Skip to content

Commit

Permalink
doc: Add cookbooks and ideas for what to build with julep (#592)
Browse files Browse the repository at this point in the history
Signed-off-by: Diwank Singh Tomer <[email protected]>

<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> Add Claude-generated notebooks for task execution and management using
Julep client, with updates to execution handling and agent models.
> 
>   - **Behavior**:
> - Adds `time.sleep()` to wait for task execution completion in
`01-Website_Crawler_using_Spider.py`,
`02-Sarcastic_News_Headline_Generator.py`,
`03-SmartResearcher_With_WebSearch.py`,
`04-TripPlanner_With_Weather_And_WikiInfo.py`,
`07-Integrating_External_Tools_and_APIs.py`,
`08-Managing_Persistent_Sessions.py`,
`09-User_Management_and_Personalization.py`,
`10-Document_Management_and_Search.py`,
`11-Advanced_Chat_Interactions.py`, `12-Monitoring_Task_Executions.py`,
and `13-Error_Handling_and_Recovery.py`.
> - Updates print statements for execution steps in
`01-Website_Crawler_using_Spider.py`,
`02-Sarcastic_News_Headline_Generator.py`,
`03-SmartResearcher_With_WebSearch.py`,
`04-TripPlanner_With_Weather_And_WikiInfo.py`,
`07-Integrating_External_Tools_and_APIs.py`,
`08-Managing_Persistent_Sessions.py`,
`09-User_Management_and_Personalization.py`,
`10-Document_Management_and_Search.py`,
`11-Advanced_Chat_Interactions.py`, `12-Monitoring_Task_Executions.py`,
and `13-Error_Handling_and_Recovery.py`.
> - Changes agent model to `gpt-4o` in
`05-Basic_Agent_Creation_and_Interaction.py`,
`06-Designing_Multi-Step_Tasks.py`,
`07-Integrating_External_Tools_and_APIs.py`,
`08-Managing_Persistent_Sessions.py`,
`09-User_Management_and_Personalization.py`,
`10-Document_Management_and_Search.py`,
`11-Advanced_Chat_Interactions.py`, `12-Monitoring_Task_Executions.py`,
and `13-Error_Handling_and_Recovery.py`.
>   - **Misc**:
> - Adds "UNDER CONSTRUCTION" comments to indicate incomplete
functionality in `05-Basic_Agent_Creation_and_Interaction.py`,
`10-Document_Management_and_Search.py`,
`11-Advanced_Chat_Interactions.py`, `12-Monitoring_Task_Executions.py`,
and `13-Error_Handling_and_Recovery.py`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=julep-ai%2Fjulep&utm_source=github&utm_medium=referral)<sup>
for 7ffae7f. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->

---------

