Fixed yaml formatting issues, save context for action = answer

1. yaml formatting issue fixed.
2. store context if action = answer.
This commit is contained in:
AKP 2025-03-22 03:08:28 +05:30 committed by GitHub
parent 4ab2bb6459
commit 6e94481c29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -18,7 +18,7 @@ class DecideAction(Node):
print(f"🤔 Agent deciding what to do next...") print(f"🤔 Agent deciding what to do next...")
# Create a prompt to help the LLM decide what to do next # Create a prompt to help the LLM decide what to do next with proper yaml formatting
prompt = f""" prompt = f"""
### CONTEXT ### CONTEXT
You are a research assistant that can search the web. You are a research assistant that can search the web.
@ -45,8 +45,14 @@ thinking: |
<your step-by-step reasoning process> <your step-by-step reasoning process>
action: search OR answer action: search OR answer
reason: <why you chose this action> reason: <why you chose this action>
answer: <if action is answer>
search_query: <specific search query if action is search> search_query: <specific search query if action is search>
```""" ```
IMPORTANT: Make sure to:
1. Use proper indentation (4 spaces) for all multi-line fields
2. Use the | character for multi-line text fields
3. Keep single-line fields without the | character
"""
# Call the LLM to make a decision # Call the LLM to make a decision
response = call_llm(prompt) response = call_llm(prompt)
@ -64,6 +70,7 @@ search_query: <specific search query if action is search>
shared["search_query"] = exec_res["search_query"] shared["search_query"] = exec_res["search_query"]
print(f"🔍 Agent decided to search for: {exec_res['search_query']}") print(f"🔍 Agent decided to search for: {exec_res['search_query']}")
else: else:
shared["context"] = exec_res["answer"] #save the context if LLM gives the answer without searching.
print(f"💡 Agent decided to answer the question") print(f"💡 Agent decided to answer the question")
# Return the action to determine the next node in the flow # Return the action to determine the next node in the flow
@ -125,4 +132,4 @@ Provide a comprehensive answer using the research results.
print(f"✅ Answer generated successfully") print(f"✅ Answer generated successfully")
# We're done - no need to continue the flow # We're done - no need to continue the flow
return "done" return "done"