diff --git a/cookbooks/01-Website_Crawler_using_Spider.py b/cookbooks/01-Website_Crawler_using_Spider.py
index 978fd3286..69d5785be 100644
--- a/cookbooks/01-Website_Crawler_using_Spider.py
+++ b/cookbooks/01-Website_Crawler_using_Spider.py
@@ -57,15 +57,20 @@
input={}
)
+# Waiting for the execution to complete
+import time
+time.sleep(5)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print("Execution output:", execution.output)
# Listing all the steps of a defined task
transitions = client.executions.transitions.list(execution_id=execution.id).items
-print("Execution transitions:", transitions)
+print("Execution Steps:")
+for transition in transitions:
+ print(transition)
-# Streaming the execution steps
+# Stream the steps of the defined task
print("Streaming execution transitions:")
-for transition in client.executions.transitions.stream(execution_id=execution.id):
- print(transition)
\ No newline at end of file
+print(client.executions.transitions.stream(execution_id=execution.id))
\ No newline at end of file
diff --git a/cookbooks/02-Sarcastic_News_Headline_Generator.py b/cookbooks/02-Sarcastic_News_Headline_Generator.py
index c658a6569..cf305c15e 100644
--- a/cookbooks/02-Sarcastic_News_Headline_Generator.py
+++ b/cookbooks/02-Sarcastic_News_Headline_Generator.py
@@ -75,15 +75,21 @@
}
)
+# Waiting for the execution to complete
+import time
+time.sleep(5)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print("Execution output:", execution.output)
# Listing all the steps of a defined task
transitions = client.executions.transitions.list(execution_id=execution.id).items
-print("Execution transitions:", transitions)
+print("Execution Steps:")
+for transition in transitions:
+ print(transition)
# Stream the steps of the defined task
print("Streaming execution transitions:")
-for transition in client.executions.transitions.stream(execution_id=execution.id):
- print(transition)
+print(client.executions.transitions.stream(execution_id=execution.id))
+
diff --git a/cookbooks/03-SmartResearcher_With_WebSearch.py b/cookbooks/03-SmartResearcher_With_WebSearch.py
index 9996a5dd5..6b0b210fb 100644
--- a/cookbooks/03-SmartResearcher_With_WebSearch.py
+++ b/cookbooks/03-SmartResearcher_With_WebSearch.py
@@ -1,6 +1,6 @@
import uuid
from julep import Client
-import yaml
+import yaml, time
# Global UUID is generated for agent and task
AGENT_UUID = uuid.uuid4()
@@ -92,13 +92,19 @@
print(execution.id)
+# Wait for the execution to complete
+time.sleep(10)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print(execution.output)
# Listing all the steps of a defined task
transitions = client.executions.transitions.list(execution_id=execution.id).items
-print(transitions)
+print("Execution Steps:")
+for transition in transitions:
+ print(transition)
-# Streaming the execution steps
-client.executions.transitions.stream(execution_id=execution.id)
\ No newline at end of file
+# Stream the steps of the defined task
+print("Streaming execution transitions:")
+print(client.executions.transitions.stream(execution_id=execution.id))
\ No newline at end of file
diff --git a/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.ipynb b/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.ipynb
index d7fc39840..c207595a2 100644
--- a/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.ipynb
+++ b/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.ipynb
@@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "div align=\"center\">\n",
+ "
\n",
"
\n",
"
\n",
"\n",
diff --git a/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.py b/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.py
index cde5d71a6..bd446a849 100644
--- a/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.py
+++ b/cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.py
@@ -107,6 +107,10 @@
print(f"Execution ID: {execution.id}")
+# Wait for the execution to complete
+import time
+time.sleep(10)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print("Execution Output:")
@@ -114,10 +118,11 @@
# List all steps of the executed task
print("Execution Steps:")
-for item in client.executions.transitions.list(execution_id=execution.id).items:
- print(item)
+transitions = client.executions.transitions.list(execution_id=execution.id).items
+print("Execution Steps:")
+for transition in transitions:
+ print(transition)
-# Stream the execution steps in real-time
-print("Streaming Execution Steps:")
-for step in client.executions.transitions.stream(execution_id=execution.id):
- print(step)
\ No newline at end of file
+# Stream the steps of the defined task
+print("Streaming execution transitions:")
+print(client.executions.transitions.stream(execution_id=execution.id))
\ No newline at end of file
diff --git a/cookbooks/06-Designing_Multi-Step_Tasks.py b/cookbooks/06-Designing_Multi-Step_Tasks.py
index 395f409cf..799bed817 100644
--- a/cookbooks/06-Designing_Multi-Step_Tasks.py
+++ b/cookbooks/06-Designing_Multi-Step_Tasks.py
@@ -1,5 +1,5 @@
import uuid
-import yaml
+import yaml, time
from julep import Client
# Global UUID is generated for agent and task
@@ -121,10 +121,13 @@
print(f"Execution ID: {execution.id}")
+# Wait for the execution to complete
+time.sleep(10)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print("Execution Output:")
-print(execution.output)
+print(client.executions.transitions.list(execution_id=execution.id).items[0].output)
# Listing all the steps of a defined task
transitions = client.executions.transitions.list(execution_id=execution.id).items
@@ -132,7 +135,6 @@
for transition in transitions:
print(transition)
-# Streaming the execution steps
-print("Streaming Execution Steps:")
-for transition in client.executions.transitions.stream(execution_id=execution.id):
- print(transition)
\ No newline at end of file
+# Stream the steps of the defined task
+print("Streaming execution transitions:")
+print(client.executions.transitions.stream(execution_id=execution.id))
\ No newline at end of file
diff --git a/cookbooks/07-Integrating_External_Tools_and_APIs.py b/cookbooks/07-Integrating_External_Tools_and_APIs.py
index fa93f687a..02ba4f367 100644
--- a/cookbooks/07-Integrating_External_Tools_and_APIs.py
+++ b/cookbooks/07-Integrating_External_Tools_and_APIs.py
@@ -110,17 +110,21 @@
print(f"Execution ID: {execution.id}")
+# Waiting for the execution to complete
+import time
+time.sleep(10)
+
# Getting the execution details
execution = client.executions.get(execution.id)
print("Execution Output:")
print(execution.output)
# List all steps of the executed task
+transitions = client.executions.transitions.list(execution_id=execution.id).items
print("Execution Steps:")
-for item in client.executions.transitions.list(execution_id=execution.id).items:
- print(item)
+for transition in transitions:
+ print(transition)
-# Stream the execution steps in real-time
-print("Streaming Execution Steps:")
-for step in client.executions.transitions.stream(execution_id=execution.id):
- print(step)
\ No newline at end of file
+# Stream the steps of the defined task
+print("Streaming execution transitions:")
+print(client.executions.transitions.stream(execution_id=execution.id))
\ No newline at end of file
diff --git a/cookbooks/08-Managing_Persistent_Sessions.py b/cookbooks/08-Managing_Persistent_Sessions.py
index 40077b7df..a32b29cb2 100644
--- a/cookbooks/08-Managing_Persistent_Sessions.py
+++ b/cookbooks/08-Managing_Persistent_Sessions.py
@@ -44,7 +44,7 @@
main:
- prompt:
- role: system
+ - role: system
content: >-
You are a session management agent. Your task is to maintain context
across user interactions. Here's the current context: {{inputs[0].session_context}}
@@ -53,16 +53,17 @@
Respond to the user and update the context with any new relevant information.
unwrap: true
-
+
- evaluate:
- updated_context: >-
- {**inputs[0].session_context,
+ session_context: >-
+ {
+ **inputs[0].session_context,
'last_interaction': inputs[0].user_input,
- 'agent_response': _}
+ 'agent_response': _}
- return:
response: _
- context: outputs[1].updated_context
+ context: outputs[1].session_context
""")
# Creating the task
@@ -78,7 +79,7 @@ def user_interaction(prompt):
# Create a session
session = client.sessions.create(
- agent_id=AGENT_UUID,
+ agent=agent.id,
context_overflow="adaptive" # Use adaptive context management
)
@@ -100,10 +101,15 @@ def user_interaction(prompt):
# Get the execution result
result = client.executions.get(execution.id)
+
+ time.sleep(2)
# Update the context and print the response
- context = result.output['context']
- print(f"Agent: {result.output['response']}")
+ final_response = client.executions.transitions.list(execution_id=result.id).items[0].output
+ print(final_response)
+ # print(client.executions.transitions.list(execution_id=result.id).items[0])
+ context = final_response['session_context']
+ print(f"Agent: {final_response['session_context']['agent_response']}")
print(f"Updated Context: {context}")
print()
@@ -127,11 +133,12 @@ def user_interaction(prompt):
)
overflow_result = client.executions.get(overflow_execution.id)
-print(f"Agent response to large input: {overflow_result.output['response']}")
-print(f"Updated context after overflow: {overflow_result.output['context']}")
+time.sleep(2)
+overflow_response = client.executions.transitions.list(execution_id=overflow_result.id).items[0].output
+print(f"Agent response to large input: {overflow_response['session_context']['agent_response']}")
+print(f"Updated context after overflow: {overflow_response['session_context']}")
# Display session history
print("\nSession History:")
-history = client.sessions.messages.list(session_id=session.id)
-for message in history.items:
- print(f"{message.role}: {message.content}")
\ No newline at end of file
+history = client.sessions.history(session_id=session.id)
+print(history)
diff --git a/cookbooks/09-User_Management_and_Personalization.py b/cookbooks/09-User_Management_and_Personalization.py
index 18f9df238..7ee30fc28 100644
--- a/cookbooks/09-User_Management_and_Personalization.py
+++ b/cookbooks/09-User_Management_and_Personalization.py
@@ -48,7 +48,7 @@
main:
- prompt:
- role: system
+ - role: system
content: >-
You are a user registration assistant. Create a user profile based on the following information:
Username: {{inputs[0].username}}
@@ -60,10 +60,10 @@
- evaluate:
user_profile: >-
{
- "username": inputs[0].username,
- "interests": inputs[0].interests,
- "bio": _.split('\n\n')[0],
- "content_preferences": _.split('\n\n')[1]
+ 'username': {{inputs[0].username}},
+ 'interests': {{inputs[0].interests}},
+ 'bio': '_.split('\n\n')[0]',
+ 'content_preferences': '_.split('\n\n')[1]'
}
- return: outputs[1].user_profile
@@ -85,37 +85,33 @@
properties:
user_profile:
type: object
-
-tools:
-- name: content_database
- type: integration
- integration:
- provider: mock
- setup:
- data: [
- {"id": 1, "title": "Introduction to AI", "category": "Technology"},
- {"id": 2, "title": "Healthy Eating Habits", "category": "Health"},
- {"id": 3, "title": "Financial Planning 101", "category": "Finance"},
- {"id": 4, "title": "The Art of Photography", "category": "Art"},
- {"id": 5, "title": "Beginner's Guide to Yoga", "category": "Fitness"}
- ]
+ description: User's profile containing their interests and preferences.
+ content_list:
+ type: array
+ description: List of available content to recommend from.
+ items:
+ type: object
+ properties:
+ id:
+ type: integer
+ title:
+ type: string
+ category:
+ type: string
main:
-- tool: content_database
- arguments: {}
-
- prompt:
- role: system
+ - role: system
content: >-
You are a content recommendation system. Based on the user's profile and the available content,
recommend 3 pieces of content that best match the user's interests and preferences.
-
+
User Profile:
{{inputs[0].user_profile}}
-
+
Available Content:
- {{outputs[0]}}
-
+ {{inputs[0].content_list}}
+
Provide your recommendations in the following format:
1. [Content ID] - [Content Title] - Reason for recommendation
2. [Content ID] - [Content Title] - Reason for recommendation
@@ -123,6 +119,7 @@
unwrap: true
- return: _
+
""")
# Creating the recommendation task
@@ -144,17 +141,27 @@ def register_user(username, interests):
result = client.executions.get(execution.id)
return result.output
-# Function to get personalized content recommendations
+# Function to get personalized recommendations for a user
def get_recommendations(user_profile):
+ content_list = [
+ {"id": 1, "title": "Introduction to AI", "category": "Technology"},
+ {"id": 2, "title": "Healthy Eating Habits", "category": "Health"},
+ {"id": 3, "title": "Financial Planning 101", "category": "Finance"},
+ {"id": 4, "title": "The Art of Photography", "category": "Art"},
+ {"id": 5, "title": "Beginner's Guide to Yoga", "category": "Fitness"}
+ ]
+
execution = client.executions.create(
task_id=RECOMMENDATION_TASK_UUID,
input={
- "user_profile": user_profile
+ "user_profile": user_profile,
+ "content_list": content_list
}
)
result = client.executions.get(execution.id)
return result.output
+
# Function to update user preferences
def update_user_preferences(user_profile, new_interests):
user_profile["interests"] = list(set(user_profile["interests"] + new_interests))