Skip to content

Commit

Permalink
fix checking final chunk in ReAct agent (#11280)
Browse files Browse the repository at this point in the history
  • Loading branch information
leehuwuj authored Feb 26, 2024
1 parent 14c52d4 commit cc8e1ee
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions llama-index-core/llama_index/core/agent/react/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ def _infer_stream_chunk_is_final(self, chunk: ChatResponse) -> bool:
"""
latest_content = chunk.message.content
if latest_content:
if not latest_content.startswith(
# doesn't follow thought-action format
if len(latest_content) > len("Thought") and not latest_content.startswith(
"Thought"
): # doesn't follow thought-action format
):
return True
elif "Answer: " in latest_content:
return True
else:
if "Answer: " in latest_content:
return True
return False

def _add_back_chunk_to_stream(
Expand Down

0 comments on commit cc8e1ee

Please sign in to comment.