-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlanAndSolvemain.py
More file actions
28 lines (24 loc) · 965 Bytes
/
Copy pathPlanAndSolvemain.py
File metadata and controls
28 lines (24 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from PlanAndSolve.executor import Executor
from PlanAndSolve.planner import Planner
from HelloAgentsLLM import HelloAgentsLLM
class PlanAndSolveAgent:
def __init__(self,llm_client:HelloAgentsLLM):
self.llm_client = llm_client
self.planner = Planner(self.llm_client)
self.executor = Executor(self.llm_client)
def run(self,question:str):
print(f"\n--- 开始处理问题 ---\n问题: {question}")
plan = self.planner.plan(question)
if not plan:
print("\n--- 任务终止 --- \n无法生成有效的行动计划。")
return
final_answer = self.executor.execute(question, plan)
print(f"\n--- 任务完成 --- \n最终答案: {final_answer}")
if __name__ == '__main__':
try:
llm_client = HelloAgentsLLM()
agent = PlanAndSolveAgent(llm_client)
question = "你是谁?"
agent.run(question)
except ValueError as e:
print(e)