Signed-off-by: Diwank Singh Tomer <[email protected]>
Co-authored-by: vedantsahai18 <[email protected]>
Co-authored-by: Ikko Eltociear Ashimine <[email protected]>
Co-authored-by: creatorrr <[email protected]>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent a51441a commit d0bef2c
Show file tree
Hide file tree
Showing 17 changed files with 278 additions and 206 deletions.
6 changes: 3 additions & 3 deletions cookbooks/01-Website_Crawler_using_Spider.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a Task which uses a agent to generate a sarcastic response to a given text using a DuckDuckGo search tool.\n",
"Here is a Task to crawl a website using the Spider Integration tool.\n",
"\n",
"More on how to define a task can be found [here](https://github.com/julep-ai/julep/blob/dev/docs/julep-concepts.md)."
]
Expand Down Expand Up @@ -207,7 +207,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating/Updating a task to generate a sarcastic response to a given text using a Intergation."
"Creating/Updating a task"
]
},
{
Expand Down Expand Up @@ -237,7 +237,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creates a execution worflow for the Task defined in the yaml file."
"Creates a execution worklow for the Task defined in the yaml file."
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions cookbooks/01-Website_Crawler_using_Spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
print(client.executions.transitions.stream(execution_id=execution.id))
6 changes: 2 additions & 4 deletions cookbooks/02-Sarcastic_News_Headline_Generator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a Task which uses a agent to generate a sarcastic response to a given text using a DuckDuckGo search tool.\n",
"\n",
"More on how to define a task can be found [here](https://github.com/julep-ai/julep/blob/dev/docs/julep-concepts.md)."
]
},
Expand Down Expand Up @@ -242,7 +240,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating/Updating a task to generate a sarcastic response to a given text using a Intergation."
"Creating/Updating a task."
]
},
{
Expand Down Expand Up @@ -272,7 +270,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creates a execution worflow for the Task defined in the yaml file."
"Creates a execution worklow for the Task defined in the yaml file."
]
},
{
Expand Down
12 changes: 9 additions & 3 deletions cookbooks/02-Sarcastic_News_Headline_Generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

6 changes: 2 additions & 4 deletions cookbooks/03-SmartResearcher_With_WebSearch.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a Task which uses a agent to generate a sarcastic response to a given text using a DuckDuckGo and Wikipedia tool.\n",
"\n",
"More on how to define a task can be found [here](https://github.com/julep-ai/julep/blob/dev/docs/julep-concepts.md)."
]
},
Expand Down Expand Up @@ -272,7 +270,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating/Updating a task to generate a sarcastic response to a given text using a Intergation."
"Creating/Updating a task."
]
},
{
Expand Down Expand Up @@ -302,7 +300,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creates a execution worflow for the Task defined in the yaml file."
"Creates a execution worklow for the Task defined in the yaml file."
]
},
{
Expand Down
14 changes: 10 additions & 4 deletions cookbooks/03-SmartResearcher_With_WebSearch.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
# Stream the steps of the defined task
print("Streaming execution transitions:")
print(client.executions.transitions.stream(execution_id=execution.id))
8 changes: 3 additions & 5 deletions cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"div align=\"center\">\n",
"<div align=\"center\">\n",
" <img src=\"https://socialify.git.ci/julep-ai/julep/image?description=1&descriptionEditable=Build%20AI%20agents%20and%20workflows%20with%20a%20simple%20API&font=Source%20Code%20Pro&logo=https%3A%2F%2Fraw.githubusercontent.com%2Fjulep-ai%2Fjulep%2Fdev%2F.github%2Fjulep-logo.svg&owner=1&pattern=Solid&stargazers=1&theme=Auto\" alt=\"julep\" width=\"640\" height=\"320\" />\n",
"</div>\n",
"\n",
Expand Down Expand Up @@ -219,8 +219,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Here is a Task which uses a agent to generate a sarcastic response to a given text using a DuckDuckGo and Wikipedia tool.\n",
"\n",
"More on how to define a task can be found [here](https://github.com/julep-ai/julep/blob/dev/docs/julep-concepts.md)."
]
},
Expand Down Expand Up @@ -295,7 +293,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creating/Updating a task to generate a sarcastic response to a given text using a Intergation."
"Creating/Updating a task."
]
},
{
Expand Down Expand Up @@ -325,7 +323,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Creates a execution worflow for the Task defined in the yaml file."
"Creates a execution worklow for the Task defined in the yaml file."
]
},
{
Expand Down
17 changes: 11 additions & 6 deletions cookbooks/04-TripPlanner_With_Weather_And_WikiInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,22 @@

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:")
print(execution.output)

# 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)
# Stream the steps of the defined task
print("Streaming execution transitions:")
print(client.executions.transitions.stream(execution_id=execution.id))
4 changes: 3 additions & 1 deletion cookbooks/05-Basic_Agent_Creation_and_Interaction.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# UNDER CONSTRUCTION - NOT WORKING YET

import uuid
from julep import Client

Expand Down Expand Up @@ -26,7 +28,7 @@
agent_id=AGENT_UUID,
name=name,
about=about,
model="gpt-4-turbo",
model="gpt-4o",
)

print(f"Agent created with ID: {agent.id}")
Expand Down
19 changes: 10 additions & 9 deletions cookbooks/06-Designing_Multi-Step_Tasks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import uuid
import yaml
import yaml, time
from julep import Client

# Global UUID is generated for agent and task
Expand Down Expand Up @@ -28,14 +28,13 @@
agent_id=AGENT_UUID,
name=name,
about=about,
model="gpt-4-turbo",
model="gpt-4o",
)

# Add a web search tool to the agent
client.agents.tools.create(
agent_id=AGENT_UUID,
name="web_search",
description="Search the web for information.",
integration={
"provider": "brave",
"method": "search",
Expand Down Expand Up @@ -71,7 +70,7 @@
# Step 2: Tool Call - Web search for each question
- foreach:
in: "_.split('\n')"
in: _.split('\\n')
do:
tool: web_search
arguments:
Expand Down Expand Up @@ -121,18 +120,20 @@

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
print("Execution Steps:")
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)
# Stream the steps of the defined task
print("Streaming execution transitions:")
print(client.executions.transitions.stream(execution_id=execution.id))
Loading

0 comments on commit d0bef2c

Please sign in to comment.