浏览代码

Merge pull request #632 from Captain-Rhino/fix-context-builder-llmresponse

fix: 修复 chapter9 示例中的 LLMResponse 类型问题
Sizhou Chen 3 周之前
父节点
当前提交
cc9cda9e38
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      code/chapter9/02_context_builder_with_agent.py

+ 2 - 2
code/chapter9/02_context_builder_with_agent.py

@@ -10,7 +10,7 @@ from dotenv import load_dotenv
 load_dotenv()
 from hello_agents import SimpleAgent, HelloAgentsLLM, ToolRegistry
 from hello_agents.context import ContextBuilder, ContextConfig
-from hello_agents.tools import MemoryTool, RAGTool
+#from hello_agents.tools import MemoryTool, RAGTool
 from hello_agents.core.message import Message
 from datetime import datetime
 
@@ -50,7 +50,7 @@ class ContextAwareAgent(SimpleAgent):
             {"role": "system", "content": optimized_context},
             {"role": "user", "content": user_input}
         ]
-        response = self.llm.invoke(messages)
+        response = self.llm.invoke(messages).content
 
         # 3. 更新对话历史
         self.conversation_history.append(