Explorar el Código

docs(chapter4): sync llm_client snippet with empty-choices fix

Mirrors the fix from ece18a4 (skip empty-choices chunks in streaming
response) into the in-text code listings of both the Chinese and
English chapter 4 documents, so prose-shown code stays in sync with
code/chapter4/llm_client.py.

Addresses review feedback on PR for issue #522.
Jijie Zhou hace 1 mes
padre
commit
3badb16842

+ 2 - 0
docs/chapter4/Chapter4-Building-Classic-Agent-Paradigms.md

@@ -92,6 +92,8 @@ class HelloAgentsLLM:
             print("✅ Large language model response successful:")
             collected_content = []
             for chunk in response:
+                if not chunk.choices:
+                    continue
                 content = chunk.choices[0].delta.content or ""
                 print(content, end="", flush=True)
                 collected_content.append(content)

+ 2 - 0
docs/chapter4/第四章 智能体经典范式构建.md

@@ -92,6 +92,8 @@ class HelloAgentsLLM:
             print("✅ 大语言模型响应成功:")
             collected_content = []
             for chunk in response:
+                if not chunk.choices:
+                    continue
                 content = chunk.choices[0].delta.content or ""
                 print(content, end="", flush=True)
                 collected_content.append(content)