Skip to content

Commit

Permalink
Refactor data analysis workflow for better collaboration
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbeevip committed Jul 12, 2024
1 parent cb8ef66 commit 46b5b78
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
30 changes: 30 additions & 0 deletions src/langchain_lab/langgraph/draw_plantuml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from langgraph.graph import Graph


class PlantUMLGraph:
def __init__(self, graph: Graph):
self.graph = graph

def draw_plantuml(self) -> str:
plantuml = []
graph_json = self.graph.to_json()['graph']
graph_nodes = graph_json['nodes']
graph_edges = graph_json['edges']
plantuml.append("@startuml")
for node in graph_nodes:
pass
# plantuml.append(f"class {node['id']} {{")
# for attr in node['attrs']:
# plantuml.append(f" {attr['key']} : {attr['value']}")
# plantuml.append("}")

for edge in graph_edges:
source_node = edge['source'] if edge['source'] != '__start__' else '(*)'
target_node = edge['target'] if edge['target'] != '__end__' else '(*)'
plantuml.append(f"{source_node} --> {target_node}")

plantuml.append("@enduml")
return "\n".join(plantuml)

def print_plantuml(self):
print(self.draw_plantuml())
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
@startuml
start

:网络运营经理 (NetworkOpsManager);
:接收统计报表并初步审核;
:召集分析会议;

:无线网络工程师 (WirelessNetworkEngineer);
:分析无线网络性能和资源数据;


:数据分析师 (DataAnalyst);
:深入挖掘数据,提供建议;
:准备数据可视化报告;

:网络维护人员 (NetworkMaintenanceTech);
:确认并解决技术问题;


:IT运营经理 (ITOpsManager);
:协调IT资源,支持分析和解决问题;
:优化网络操作流程;

:客户服务经理 (CustomerServiceManager);
:整理客户投诉和反馈;


:高层管理人员 (ExecutiveManagement);
:审核整体报告和建议;
:批准必要的优化项目;

:质量保证(QA)团队 (QATeam);
:评估最终网络服务质量;
:确保符合公司标准和法规;

stop
(*) --> networkOpsManager
networkOpsManager --> dataAnalyst
networkOpsManager --> data_tool
networkOpsManager --> (*)
dataAnalyst --> networkOpsManager
dataAnalyst --> data_tool
dataAnalyst --> (*)
data_tool --> networkOpsManager
data_tool --> dataAnalyst
@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from langgraph.prebuilt.tool_executor import ToolExecutor, ToolInvocation
from typing_extensions import TypedDict

from langchain_lab.langgraph.draw_plantuml import PlantUMLGraph

warnings.filterwarnings("ignore", category=UserWarning, module="openpyxl")


Expand Down Expand Up @@ -133,6 +135,7 @@ def __init__(self, openai_api_base: str, openai_api_key: str, model_name: str, r
)
workflow.set_entry_point("networkOpsManager")
self.graph = workflow.compile()
PlantUMLGraph(self.graph).print_plantuml()

# from IPython.display import Image
# import matplotlib.pyplot as plt
Expand Down Expand Up @@ -306,3 +309,4 @@ def run(self):
f.write(f"{msg.additional_kwargs}\n")
f.write(msg.content)
f.write("\n\n") # 结束

0 comments on commit 46b5b78

Please sign in to comment.