-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'd/new-cookbooks' into d/update-readme
- Loading branch information
Showing
17 changed files
with
3,244 additions
and
147 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import uuid | ||
import yaml | ||
from julep import Client | ||
|
||
# Global UUID is generated for agent and task | ||
AGENT_UUID = uuid.uuid4() | ||
TASK_UUID = uuid.uuid4() | ||
|
||
# Creating Julep Client with the API Key | ||
api_key = os.getenv("JULEP_API_KEY") | ||
if not api_key: | ||
raise ValueError("JULEP_API_KEY not found in environment variables") | ||
|
||
client = Client(api_key=api_key, environment="dev") | ||
|
||
# Creating an "agent" | ||
name = "Jarvis" | ||
about = "The original AI conscious the Iron Man." | ||
|
||
# Create the agent | ||
agent = client.agents.create_or_update( | ||
agent_id=AGENT_UUID, | ||
name=name, | ||
about=about, | ||
model="gpt-4o", | ||
) | ||
|
||
# Defining a Task | ||
task_def = yaml.safe_load(""" | ||
name: Agent Crawler | ||
tools: | ||
- name: spider_crawler | ||
type: integration | ||
integration: | ||
provider: spider | ||
setup: | ||
spider_api_key: "{{SPIDER_API_KEY}}" | ||
main: | ||
- tool: spider_crawler | ||
arguments: | ||
url: '"https://spider.cloud"' | ||
""") | ||
|
||
# Creating/Updating a task | ||
task = client.tasks.create_or_update( | ||
task_id=TASK_UUID, | ||
agent_id=AGENT_UUID, | ||
**task_def | ||
) | ||
|
||
# Creating an Execution | ||
execution = client.executions.create( | ||
task_id=TASK_UUID, | ||
input={} | ||
) | ||
|
||
# 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) | ||
|
||
# Streaming the execution steps | ||
print("Streaming execution transitions:") | ||
for transition in client.executions.transitions.stream(execution_id=execution.id): | ||
print(transition) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import os | ||
import uuid | ||
import yaml | ||
from julep import Client | ||
|
||
# Global UUID is generated for agent and task | ||
AGENT_UUID = uuid.uuid4() | ||
TASK_UUID = uuid.uuid4() | ||
|
||
# Create Julep Client with the API Key | ||
api_key = os.getenv("JULEP_API_KEY") | ||
if not api_key: | ||
raise ValueError("JULEP_API_KEY not found in environment variables") | ||
|
||
client = Client(api_key=api_key, environment="dev") | ||
|
||
# Define agent properties | ||
name = "Sarcastic News Bot" | ||
about = "An AI agent specialized in generating sarcastic news headlines." | ||
default_settings = { | ||
"temperature": 0.7, | ||
"top_p": 1, | ||
"min_p": 0.01, | ||
"presence_penalty": 0, | ||
"frequency_penalty": 0, | ||
"length_penalty": 1.0, | ||
"max_tokens": 150, | ||
} | ||
|
||
# Create the agent | ||
agent = client.agents.create_or_update( | ||
agent_id=AGENT_UUID, | ||
name=name, | ||
about=about, | ||
model="gpt-4o", | ||
) | ||
|
||
# Define the task | ||
task_def = yaml.safe_load(""" | ||
name: Sarcasm Headline Generator | ||
tools: | ||
- name: brave_search | ||
type: integration | ||
integration: | ||
provider: brave | ||
setup: | ||
api_key: "YOUR_BRAVE_API_KEY" | ||
main: | ||
- tool: brave_search | ||
arguments: | ||
query: "_.topic + ' funny'" | ||
- prompt: | ||
- role: system | ||
content: >- | ||
You are a sarcastic news headline writer. Generate a witty and sarcastic headline | ||
for the topic {{inputs[0].topic}}. Use the following information for context: {{_}} | ||
unwrap: true | ||
""") | ||
|
||
# Creating/Updating a task | ||
task = client.tasks.create_or_update( | ||
task_id=TASK_UUID, | ||
agent_id=AGENT_UUID, | ||
**task_def | ||
) | ||
|
||
# Creating an Execution | ||
execution = client.executions.create( | ||
task_id=TASK_UUID, | ||
input={ | ||
"topic": "elon musk" | ||
} | ||
) | ||
|
||
# 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) | ||
|
||
# Stream the steps of the defined task | ||
print("Streaming execution transitions:") | ||
for transition in client.executions.transitions.stream(execution_id=execution.id): | ||
print(transition) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import uuid | ||
from julep import Client | ||
import yaml | ||
|
||
# Global UUID is generated for agent and task | ||
AGENT_UUID = uuid.uuid4() | ||
TASK_UUID = uuid.uuid4() | ||
|
||
# Creating Julep Client with the API Key | ||
api_key = "" # Your API key here | ||
client = Client(api_key=api_key, environment="dev") | ||
|
||
# Creating an "agent" | ||
name = "Jarvis" | ||
about = "The original AI conscious the Iron Man." | ||
default_settings = { | ||
"temperature": 0.7, | ||
"top_p": 1, | ||
"min_p": 0.01, | ||
"presence_penalty": 0, | ||
"frequency_penalty": 0, | ||
"length_penalty": 1.0, | ||
"max_tokens": 150, | ||
} | ||
|
||
# Create the agent | ||
agent = client.agents.create_or_update( | ||
agent_id=AGENT_UUID, | ||
name=name, | ||
about=about, | ||
model="gpt-4o", | ||
) | ||
|
||
# Defining a Task | ||
task_def = yaml.safe_load(""" | ||
name: Research Assistant to find Wikipedia Keywords | ||
input_schema: | ||
type: object | ||
properties: | ||
topics: | ||
type: array | ||
items: | ||
type: string | ||
description: The topics to search for. | ||
tools: | ||
- name: brave_search | ||
type: integration | ||
integration: | ||
provider: brave | ||
setup: | ||
api_key: "YOUR_API_KEY" | ||
main: | ||
- over: _.topics | ||
map: | ||
tool: brave_search | ||
arguments: | ||
query: "'the latest news about ' + _" | ||
- over: _ | ||
parallelism: 2 | ||
map: | ||
prompt: | ||
- role: system | ||
content: >- | ||
You are a research assistant. | ||
I need you to do in-depth research on topics trending in the news currently. | ||
Based on the following latest html news snippet, come up with a list of wikipedia keywords to search: | ||
"{{_}}" | ||
Your response should be a list of keywords, separated by commas. Do not add any other text. | ||
Example: `KEYWORDS: keyword1, keyword2, keyword3` | ||
unwrap: true | ||
""") | ||
|
||
# Creating/Updating a task | ||
task = client.tasks.create_or_update( | ||
task_id=TASK_UUID, | ||
agent_id=AGENT_UUID, | ||
**task_def | ||
) | ||
|
||
# Creating an Execution | ||
execution = client.executions.create( | ||
task_id=task.id, | ||
input={ | ||
"topics": ["Burger King Cup on the Ground Behind a Wendy's", "Forbidden Chemical X", "Finger Bracelets", "Amusing Notions"] | ||
} | ||
) | ||
|
||
print(execution.id) | ||
|
||
# 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) | ||
|
||
# Streaming the execution steps | ||
client.executions.transitions.stream(execution_id=execution.id) |
Oops, something went wrong.