Skip to content

Commit

Permalink
d(cookbooks): minor bug fixes for 5,6,7 ckbks,testing remains
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedantsahai18 committed Oct 6, 2024
1 parent 000d1b4 commit fab18f3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 33 deletions.
9 changes: 7 additions & 2 deletions cookbooks/05-Basic_Agent_Creation_and_Interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,22 @@

# Create a session for interaction
session = client.sessions.create(
agent_id=agent.id,
agent=agent.id,
context_overflow="adaptive"
)

print(f"Session created with ID: {session.id}")

# Function to chat with the agent
def chat_with_agent(message):
message = {
"role": "user",
"content": message,
}
# TODO: message validation error
response = client.sessions.chat(
session_id=session.id,
message=message
messages=[message],
)
return response.choices[0].message.content

Expand Down
29 changes: 15 additions & 14 deletions cookbooks/06-Designing_Multi-Step_Tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,39 +60,39 @@
integration:
provider: brave
setup:
api_key: "your_brave_api_key"
api_key: "your_api_key"
main:
# Step 1: Prompt - Initial research question
- prompt:
- role: system
content: "You are a research assistant. Your task is to formulate three specific research questions about the given topic: {{inputs[0].topic}}"
- role: system
content: "You are a research assistant. Your task is to formulate three specific research questions about the given topic: {{inputs[0].topic}}"
unwrap: true
# Step 2: Tool Call - Web search for each question
- foreach:
in: "_.split('\\n')"
in: "_.split('\n')"
do:
tool: web_search
arguments:
query: "_"
query: _
# Step 3: Evaluate - Extract relevant information
- evaluate:
relevant_info: "[output['organic'][0]['description'] for output in _]"
relevant_info: "[output for output in _]"
# Step 4: Conditional Logic - Check if enough information is gathered
- if: "len(_.relevant_info) >= 3"
then:
- prompt:
- role: system
content: "Summarize the following information about {{inputs[0].topic}}:\n{{_.relevant_info}}"
unwrap: true
prompt:
- role: system
content: "Summarize the following information about {{inputs[0].topic}}:\n{{_.relevant_info}}"
unwrap: true
else:
- prompt:
- role: system
content: "Not enough information gathered. Please provide a brief overview of {{inputs[0].topic}} based on your knowledge."
unwrap: true
prompt:
- role: system
content: "Not enough information gathered. Please provide a brief overview of {{inputs[0].topic}} based on your knowledge."
unwrap: true
# Step 5: Log - Record the summary
- log: "Summary for {{inputs[0].topic}}: {{_}}"
Expand All @@ -101,6 +101,7 @@
- return:
summary: "_"
topic: "inputs[0].topic"
""")

# Creating/Updating a task
Expand Down
19 changes: 2 additions & 17 deletions cookbooks/07-Integrating_External_Tools_and_APIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
integration:
provider: wikipedia
- name: news_api
type: integration
integration:
provider: newsapi
setup:
api_key: "YOUR_NEWSAPI_API_KEY"
main:
- tool: brave_search
arguments:
Expand All @@ -76,12 +69,6 @@
arguments:
query: "{{inputs[0].topic}}"
- tool: news_api
arguments:
q: "{{inputs[0].topic}}"
language: "en"
sortBy: "relevancy"
- prompt:
- role: system
content: >-
Expand All @@ -90,16 +77,14 @@
1. Overview (based on Wikipedia data)
2. Latest Developments (based on Brave Search results)
3. Recent News (based on News API results)
4. Weather Impact (if applicable, based on weather data for {{inputs[0].location}})
5. Analysis and Conclusions
3. Weather Impact (if applicable, based on weather data for {{inputs[0].location}})
4. Analysis and Conclusions
Use the following data for your report:
Brave Search Results: {{outputs[0]}}
Weather Data: {{outputs[1]}}
Wikipedia Data: {{outputs[2]}}
News API Results: {{outputs[3]}}
Provide a well-structured, informative report that synthesizes information from all these sources.
unwrap: true
Expand Down

0 comments on commit fab18f3

Please sign in to comment.