Преглед изворни кода

Merge pull request #895 from fancyboi999/fix/ch7-stream-run-duplicate-print

fix(ch7): resolve duplicate stream print in MySimpleAgent and docs
Sizhou Chen пре 1 недеља
родитељ
комит
6d9506ba26

+ 0 - 1
code/chapter7/my_simple_agent.py

@@ -214,7 +214,6 @@ class MySimpleAgent(SimpleAgent):
         print("📝 实时响应: ", end="")
         print("📝 实时响应: ", end="")
         for chunk in self.llm.stream_invoke(messages, **kwargs):
         for chunk in self.llm.stream_invoke(messages, **kwargs):
             full_response += chunk
             full_response += chunk
-            print(chunk, end="", flush=True)
             yield chunk
             yield chunk
 
 
         print()  # 换行
         print()  # 换行

+ 0 - 1
docs/chapter7/Chapter7-Building-Your-Agent-Framework.md

@@ -856,7 +856,6 @@ class MySimpleAgent(SimpleAgent):
         print("📝 Real-time response: ", end="")
         print("📝 Real-time response: ", end="")
         for chunk in self.llm.stream_invoke(messages, **kwargs):
         for chunk in self.llm.stream_invoke(messages, **kwargs):
             full_response += chunk
             full_response += chunk
-            print(chunk, end="", flush=True)
             yield chunk
             yield chunk
 
 
         print()  # New line
         print()  # New line

+ 0 - 1
docs/chapter7/第七章 构建你的Agent框架.md

@@ -856,7 +856,6 @@ class MySimpleAgent(SimpleAgent):
         print("📝 实时响应: ", end="")
         print("📝 实时响应: ", end="")
         for chunk in self.llm.stream_invoke(messages, **kwargs):
         for chunk in self.llm.stream_invoke(messages, **kwargs):
             full_response += chunk
             full_response += chunk
-            print(chunk, end="", flush=True)
             yield chunk
             yield chunk
 
 
         print()  # 换行
         print()  # 换行