diff --git a/README-CN.md b/README-CN.md
index d5cb2c2de..b8f19f31a 100644
--- a/README-CN.md
+++ b/README-CN.md
@@ -596,9 +596,9 @@ client.agents.tools.create(
name="web_search",
description="搜索网络以获取信息。",
integration={
- "provider": "google",
+ "provider": "brave",
"method": "search",
- "setup": {"api_key": "your_google_api_key"},
+ "setup": {"api_key": "your_brave_api_key"},
},
)
```
@@ -617,7 +617,12 @@ session = client.sessions.create(
# 在同一会话中继续对话
response = client.sessions.chat(
session_id=session.id,
- message="继续我们之前的对话。"
+ messages=[
+ {
+ "role": "user",
+ "content": "继续我们之前的对话。"
+ }
+ ]
)
```
@@ -627,15 +632,16 @@ response = client.sessions.chat(
```python
# 上传文档
-document = client.documents.create(
- file="path/to/document.pdf",
+document = client.agents.docs.create(
+ title="AI advancements",
+ content="AI is changing the world...",
metadata={"category": "research_paper"}
)
# 搜索文档
-results = client.documents.search(
- query="AI 进展",
- filter={"category": "research_paper"}
+results = client.agents.docs.search(
+ text="AI advancements",
+ metadata_filter={"category": "research_paper"}
)
```
diff --git a/README-JP.md b/README-JP.md
index 8cd716ade..fb3c1dd97 100644
--- a/README-JP.md
+++ b/README-JP.md
@@ -600,9 +600,9 @@ client.agents.tools.create(
name="web_search",
description="Search the web for information.",
integration={
- "provider": "google",
+ "provider": "brave",
"method": "search",
- "setup": {"api_key": "your_google_api_key"},
+ "setup": {"api_key": "your_brave_api_key"},
},
)
```
@@ -614,14 +614,19 @@ Julepは、持続的なインタラクションのための強力なセッショ
```python
session = client.sessions.create(
agent_id=agent.id,
- user_id="user123",
+ user_id=user.id,
context_overflow="adaptive"
)
# 同じセッションで会話を続ける
response = client.sessions.chat(
session_id=session.id,
- message="Follow up on our previous conversation."
+ messages=[
+ {
+ "role": "user",
+ "content": "Follow up on our previous conversation."
+ }
+ ]
)
```
@@ -631,15 +636,16 @@ response = client.sessions.chat(
```python
# ドキュメントをアップロードする
-document = client.documents.create(
- file="path/to/document.pdf",
+document = client.agents.docs.create(
+ title="AI advancements",
+ content="AI is changing the world...",
metadata={"category": "research_paper"}
)
# ドキュメントを検索する
-results = client.documents.search(
- query="AI advancements",
- filter={"category": "research_paper"}
+results = client.agents.docs.search(
+ text="AI advancements",
+ metadata_filter={"category": "research_paper"}
)
```
diff --git a/README.md b/README.md
index 179e4c0a9..b636f4718 100644
--- a/README.md
+++ b/README.md
@@ -96,6 +96,13 @@ Exciting news! We're participating in DevFest.AI throughout October 2024! 🗓
- [Adding Tools to Agents](#adding-tools-to-agents)
- [Managing Sessions and Users](#managing-sessions-and-users)
- [Document Integration and Search](#document-integration-and-search)
+- [Integrations](#integrations)
+ - [Brave Search](#brave-search)
+ - [BrowserBase](#browserbase)
+ - [Email](#email)
+ - [Spider](#spider)
+ - [Weather](#weather)
+ - [Wikipedia](#wikipedia)
- [SDK Reference](#sdk-reference)
- [API Reference](#api-reference)
@@ -104,14 +111,19 @@ Exciting news! We're participating in DevFest.AI throughout October 2024! 🗓
## Introduction
-
+Julep is a platform for creating AI agents that remember past interactions and can perform complex tasks. It offers long-term memory and manages multi-step processes.
-Julep is a platform for creating AI agents that maintain state and execute complex workflows. It offers long-term context and orchestrates multi-step tasks.
+Julep enables the creation of multi-step tasks incorporating decision-making, loops, parallel processing, and integration with numerous external tools and APIs.
-Julep lets you define multi-step tasks that can include conditional logic, loops, parallel processing, and built-in integration with 100s of external tools and APIs. Typically AI applications tend to be linear and have simple chains of a handful of prompts and API calls without much branching or decision-making.
+While many AI applications are limited to simple, linear chains of prompts and API calls with minimal branching, Julep is built to handle more complex scenarios.
+
+It supports:
+- Intricate, multi-step processes
+- Dynamic decision-making
+- Parallel execution
> [!TIP]
-> Imagine you want to build an AI agent that can do more than just answer simple queries—it needs to handle complex tasks, remember past interactions, and maybe even integrate with other tools or APIs. That's where Julep comes in.
+> Imagine you want to build an AI agent that can do more than just answer simple questions—it needs to handle complex tasks, remember past interactions, and maybe even use other tools or APIs. That's where Julep comes in.
## Quick Example
@@ -119,13 +131,10 @@ Imagine a Research AI agent that can do the following:
1. Take a topic,
2. Come up with 100 search queries for that topic,
3. Perform those web searches in parallel,
- 4. Collect and compile the results,
- 5. Come up with 5 follow-up questions,
- 6. Repeat the process with new queries,
- 7. Summarize the results,
- 8. Send the summary to Discord
+ 4. Summarize the results,
+ 5. Send the summary to Discord
-In julep, this would be a single task under 80 lines of code and run fully managed all on its own. Here's a working example:
+In Julep, this would be a single task under 80 lines of code and run fully managed all on its own. All of the steps are executed on Julep's own servers and you don't need to lift a finger. Here's a working example:
```yaml
name: Research Agent
@@ -182,45 +191,19 @@ main:
tool: web_search
arguments:
query: "_"
- on_error:
parallelism: 100
# Collect the results from the web search
- evaluate:
results: "'\n'.join([item.result for item in _])"
-# Generate follow-up questions based on the results
-- prompt:
- - role: system
- content: >-
- Based on the following research results, generate 5 follow-up questions that would deepen our understanding of {{inputs[0].topic}}:
- {{_.results}}
-
- Write one question per line.
- unwrap: true
-
-- evaluate:
- follow_up_queries: "_.split('\n')"
-
-# Run the web search in parallel for each follow-up query
-- over: "_.follow_up_queries"
- map:
- tool: web_search
- arguments:
- query: "_"
-
- parallelism: 5
-
-- evaluate:
- all_results: "outputs[3].results + '\n'.join([item.result for item in _])"
-
# Summarize the results
- prompt:
- role: system
content: >
You are a research summarizer. Create a comprehensive summary of the following research results on the topic {{inputs[0].topic}}.
The summary should be well-structured, informative, and highlight key findings and insights:
- {{_.all_results}}
+ {{_.results}}
unwrap: true
# Send the summary to Discord
@@ -235,17 +218,17 @@ main:
> [!TIP]
> Julep is really useful when you want to build AI agents that can maintain context and state over long-term interactions. It's great for designing complex, multi-step workflows and integrating various tools and APIs directly into your agent's processes.
>
-> In this example, Julep will automatically manage parallel executions, retry failed steps, resend api requests, and keep the workflows running reliably until completion.
+> In this example, Julep will automatically manage parallel executions, retry failed steps, resend API requests, and keep the tasks running reliably until completion.
## Key Features
-1. **Persistent AI Agents**: Persist context and state over long-term interactions.
-2. **Stateful Sessions**: Remember past interactions for personalized responses.
-3. **Multi-Step Workflows**: Build complex, multi-step processes with loops and conditional logic.
-4. **Task Orchestration**: Manage long-running tasks that can run indefinitely.
-5. **Built-in Tools**: Integrate built-in tools and external APIs into workflows.
-6. **Self-Healing**: Julep will automatically retry failed steps, resend messages, and generally keep your workflows running smoothly.
-7. **RAG**: Use Julep's document store to build a RAG system for your own data.
+1. 🧠 **Persistent AI Agents**: Remember context and information over long-term interactions.
+2. 💾 **Stateful Sessions**: Keep track of past interactions for personalized responses.
+3. 🔄 **Multi-Step Tasks**: Build complex, multi-step processes with loops and decision-making.
+4. ⏳ **Task Management**: Handle long-running tasks that can run indefinitely.
+5. 🛠️ **Built-in Tools**: Use built-in tools and external APIs in your tasks.
+6. 🔧 **Self-Healing**: Julep will automatically retry failed steps, resend messages, and generally keep your tasks running smoothly.
+7. 📚 **RAG**: Use Julep's document store to build a system for retrieving and using your own data.
Julep is ideal for applications that require AI use cases beyond simple prompt-response models.
@@ -255,34 +238,34 @@ Julep is ideal for applications that require AI use cases beyond simple prompt-r
Think of LangChain and Julep as tools with different focuses within the AI development stack.
-LangChain is great for creating sequences of prompts and managing interactions with LLMs. It has a large ecosystem with lots of pre-built integrations, which makes it convenient if you want to get something up and running quickly. LangChain fits well with simple use cases that involve a linear chain of prompts and API calls.
+LangChain is great for creating sequences of prompts and managing interactions with AI models. It has a large ecosystem with lots of pre-built integrations, which makes it convenient if you want to get something up and running quickly. LangChain fits well with simple use cases that involve a linear chain of prompts and API calls.
-Julep, on the other hand, is more about building persistent AI agents that can maintain context over long-term interactions. It shines when you need complex workflows that involve multi-step tasks, conditional logic, and integration with various tools or APIs directly within the agent's process. It's designed from the ground up to manage persistent sessions and complex workflows.
+Julep, on the other hand, is more about building persistent AI agents that can remember things over long-term interactions. It shines when you need complex tasks that involve multiple steps, decision-making, and integration with various tools or APIs directly within the agent's process. It's designed from the ground up to manage persistent sessions and complex tasks.
Use Julep if you imagine building a complex AI assistant that needs to:
- Keep track of user interactions over days or weeks.
- Perform scheduled tasks, like sending daily summaries or monitoring data sources.
- Make decisions based on prior interactions or stored data.
-- Interact with multiple external services as part of its workflow.
+- Interact with multiple external services as part of its task.
Then Julep provides the infrastructure to support all that without you having to build it from scratch.
### Different Form Factor
-Julep is a **platform** that includes a language for describing workflows, a server for running those workflows, and an SDK for interacting with the platform. In order to build something with Julep, you write a description of the workflow in `YAML`, and then run the workflow in the cloud.
+Julep is a **platform** that includes a language for describing tasks, a server for running those tasks, and an SDK for interacting with the platform. To build something with Julep, you write a description of the task in `YAML`, and then run the task in the cloud.
-Julep is built for heavy-lifting, multi-step, and long-running workflows and there's no limit to how complex the workflow can be.
+Julep is built for heavy-lifting, multi-step, and long-running tasks and there's no limit to how complex the task can be.
-LangChain is a **library** that includes a few tools and a framework for building linear chains of prompts and tools. In order to build something with LangChain, you typically write Python code that configures and runs the model chains you want to use.
+LangChain is a **library** that includes a few tools and a framework for building linear chains of prompts and tools. To build something with LangChain, you typically write Python code that configures and runs the model chains you want to use.
LangChain might be sufficient and quicker to implement for simple use cases that involve a linear chain of prompts and API calls.
### In Summary
-Use LangChain when you need to manage LLM interactions and prompt sequences in a stateless or short-term context.
+Use LangChain when you need to manage AI model interactions and prompt sequences in a stateless or short-term context.
-Choose Julep when you need a robust framework for stateful agents with advanced workflow capabilities, persistent sessions, and complex task orchestration.
+Choose Julep when you need a robust framework for stateful agents with advanced task capabilities, persistent sessions, and complex task management.
## Installation
@@ -598,7 +581,7 @@ Julep is made up of the following components:
### Mental Model
-
+
Think of Julep as a platform that combines both client-side and server-side components to help you build advanced AI agents. Here's how to visualize it:
@@ -662,55 +645,137 @@ Tasks are the core of Julep's workflow system. They allow you to define complex,
### Types of Workflow Steps
-Tasks in Julep can include various types of steps:
+Tasks in Julep can include various types of steps, allowing you to create complex and powerful workflows. Here's an overview of the available step types, organized by category:
+
+#### Common Steps
1. **Prompt**: Send a message to the AI model and receive a response.
- ```python
- {"prompt": "Analyze the following data: {{data}}"}
+ ```yaml
+ - prompt: "Analyze the following data: {{data}}"
```
2. **Tool Call**: Execute an integrated tool or API.
- ```python
- {"tool": "web_search", "arguments": {"query": "Latest AI developments"}}
+ ```yaml
+ - tool: web_search
+ arguments:
+ query: "Latest AI developments"
```
3. **Evaluate**: Perform calculations or manipulate data.
- ```python
- {"evaluate": {"average_score": "sum(scores) / len(scores)"}}
+ ```yaml
+ - evaluate:
+ average_score: "sum(scores) / len(scores)"
```
-4. **Conditional Logic**: Execute steps based on conditions.
- ```python
- {"if": "score > 0.8", "then": [...], "else": [...]}
+4. **Wait for Input**: Pause workflow until input is received.
+ ```yaml
+ - wait_for_input:
+ info:
+ message: "Please provide additional information."
```
-5. **Loops**: Iterate over data or repeat steps.
- ```python
- {"foreach": {"in": "data_list", "do": [...]}}
+5. **Log**: Log a specified value or message.
+ ```yaml
+ - log: "Processing completed for item {{item_id}}"
+ ```
+
+#### Key-Value Steps
+
+6. **Get**: Retrieve a value from a key-value store.
+ ```yaml
+ - get: "user_preference"
```
-| Step Name | Description | Input |
-|--------------------|--------------------------------------------------------------------------------------------------|------------------------------------------------------|
-| **Prompt** | Send a message to the AI model and receive a response. | Prompt text or template |
-| **Tool Call** | Execute an integrated tool or API. | Tool name and arguments |
-| **Evaluate** | Perform calculations or manipulate data. | Expressions or variables to evaluate |
-| **Wait for Input** | Pause workflow until input is received. | Any required user or system input |
-| **Log** | Log a specified value or message. | Message or value to log |
-| **Embed** | Embed text into a specific format or system. | Text or content to embed |
-| **Search** | Perform a document search based on a query. | Search query |
-| **Get** | Retrieve a value from a key-value store. | Key identifier |
-| **Set** | Assign a value to a key in a key-value store. | Key and value to assign |
-| **Parallel** | Run multiple steps in parallel. | List of steps to execute simultaneously |
-| **Foreach** | Iterate over a collection and perform steps for each item. | Collection or list to iterate over |
-| **MapReduce** | Map over a collection and reduce the results based on an expression. | Collection to map and reduce expressions |
-| **If Else** | Conditional execution of steps based on a condition. | Condition to evaluate |
-| **Switch** | Execute steps based on multiple conditions, similar to a switch-case statement. | Multiple conditions and corresponding steps |
-| **Yield** | Run a subworkflow and await its completion. | Subworkflow identifier and input data |
-| **Error** | Handle errors by specifying an error message. | Error message or handling instructions |
-| **Sleep** | Pause the workflow for a specified duration. | Duration (seconds, minutes, etc.) |
-| **Return** | Return a value from the workflow. | Value to return |
-
-For detailed information on each step type and advanced usage, please refer to our [Task Documentation](https://docs.julep.ai/tasks).
+7. **Set**: Assign a value to a key in a key-value store.
+ ```yaml
+ - set:
+ user_preference: "dark_mode"
+ ```
+
+#### Iteration Steps
+
+8. **Foreach**: Iterate over a collection and perform steps for each item.
+ ```yaml
+ - foreach:
+ in: "data_list"
+ do:
+ - log: "Processing item {{_}}"
+ ```
+
+9. **Map-Reduce**: Map over a collection and reduce the results.
+ ```yaml
+ - map_reduce:
+ over: "numbers"
+ map:
+ - evaluate:
+ squared: "_ ** 2"
+ reduce: "sum(results)"
+ ```
+
+10. **Parallel**: Run multiple steps in parallel.
+ ```yaml
+ - parallel:
+ - tool: web_search
+ arguments:
+ query: "AI news"
+ - tool: weather_check
+ arguments:
+ location: "New York"
+ ```
+
+#### Conditional Steps
+
+11. **If-Else**: Conditional execution of steps.
+ ```yaml
+ - if: "score > 0.8"
+ then:
+ - log: "High score achieved"
+ else:
+ - log: "Score needs improvement"
+ ```
+
+12. **Switch**: Execute steps based on multiple conditions.
+ ```yaml
+ - switch:
+ - case: "category == 'A'"
+ then:
+ - log: "Category A processing"
+ - case: "category == 'B'"
+ then:
+ - log: "Category B processing"
+ - case: "_" # Default case
+ then:
+ - log: "Unknown category"
+ ```
+
+#### Other Control Flow
+
+13. **Sleep**: Pause the workflow for a specified duration.
+ ```yaml
+ - sleep:
+ seconds: 30
+ ```
+
+14. **Return**: Return a value from the workflow.
+ ```yaml
+ - return:
+ result: "Task completed successfully"
+ ```
+
+15. **Yield**: Run a subworkflow and await its completion.
+ ```yaml
+ - yield:
+ workflow: "data_processing_subflow"
+ arguments:
+ input_data: "{{raw_data}}"
+ ```
+
+16. **Error**: Handle errors by specifying an error message.
+ ```yaml
+ - error: "Invalid input provided"
+ ```
+
+Each step type serves a specific purpose in building sophisticated AI workflows. This categorization helps in understanding the various control flows and operations available in Julep tasks.
## Advanced Features
@@ -726,9 +791,9 @@ client.agents.tools.create(
name="web_search",
description="Search the web for information.",
integration={
- "provider": "google",
+ "provider": "brave",
"method": "search",
- "setup": {"api_key": "your_google_api_key"},
+ "setup": {"api_key": "your_brave_api_key"},
},
)
```
@@ -740,14 +805,19 @@ Julep provides robust session management for persistent interactions:
```python
session = client.sessions.create(
agent_id=agent.id,
- user_id="user123",
+ user_id=user.id,
context_overflow="adaptive"
)
# Continue conversation in the same session
response = client.sessions.chat(
session_id=session.id,
- message="Follow up on our previous conversation."
+ messages=[
+ {
+ "role": "user",
+ "content": "Follow up on the previous conversation."
+ }
+ ]
)
```
@@ -757,21 +827,113 @@ Easily manage and search through documents for your agents:
```python
# Upload a document
-document = client.documents.create(
+document = client.agents.docs.create(
title="AI advancements",
content="AI is changing the world...",
metadata={"category": "research_paper"}
)
# Search documents
-results = client.documents.search(
- query="AI advancements",
+results = client.agents.docs.search(
+ text="AI advancements",
metadata_filter={"category": "research_paper"}
)
```
For more advanced features and detailed usage, please refer to our [Advanced Features Documentation](https://docs.julep.ai/advanced-features).
+## Integrations
+
+Julep supports various integrations that extend the capabilities of your AI agents. Here's a list of available integrations and their supported arguments:
+
+### Brave Search
+
+```yaml
+setup:
+ api_key: string # The API key for Brave Search
+
+arguments:
+ query: string # The search query for searching with Brave
+
+output:
+ result: string # The result of the Brave Search
+```
+
+### BrowserBase
+
+```yaml
+setup:
+ api_key: string # The API key for BrowserBase
+ project_id: string # The project ID for BrowserBase
+ session_id: string # (Optional) The session ID for BrowserBase
+
+arguments:
+ urls: list[string] # The URLs for loading with BrowserBase
+
+output:
+ documents: list # The documents loaded from the URLs
+```
+
+### Email
+
+```yaml
+setup:
+ host: string # The host of the email server
+ port: integer # The port of the email server
+ user: string # The username of the email server
+ password: string # The password of the email server
+
+arguments:
+ to: string # The email address to send the email to
+ from: string # The email address to send the email from
+ subject: string # The subject of the email
+ body: string # The body of the email
+
+output:
+ success: boolean # Whether the email was sent successfully
+```
+
+### Spider
+
+```yaml
+setup:
+ spider_api_key: string # The API key for Spider
+
+arguments:
+ url: string # The URL for which to fetch data
+ mode: string # The type of crawlers (default: "scrape")
+ params: dict # (Optional) The parameters for the Spider API
+
+output:
+ documents: list # The documents returned from the spider
+```
+
+### Weather
+
+```yaml
+setup:
+ openweathermap_api_key: string # The API key for OpenWeatherMap
+
+arguments:
+ location: string # The location for which to fetch weather data
+
+output:
+ result: string # The weather data for the specified location
+```
+
+### Wikipedia
+
+```yaml
+arguments:
+ query: string # The search query string
+ load_max_docs: integer # Maximum number of documents to load (default: 2)
+
+output:
+ documents: list # The documents returned from the Wikipedia search
+```
+
+These integrations can be used within your tasks to extend the capabilities of your AI agents. For more detailed information on how to use these integrations in your workflows, please refer to our [Integrations Documentation](https://docs.julep.ai/integrations).
+
## SDK Reference
- [Node.js SDK](https://github.com/julep-ai/node-sdk/blob/main/api.md)
@@ -783,4 +945,4 @@ Explore our comprehensive API documentation to learn more about agents, tasks, a
- [Agents API](https://api.julep.ai/api/docs#tag/agents)
- [Tasks API](https://api.julep.ai/api/docs#tag/tasks)
-- [Executions API](https://api.julep.ai/api/docs#tag/executions)
+- [Executions API](https://api.julep.ai/api/docs#tag/executions)
\ No newline at end of file
diff --git a/SCRATCHPAD.md b/SCRATCHPAD.md
new file mode 100644
index 000000000..f793fb367
--- /dev/null
+++ b/SCRATCHPAD.md
@@ -0,0 +1,137 @@
+Sure! So imagine you want to build an AI agent that can do more than just answer simple queries—it needs to handle complex tasks, remember past interactions, and maybe even integrate with other tools or APIs. That's where Julep comes in. It's an open-source platform that lets you create persistent AI agents with customizable workflows, making it super easy to develop and deploy advanced AI applications without reinventing the wheel.
+
+
+
+Julep is really useful when you want to build AI agents that can maintain context and state over long-term interactions. It's great for designing complex, multi-step workflows and integrating various tools and APIs directly into your agent's processes.
+
+Compared to LangChain, which is excellent for chaining together prompts and managing LLM interactions, Julep focuses more on creating persistent agents with customizable workflows. While LangChain provides a robust framework for building applications with language models, it doesn't inherently offer the same level of session management or state persistence that Julep does.
+
+
+
+
+
+Persistent sessions in Julep mean that the AI agents can maintain context and state over long periods and multiple interactions. So instead of just handling a single query and forgetting everything afterward (which is what you'd get with regular sessions), the agent can remember past conversations, user preferences, and any relevant data from previous interactions. This is super handy when you want your agent to provide a more personalized experience or when the tasks require building upon previous steps.
+
+For example, if you're building a customer support agent, it can recall a user's issue from earlier chats without them having to repeat themselves. Regular sessions typically don't offer this level of continuity.
+
+As for complex workflows, Julep lets you define multi-step tasks that can include conditional logic, loops, parallel processing, and integration with external tools or APIs. Regular workflows might be more linear and straightforward—think a simple sequence of prompts or API calls without much branching or decision-making capability.
+
+In Julep, you can create tasks where the agent might, say, take user input, perform a web search, process the results, maybe even interact with other services like sending an email or updating a database—all within a single workflow. This level of complexity allows you to build more sophisticated applications without having to manage the orchestration logic yourself.
+
+That said, one thing to keep in mind is that while Julep offers these advanced features, it's still relatively new compared to something like LangChain. So you might find that the community support and pre-built integrations aren't as extensive yet. If you need something up and running quickly with lots of existing modules, LangChain might be more convenient. But if you want more control over persistent state and complex task execution, Julep provides a solid framework for that.
+
+
+
+
+
+
+LangChain is great for creating sequences of prompts and managing interactions with LLMs. It has a large ecosystem with lots of pre-built integrations, which makes it convenient if you want to get something up and running quickly.
+
+Julep, on the other hand, is more about building persistent AI agents that can maintain context over long-term interactions. It shines when you need complex workflows that involve multi-step tasks, conditional logic, and integration with various tools or APIs directly within the agent's process.
+
+So, you shouldn't think of Julep as a direct replacement for LangChain. Instead, consider it as an alternative that's better suited for projects where maintaining state over time and handling complex task executions are important. If your application requires agents that can remember past interactions, personalize responses, and perform intricate operations, Julep might be the way to go.
+
+
+
+
+Think of LangChain and Julep as tools with different focuses within the AI development stack.
+
+LangChain is like a powerful library that helps you chain together prompts and manage interactions with language models. It's excellent for building applications where the primary interaction is between the user and the LLM in a sequential manner. You get utilities for prompt management, memory, and even some basic tools integration. But when it comes to handling more complex state management or long-term sessions, you might find yourself writing a lot of custom code.
+
+Julep, on the other hand, is more of an orchestration platform for AI agents. It's designed from the ground up to manage persistent sessions and complex workflows. Here's how you might think about it:
+
+Persistent State and Sessions: Julep allows your AI agents to maintain state over time without you having to implement the storage and retrieval mechanisms yourself. So if your application requires the agent to remember previous interactions, user preferences, or intermediate data across sessions, Julep handles that natively.
+
+Complex Workflow Management: With Julep, you can define multi-step tasks that include conditional logic, loops, parallel processing, and more. It's like having a built-in workflow engine tailored for AI agents. This is particularly useful when your agent needs to perform a series of actions that depend on each other or on external inputs.
+
+Tool and API Integration: While LangChain allows for some tools integration, Julep provides a more seamless way to incorporate external tools and APIs directly into your agent's workflows. You can define tools once and reuse them across different tasks and agents.
+
+Agent-Centric Design: Julep is centered around the concept of agents that have their own identities, abilities, and long-term goals. This abstraction is helpful when you're building applications where the agent needs to interact with users or systems in a more autonomous or stateful way.
+
+So, rather than a drop-in replacement, Julep can be thought of as a higher-level framework that sits on top of or alongside tools like LangChain. If you imagine building a complex AI assistant that needs to:
+
+Keep track of user interactions over days or weeks.
+Perform scheduled tasks, like sending daily summaries or monitoring data sources.
+Make decisions based on prior interactions or stored data.
+Interact with multiple external services as part of its workflow.
+Then Julep provides the infrastructure to support all that without you having to build it from scratch.
+
+In contrast, if you're building a simpler application where you just need to chain a few prompts together and don't require persistent state or complex task management, LangChain might be sufficient and quicker to implement.
+
+In summary:
+
+Use LangChain when you need to manage LLM interactions and prompt sequences in a stateless or short-term context.
+Choose Julep when you need a robust framework for stateful agents with advanced workflow capabilities, persistent sessions, and complex task orchestration.
+
+
+
+
+Sure! To help you "bookmark" Julep in your mind, here are some key phrases and keywords that set it apart and highlight where it uniquely shines:
+
+Persistent AI Agents: Julep specializes in creating AI agents that maintain context and state over long-term interactions.
+
+Stateful Sessions: Think of Julep when you need sessions that remember past interactions, enabling personalized and context-aware responses.
+
+Customizable Workflows: It's ideal for building complex, multi-step workflows with features like conditional logic, loops, and parallel processing.
+
+Advanced Task Orchestration: Julep excels at orchestrating intricate tasks without requiring you to build the orchestration logic from scratch.
+
+Seamless Tool and API Integration: Use Julep when you want to integrate external tools and APIs directly into your agent's workflows.
+
+Agent-Centric Design: It's designed around autonomous agents with their own identities and long-term goals, perfect for applications needing more than simple prompt-response interactions.
+
+Reason to Recall Julep:
+
+When you're working on a project that requires an AI agent to:
+
+Maintain Long-Term Context: Remember user preferences or past interactions over extended periods.
+
+Handle Complex Operations: Perform multi-step tasks that involve decision-making, branching logic, or interacting with multiple services.
+
+Integrate with External Systems: Seamlessly connect with APIs, databases, or other tools as part of the agent's workflow.
+
+Provide Personalized Experiences: Offer responses or actions tailored to individual users based on accumulated context.
+
+In these scenarios, Julep uniquely shines by providing the infrastructure and tools needed to build such sophisticated, stateful AI applications without having to build the underlying systems yourself.
+
+
+
+
+
+
+Possible Descriptions:
+
+"Julep is an open-source platform for building persistent AI agents that maintain long-term context and execute complex, customizable workflows."
+
+"Create AI agents that remember past interactions and handle intricate tasks with Julep's customizable workflows and seamless tool integration."
+
+"Julep enables developers to build stateful AI agents with advanced task orchestration, maintaining context over time and integrating external tools directly into workflows."
+
+"With Julep, develop AI agents that persist over sessions, perform multi-step tasks, and integrate various tools and APIs effortlessly."
+
+"Julep is a platform for creating AI agents that maintain state and execute complex workflows, offering long-term context and advanced orchestration capabilities."
+
+
+
+
+Key Concepts to Include:
+
+Persistent AI Agents: Agents that maintain context and state over long-term interactions.
+Customizable Workflows: Ability to define complex, multi-step tasks with conditional logic, loops, and more.
+Seamless Tool and API Integration: Direct integration of external tools and APIs into agents' workflows.
+Stateful Sessions: Sessions that remember past interactions for personalized and context-aware responses.
+Advanced Task Orchestration: Orchestrate intricate tasks without building the underlying logic from scratch.
+
+
+
+Top 5 Winners
+1.5 "Julep: Open-source platform for AI agents with long-term memory and complex workflows."
+
+2.5 "Julep: Create AI agents that remember and handle intricate tasks effortlessly."
+
+3.5 "Julep: Create AI agents with persistent context and advanced orchestration."
+
+4.5 "Julep: Craft AI agents that persist and perform complex tasks seamlessly."
+
+5.5 "Julep: Build AI agents with persistent state and powerful task execution."
+
diff --git a/agents-api/agents_api/common/exceptions/tasks.py b/agents-api/agents_api/common/exceptions/tasks.py
new file mode 100644
index 000000000..6e1df0734
--- /dev/null
+++ b/agents-api/agents_api/common/exceptions/tasks.py
@@ -0,0 +1,107 @@
+"""
+This module defines non-retryable error types and provides a function to check
+if a given error is non-retryable. These are used in conjunction with custom
+Temporal interceptors to prevent unnecessary retries of certain error types.
+"""
+
+import asyncio
+
+import beartype
+import beartype.roar
+import box
+import box.exceptions
+import fastapi
+import httpx
+import jinja2
+import jsonschema.exceptions
+import pydantic
+import requests
+import temporalio.exceptions
+
+# List of error types that should not be retried
+NON_RETRYABLE_ERROR_TYPES = [
+ # Temporal-specific errors
+ temporalio.exceptions.WorkflowAlreadyStartedError,
+ temporalio.exceptions.TerminatedError,
+ temporalio.exceptions.CancelledError,
+ #
+ # Built-in Python exceptions
+ TypeError,
+ AssertionError,
+ SyntaxError,
+ ValueError,
+ ZeroDivisionError,
+ IndexError,
+ AttributeError,
+ LookupError,
+ BufferError,
+ ArithmeticError,
+ KeyError,
+ NameError,
+ NotImplementedError,
+ RecursionError,
+ RuntimeError,
+ StopIteration,
+ StopAsyncIteration,
+ IndentationError,
+ TabError,
+ #
+ # Unicode-related errors
+ UnicodeError,
+ UnicodeEncodeError,
+ UnicodeDecodeError,
+ UnicodeTranslateError,
+ #
+ # HTTP and API-related errors
+ fastapi.exceptions.HTTPException,
+ fastapi.exceptions.RequestValidationError,
+ httpx.RequestError,
+ httpx.HTTPStatusError,
+ #
+ # Asynchronous programming errors
+ asyncio.CancelledError,
+ asyncio.InvalidStateError,
+ GeneratorExit,
+ #
+ # Third-party library exceptions
+ jinja2.exceptions.TemplateSyntaxError,
+ jinja2.exceptions.TemplateNotFound,
+ jsonschema.exceptions.ValidationError,
+ pydantic.ValidationError,
+ requests.exceptions.InvalidURL,
+ requests.exceptions.MissingSchema,
+ # Box exceptions
+ box.exceptions.BoxKeyError,
+ box.exceptions.BoxTypeError,
+ box.exceptions.BoxValueError,
+ # Beartype exceptions
+ beartype.roar.BeartypeException,
+ beartype.roar.BeartypeDecorException,
+ beartype.roar.BeartypeDecorHintException,
+ beartype.roar.BeartypeDecorHintNonpepException,
+ beartype.roar.BeartypeDecorHintPepException,
+ beartype.roar.BeartypeDecorHintPepUnsupportedException,
+ beartype.roar.BeartypeDecorHintTypeException,
+ beartype.roar.BeartypeDecorParamException,
+ beartype.roar.BeartypeDecorParamNameException,
+ beartype.roar.BeartypeCallHintParamViolation,
+ beartype.roar.BeartypeCallHintReturnViolation,
+ beartype.roar.BeartypeDecorHintParamDefaultViolation,
+ beartype.roar.BeartypeDoorHintViolation,
+]
+
+
+def is_non_retryable_error(error: Exception) -> bool:
+ """
+ Determines if the given error is non-retryable.
+
+ This function checks if the error is an instance of any of the error types
+ defined in NON_RETRYABLE_ERROR_TYPES.
+
+ Args:
+ error (Exception): The error to check.
+
+ Returns:
+ bool: True if the error is non-retryable, False otherwise.
+ """
+ return isinstance(error, tuple(NON_RETRYABLE_ERROR_TYPES))
diff --git a/agents-api/agents_api/common/interceptors.py b/agents-api/agents_api/common/interceptors.py
new file mode 100644
index 000000000..2fb077c45
--- /dev/null
+++ b/agents-api/agents_api/common/interceptors.py
@@ -0,0 +1,92 @@
+"""
+This module defines custom interceptors for Temporal activities and workflows.
+The main purpose of these interceptors is to handle errors and prevent retrying
+certain types of errors that are known to be non-retryable.
+"""
+
+from typing import Optional, Type
+
+from temporalio.exceptions import ApplicationError
+from temporalio.worker import (
+ ActivityInboundInterceptor,
+ ExecuteActivityInput,
+ ExecuteWorkflowInput,
+ Interceptor,
+ WorkflowInboundInterceptor,
+ WorkflowInterceptorClassInput,
+)
+
+from .exceptions.tasks import is_non_retryable_error
+
+
+class CustomActivityInterceptor(ActivityInboundInterceptor):
+ """
+ Custom interceptor for Temporal activities.
+
+ This interceptor catches exceptions during activity execution and
+ raises them as non-retryable ApplicationErrors if they are identified
+ as non-retryable errors.
+ """
+
+ async def execute_activity(self, input: ExecuteActivityInput):
+ try:
+ return await super().execute_activity(input)
+ except Exception as e:
+ if is_non_retryable_error(e):
+ raise ApplicationError(
+ str(e),
+ type=type(e).__name__,
+ non_retryable=True,
+ )
+ raise
+
+
+class CustomWorkflowInterceptor(WorkflowInboundInterceptor):
+ """
+ Custom interceptor for Temporal workflows.
+
+ This interceptor catches exceptions during workflow execution and
+ raises them as non-retryable ApplicationErrors if they are identified
+ as non-retryable errors.
+ """
+
+ async def execute_workflow(self, input: ExecuteWorkflowInput):
+ try:
+ return await super().execute_workflow(input)
+ except Exception as e:
+ if is_non_retryable_error(e):
+ raise ApplicationError(
+ str(e),
+ type=type(e).__name__,
+ non_retryable=True,
+ )
+ raise
+
+
+class CustomInterceptor(Interceptor):
+ """
+ Custom Interceptor that combines both activity and workflow interceptors.
+
+ This class is responsible for creating and returning the custom
+ interceptors for both activities and workflows.
+ """
+
+ def intercept_activity(
+ self, next: ActivityInboundInterceptor
+ ) -> ActivityInboundInterceptor:
+ """
+ Creates and returns a CustomActivityInterceptor.
+
+ This method is called by Temporal to intercept activity executions.
+ """
+ return CustomActivityInterceptor(super().intercept_activity(next))
+
+ def workflow_interceptor_class(
+ self, input: WorkflowInterceptorClassInput
+ ) -> Optional[Type[WorkflowInboundInterceptor]]:
+ """
+ Returns the CustomWorkflowInterceptor class.
+
+ This method is called by Temporal to get the workflow interceptor class.
+ """
+ return CustomWorkflowInterceptor
diff --git a/agents-api/agents_api/common/retry_policies.py b/agents-api/agents_api/common/retry_policies.py
index fc343553c..c6c1c362c 100644
--- a/agents-api/agents_api/common/retry_policies.py
+++ b/agents-api/agents_api/common/retry_policies.py
@@ -1,63 +1,14 @@
-from datetime import timedelta
+# from datetime import timedelta
-from temporalio.common import RetryPolicy
+# from temporalio.common import RetryPolicy
-DEFAULT_RETRY_POLICY = RetryPolicy(
- initial_interval=timedelta(seconds=1),
- backoff_coefficient=2,
- maximum_attempts=25,
- maximum_interval=timedelta(seconds=300),
- non_retryable_error_types=[
- # Temporal-specific errors
- "WorkflowExecutionAlreadyStarted",
- "temporalio.exceptions.TerminalFailure",
- "temporalio.exceptions.CanceledError",
- #
- # Built-in Python exceptions
- "TypeError",
- "AssertionError",
- "SyntaxError",
- "ValueError",
- "ZeroDivisionError",
- "IndexError",
- "AttributeError",
- "LookupError",
- "BufferError",
- "ArithmeticError",
- "KeyError",
- "NameError",
- "NotImplementedError",
- "RecursionError",
- "RuntimeError",
- "StopIteration",
- "StopAsyncIteration",
- "IndentationError",
- "TabError",
- #
- # Unicode-related errors
- "UnicodeError",
- "UnicodeEncodeError",
- "UnicodeDecodeError",
- "UnicodeTranslateError",
- #
- # HTTP and API-related errors
- "HTTPException",
- "fastapi.exceptions.HTTPException",
- "fastapi.exceptions.RequestValidationError",
- "httpx.RequestError",
- "httpx.HTTPStatusError",
- #
- # Asynchronous programming errors
- "asyncio.CancelledError",
- "asyncio.InvalidStateError",
- "GeneratorExit",
- #
- # Third-party library exceptions
- "jinja2.exceptions.TemplateSyntaxError",
- "jinja2.exceptions.TemplateNotFound",
- "jsonschema.exceptions.ValidationError",
- "pydantic.ValidationError",
- "requests.exceptions.InvalidURL",
- "requests.exceptions.MissingSchema",
- ],
-)
+# DEFAULT_RETRY_POLICY = RetryPolicy(
+# initial_interval=timedelta(seconds=1),
+# backoff_coefficient=2,
+# maximum_attempts=25,
+# maximum_interval=timedelta(seconds=300),
+# )
+
+# FIXME: Adding both interceptors and retry policy (even with `non_retryable_errors` not set)
+# is causing the errors to be retried. We need to find a workaround for this.
+DEFAULT_RETRY_POLICY = None
diff --git a/agents-api/agents_api/models/user/create_or_update_user.py b/agents-api/agents_api/models/user/create_or_update_user.py
index d295d1d8a..13260a038 100644
--- a/agents-api/agents_api/models/user/create_or_update_user.py
+++ b/agents-api/agents_api/models/user/create_or_update_user.py
@@ -26,9 +26,21 @@
@rewrap_exceptions(
{
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
+ ),
}
)
@wrap_in_class(User, one=True, transform=lambda d: {"id": UUID(d.pop("user_id")), **d})
diff --git a/agents-api/agents_api/models/user/create_user.py b/agents-api/agents_api/models/user/create_user.py
index 9dd036c57..270c0d44c 100644
--- a/agents-api/agents_api/models/user/create_user.py
+++ b/agents-api/agents_api/models/user/create_user.py
@@ -29,11 +29,24 @@
lambda e: isinstance(e, QueryException)
and "asserted to return some results, but returned none"
in str(e): lambda *_: HTTPException(
- detail="developer not found", status_code=403
+ detail="Developer not found. Please ensure the provided auth token (which refers to your developer_id) is valid and the developer has the necessary permissions to create an agent.",
+ status_code=403,
+ ),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
),
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
}
)
@wrap_in_class(
diff --git a/agents-api/agents_api/models/user/delete_user.py b/agents-api/agents_api/models/user/delete_user.py
index 0532f5cfa..7f08316be 100644
--- a/agents-api/agents_api/models/user/delete_user.py
+++ b/agents-api/agents_api/models/user/delete_user.py
@@ -27,9 +27,32 @@
@rewrap_exceptions(
{
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
+ lambda e: isinstance(e, QueryException)
+ and "Developer does not exist" in str(e): lambda *_: HTTPException(
+ detail="The specified developer does not exist.",
+ status_code=403,
+ ),
+ lambda e: isinstance(e, QueryException)
+ and "Developer does not own resource"
+ in e.resp["display"]: lambda *_: HTTPException(
+ detail="The specified developer does not own the requested resource. Please verify the ownership or check if the developer ID is correct.",
+ status_code=404,
+ ),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
+ ),
}
)
@wrap_in_class(
diff --git a/agents-api/agents_api/models/user/get_user.py b/agents-api/agents_api/models/user/get_user.py
index 2b4f59c83..34ff2c6f4 100644
--- a/agents-api/agents_api/models/user/get_user.py
+++ b/agents-api/agents_api/models/user/get_user.py
@@ -23,17 +23,31 @@
@rewrap_exceptions(
{
lambda e: isinstance(e, QueryException)
- and "Developer not found" in str(e): lambda *_: HTTPException(
- detail="developer does not exist", status_code=403
+ and "Developer does not exist" in str(e): lambda *_: HTTPException(
+ detail="The specified developer does not exist.",
+ status_code=403,
),
lambda e: isinstance(e, QueryException)
and "Developer does not own resource"
in e.resp["display"]: lambda *_: HTTPException(
- detail="developer doesnt own resource", status_code=404
+ detail="The specified developer does not own the requested resource. Please verify the ownership or check if the developer ID is correct.",
+ status_code=404,
+ ),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
),
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
}
)
@wrap_in_class(User, one=True)
diff --git a/agents-api/agents_api/models/user/list_users.py b/agents-api/agents_api/models/user/list_users.py
index 2a810b8e0..7f59cbf57 100644
--- a/agents-api/agents_api/models/user/list_users.py
+++ b/agents-api/agents_api/models/user/list_users.py
@@ -22,9 +22,21 @@
@rewrap_exceptions(
{
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
+ ),
}
)
@wrap_in_class(User)
diff --git a/agents-api/agents_api/models/user/patch_user.py b/agents-api/agents_api/models/user/patch_user.py
index 265241d47..152f66de7 100644
--- a/agents-api/agents_api/models/user/patch_user.py
+++ b/agents-api/agents_api/models/user/patch_user.py
@@ -26,9 +26,21 @@
@rewrap_exceptions(
{
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
+ ),
}
)
@wrap_in_class(
diff --git a/agents-api/agents_api/models/user/update_user.py b/agents-api/agents_api/models/user/update_user.py
index fd8e7e2c8..964e550b4 100644
--- a/agents-api/agents_api/models/user/update_user.py
+++ b/agents-api/agents_api/models/user/update_user.py
@@ -23,9 +23,21 @@
@rewrap_exceptions(
{
- QueryException: partialclass(HTTPException, status_code=400),
- ValidationError: partialclass(HTTPException, status_code=400),
- TypeError: partialclass(HTTPException, status_code=400),
+ QueryException: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A database query failed to return the expected results. This might occur if the requested resource doesn't exist or your query parameters are incorrect.",
+ ),
+ ValidationError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="Input validation failed. Please check the provided data for missing or incorrect fields, and ensure it matches the required format.",
+ ),
+ TypeError: partialclass(
+ HTTPException,
+ status_code=400,
+ detail="A type mismatch occurred. This likely means the data provided is of an incorrect type (e.g., string instead of integer). Please review the input and try again.",
+ ),
}
)
@wrap_in_class(
diff --git a/agents-api/agents_api/worker/worker.py b/agents-api/agents_api/worker/worker.py
index dc02cb4a7..54f2bcdd5 100644
--- a/agents-api/agents_api/worker/worker.py
+++ b/agents-api/agents_api/worker/worker.py
@@ -22,6 +22,7 @@ def create_worker(client: Client) -> Any:
from ..activities.mem_rating import mem_rating
from ..activities.summarization import summarization
from ..activities.truncation import truncation
+ from ..common.interceptors import CustomInterceptor
from ..env import (
temporal_task_queue,
)
@@ -61,6 +62,7 @@ def create_worker(client: Client) -> Any:
summarization,
truncation,
],
+ interceptors=[CustomInterceptor()],
)
return worker
diff --git a/agents-api/notebooks/01-revise-entities.ipynb b/agents-api/notebooks/01-revise-entities.ipynb
index 00667cb82..27b2e1f0d 100644
--- a/agents-api/notebooks/01-revise-entities.ipynb
+++ b/agents-api/notebooks/01-revise-entities.ipynb
@@ -2,16 +2,64 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n",
+ "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n",
+ "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n",
+ "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n",
+ "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n",
+ "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n",
+ "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n",
+ "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n",
+ "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n",
+ "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n",
+ "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n",
+ "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n",
+ "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
+ "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
+ "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install openai"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install python-dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "True"
+ "False"
]
},
- "execution_count": 6,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -35,18 +83,22 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
- "from openai import Client\n",
+ "import openai\n",
+ "from openai import OpenAI\n",
+ "\n",
+ "api_key = \"YOUR_OPENAI_API_KEY\"\n",
"\n",
- "client = Client()"
+ "openai.api_key = api_key\n",
+ "client = OpenAI(api_key=api_key)"
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -69,7 +121,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -89,7 +141,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -106,7 +158,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -290,7 +342,7 @@
},
{
"cell_type": "code",
- "execution_count": 29,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -314,7 +366,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -323,7 +375,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -339,7 +391,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -348,7 +400,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -365,7 +417,7 @@
},
{
"cell_type": "code",
- "execution_count": 17,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -381,7 +433,7 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -460,7 +512,7 @@
},
{
"cell_type": "code",
- "execution_count": 33,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -468,44 +520,37 @@
"output_type": "stream",
"text": [
"Starting CoT generation\n",
- "{'content': 'Planning step by step:\\n'\n",
+ "{'content': 'To add context for future entries, we should outline the main '\n",
+ " 'entities in the session. These entities are the main people, '\n",
+ " 'places, or things that are most relevant to the conversation.\\n'\n",
" '\\n'\n",
- " '1. Identify key entities such as characters, games, and '\n",
- " 'technology mentioned in the conversation.\\n'\n",
- " '2. Provide context for each entity, explaining its relevance to '\n",
- " 'the conversation and any additional useful information.\\n'\n",
- " '3. Ensure the entities and their descriptions encapsulate the '\n",
- " 'essence of the conversation for future reference or follow-up '\n",
- " 'discussions.\\n'\n",
- " '\\n'\n",
- " 'Entities will be identified and described based on the '\n",
- " \"conversation's content and flow. This will include the games \"\n",
- " 'discussed, characters within those games, and any technology '\n",
- " 'issues mentioned.',\n",
+ " 'Entities:\\n'\n",
+ " '1. User (The participant initiating the conversation, interested '\n",
+ " 'in video games and experiencing technical issues).\\n'\n",
+ " '2. Assistant (Engages in conversation about video games and '\n",
+ " 'offers technical advice).\\n'\n",
+ " '3. Red Dead Redemption 2 (Video game discussed, specifically the '\n",
+ " '\"Blood Feuds, Ancient and Modern\" mission and the character '\n",
+ " 'development of Arthur and Dutch).\\n'\n",
+ " '4. Helldivers 2 (Another video game discussed, focusing on '\n",
+ " 'gameplay, strategy, and specific in-game items like the laser '\n",
+ " 'cannon and guard dog).\\n'\n",
+ " '5. Nvidia (Referenced in relation to driver issues, particularly '\n",
+ " 'in the context of compatibility with Linux operating systems).',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
"Starting chatml generation\n",
"End chatml generation\n",
- "{'content': '- **User**: Engages in discussions about video games and faces '\n",
+ "{'content': '- User: Engages in discussions about video games and experiences '\n",
" 'technical issues with Nvidia drivers on Linux.\\n'\n",
- " '- **Assistant**: Provides conversation on video games, offers '\n",
- " 'suggestions on game strategies, and gives technical advice '\n",
- " 'regarding Nvidia drivers.\\n'\n",
- " '- **Red Dead Redemption 2 (RDR2)**: A video game discussed '\n",
- " 'extensively, particularly its missions and character '\n",
- " 'development.\\n'\n",
- " '- **Arthur Morgan**: A central character in RDR2, noted for his '\n",
- " 'moral complexity and development throughout the game.\\n'\n",
- " '- **Dutch van der Linde**: Another key character from RDR2, whose '\n",
- " \"increasingly erratic decisions impact the game's storyline.\\n\"\n",
- " '- **Helldivers 2**: A cooperative multiplayer game mentioned by '\n",
- " 'the user, known for its intense gameplay and strategic team '\n",
- " 'dynamics.\\n'\n",
- " '- **Nvidia**: Technology company referenced in relation to driver '\n",
- " 'compatibility issues with Linux operating systems.\\n'\n",
- " '- **Linux**: Operating system mentioned as having compatibility '\n",
- " \"issues with Nvidia drivers, affecting the user's gaming \"\n",
- " 'experience.',\n",
+ " '- Assistant: Provides insights and engages in discussions about '\n",
+ " 'video games, offers technical advice.\\n'\n",
+ " '- Red Dead Redemption 2: A video game discussed for its missions '\n",
+ " 'and character development.\\n'\n",
+ " '- Helldivers 2: Another video game mentioned, focusing on '\n",
+ " 'gameplay and strategies.\\n'\n",
+ " '- Nvidia: Mentioned in relation to driver compatibility issues '\n",
+ " 'with Linux.',\n",
" 'role': 'assistant'}\n"
]
}
@@ -513,11 +558,18 @@
"source": [
"pprint(get_entities(chat_session))"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
"kernelspec": {
- "display_name": "julep",
+ "display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -531,7 +583,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.14"
+ "version": "3.12.1"
}
},
"nbformat": 4,
diff --git a/agents-api/notebooks/02-trim-messages.ipynb b/agents-api/notebooks/02-trim-messages.ipynb
index 2a5c58da2..bf03a76a0 100644
--- a/agents-api/notebooks/02-trim-messages.ipynb
+++ b/agents-api/notebooks/02-trim-messages.ipynb
@@ -4,14 +4,62 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n",
+ "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n",
+ "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n",
+ "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n",
+ "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n",
+ "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n",
+ "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n",
+ "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n",
+ "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n",
+ "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n",
+ "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n",
+ "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n",
+ "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
+ "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
+ "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install openai"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install python-dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "True"
+ "False"
]
},
- "execution_count": 1,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -35,18 +83,22 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
- "from openai import Client\n",
+ "import openai\n",
+ "from openai import OpenAI\n",
"\n",
- "client = Client()"
+ "api_key = \"YOUR_OPENAI_API_KEY\"\n",
+ "\n",
+ "openai.api_key = api_key\n",
+ "client = OpenAI(api_key=api_key)"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -69,7 +121,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -89,7 +141,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -106,7 +158,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -290,7 +342,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -351,7 +403,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -360,7 +412,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -376,7 +428,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -385,7 +437,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -402,7 +454,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -418,7 +470,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -493,7 +545,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -501,11 +553,11 @@
"output_type": "stream",
"text": [
"Starting CoT generation\n",
- "{'content': 'The messages are clear and concise, reflecting a casual '\n",
- " 'conversation about gaming experiences and software issues. '\n",
- " \"There's no need for trimming as each message contributes to the \"\n",
- " 'flow of the conversation, maintaining user engagement and '\n",
- " 'providing relevant information and responses.',\n",
+ "{'content': 'The conversation is generally concise and relevant to the casual, '\n",
+ " 'gaming-centered topic. Each message contributes to the dialogue '\n",
+ " 'by either providing information or prompting further discussion, '\n",
+ " 'and no excessive verbosity or extraneous details are present. '\n",
+ " 'Therefore, no trimming is required for this session.',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
"Starting chatml generation\n",
@@ -701,11 +753,18 @@
"source": [
"pprint(trim_messages(chat_session))"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
"kernelspec": {
- "display_name": "julep",
+ "display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -719,7 +778,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.14"
+ "version": "3.12.1"
}
},
"nbformat": 4,
diff --git a/agents-api/notebooks/03-summarise.ipynb b/agents-api/notebooks/03-summarise.ipynb
index 98e6f5e0a..7be4baf02 100644
--- a/agents-api/notebooks/03-summarise.ipynb
+++ b/agents-api/notebooks/03-summarise.ipynb
@@ -4,14 +4,62 @@
"cell_type": "code",
"execution_count": 1,
"metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n",
+ "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n",
+ "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n",
+ "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n",
+ "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n",
+ "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n",
+ "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n",
+ "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n",
+ "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n",
+ "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n",
+ "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n",
+ "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n",
+ "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
+ "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
+ "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install openai"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install python-dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "True"
+ "False"
]
},
- "execution_count": 1,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -42,18 +90,22 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
- "from openai import Client\n",
+ "import openai\n",
+ "from openai import OpenAI\n",
+ "\n",
+ "api_key = \"YOUR_OPENAI_API_KEY\"\n",
"\n",
- "client = Client()"
+ "openai.api_key = api_key\n",
+ "client = OpenAI(api_key=api_key)"
]
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -80,7 +132,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -100,7 +152,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -124,7 +176,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -315,7 +367,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -355,7 +407,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -429,7 +481,7 @@
},
{
"cell_type": "code",
- "execution_count": 47,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -474,7 +526,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -490,7 +542,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -506,7 +558,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -515,7 +567,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -532,7 +584,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@@ -555,7 +607,7 @@
},
{
"cell_type": "code",
- "execution_count": 48,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@@ -636,7 +688,7 @@
},
{
"cell_type": "code",
- "execution_count": 49,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -644,41 +696,37 @@
"output_type": "stream",
"text": [
"Starting CoT generation\n",
- "{'content': 'To provide a comprehensive overview of the entities in the '\n",
- " 'session, we need to focus on the main people, places, things, and '\n",
- " 'concepts that have been discussed:\\n'\n",
+ "{'content': 'To summarize the important entities from this conversation:\\n'\n",
" '\\n'\n",
- " '1. **User**: Engages in conversation about video games, '\n",
- " 'specifically mentioning experiences with \"Red Dead Redemption 2\" '\n",
- " 'and \"Helldivers 2.\" Also, shares technical issues related to '\n",
- " 'Nvidia graphics drivers on Linux.\\n'\n",
+ " '1. **User**: Engages in a casual and friendly chat with the '\n",
+ " 'Assistant, discussing video games and a technical issue.\\n'\n",
+ " '2. **Assistant**: Responds to the User, engaging in discussions '\n",
+ " 'about specific video games and offering technical advice '\n",
+ " 'regarding an Nvidia driver issue.\\n'\n",
+ " '3. **Video Games Discussed**:\\n'\n",
+ " ' - **Red Dead Redemption 2 (RDR2)**: User recently finished '\n",
+ " 'this game and discusses specific missions such as \"Blood Feuds, '\n",
+ " 'Ancient and Modern\".\\n'\n",
+ " ' - **Helldivers 2**: User is currently playing this game, '\n",
+ " 'mentioning favorite builds and discussing gameplay strategies.\\n'\n",
+ " '4. **Technical Issue**: User mentions having an Nvidia driver '\n",
+ " 'issue, particularly concerning its compatibility with Linux. The '\n",
+ " 'Assistant offers advice on handling this issue.\\n'\n",
+ " '5. **Game Characters**:\\n'\n",
+ " ' - **Arthur**: From RDR2, discussed in terms of his journey and '\n",
+ " 'character development.\\n'\n",
+ " ' - **Dutch**: Also from RDR2, discussed for his progressive '\n",
+ " 'craziness and leadership style.\\n'\n",
+ " '6. **Gaming Strategies**:\\n'\n",
+ " ' - **Run and Gun**: Mentioned by the User as a strategy used in '\n",
+ " 'Helldivers 2.\\n'\n",
+ " '7. **Operating System**:\\n'\n",
+ " ' - **Linux**: Mentioned in relation to the Nvidia driver '\n",
+ " 'compatibility issue.\\n'\n",
" '\\n'\n",
- " '2. **Assistant**: Offers insights and engages in discussions '\n",
- " 'about the video games mentioned by the user, provides gameplay '\n",
- " 'strategies, and offers technical advice regarding Nvidia driver '\n",
- " 'issues on Linux.\\n'\n",
- " '\\n'\n",
- " '3. **Red Dead Redemption 2 (RDR2)**: A video game discussed '\n",
- " 'extensively in the conversation. Key aspects such as the '\n",
- " 'character Arthur, missions like \"Blood Feuds, Ancient and '\n",
- " 'Modern,\" and side quests are highlighted.\\n'\n",
- " '\\n'\n",
- " '4. **Helldivers 2**: Another video game mentioned by the user. '\n",
- " 'The conversation covers gameplay elements like the laser cannon, '\n",
- " 'guard dog, and challenges like the Charger enemy.\\n'\n",
- " '\\n'\n",
- " '5. **Nvidia Drivers**: A technical issue brought up by the user, '\n",
- " 'particularly focusing on compatibility problems with Linux. The '\n",
- " 'assistant provides troubleshooting advice and recommendations for '\n",
- " 'dealing with these issues.\\n'\n",
- " '\\n'\n",
- " '6. **Linux**: Mentioned in the context of having compatibility '\n",
- " \"issues with Nvidia drivers, highlighting the user's struggle with \"\n",
- " 'technical aspects of gaming on this operating system.\\n'\n",
- " '\\n'\n",
- " 'These entities encapsulate the core topics and issues discussed '\n",
- " \"in the session, providing a clear view of the conversation's \"\n",
- " 'focus areas.',\n",
+ " 'These entities encapsulate the main topics and references made '\n",
+ " 'during the conversation, focusing on video gaming experiences, '\n",
+ " 'character analysis, and technical troubleshooting.',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
"Starting chatml generation\n",
@@ -699,7 +747,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@@ -777,7 +825,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 20,
"metadata": {},
"outputs": [
{
@@ -785,19 +833,45 @@
"output_type": "stream",
"text": [
"Starting CoT generation\n",
- "{'content': 'The conversation between the user and the assistant revolves '\n",
- " 'around video games and technical issues. The assistant engages '\n",
- " 'enthusiastically about the user’s gaming experiences, providing '\n",
- " 'tips and engaging on a technical level about Nvidia drivers on '\n",
- " 'Linux towards the end. The user is generally responsive and '\n",
- " 'shares specifics about their gaming preferences and technical '\n",
- " 'difficulties. The tone is casual and friendly throughout, with '\n",
- " 'the assistant providing support and showing interest in the '\n",
- " \"user's activities. \\n\"\n",
- " '\\n'\n",
- " 'No trimming is required as the messages are well-paced and '\n",
- " \"relevant to the users' interests, fostering an engaging and \"\n",
- " 'informative dialogue.',\n",
+ "{'content': '\\n'\n",
+ " \"- User greeted the assistant and asked what's good.\\n\"\n",
+ " '- Assistant replied casually, asking about recent games.\\n'\n",
+ " '- User mentioned finishing Red Dead Redemption 2, praising the '\n",
+ " 'final mission.\\n'\n",
+ " \"- Assistant inquired about the user's thoughts on Arthur's \"\n",
+ " 'journey and favorite moments.\\n'\n",
+ " '- User highlighted the \"Blood Feuds\" mission.\\n'\n",
+ " \"- Assistant discussed the mission's cinematic aspects and asked \"\n",
+ " \"about user's alignment with game characters.\\n\"\n",
+ " '- User preferred Arthur over Dutch.\\n'\n",
+ " '- Assistant discussed character development and suggested '\n",
+ " 'exploring side quests.\\n'\n",
+ " '- User mentioned completing side quests, liked the widow and '\n",
+ " 'bounty missions.\\n'\n",
+ " \"- Assistant praised the game's side missions and asked about \"\n",
+ " \"user's next gaming plans.\\n\"\n",
+ " '- User switched to playing Helldivers 2.\\n'\n",
+ " \"- Assistant described Helldivers 2's gameplay and asked about \"\n",
+ " \"user's experience.\\n\"\n",
+ " '- User shared favorite equipment setup.\\n'\n",
+ " '- Assistant discussed tactical options and asked about '\n",
+ " 'challenging missions.\\n'\n",
+ " '- User mentioned difficulty with a specific enemy.\\n'\n",
+ " \"- Assistant offered strategy tips and inquired about team's \"\n",
+ " 'handling of game challenges.\\n'\n",
+ " '- User described their run-and-gun approach.\\n'\n",
+ " '- Assistant acknowledged the strategy and asked about difficulty '\n",
+ " 'levels.\\n'\n",
+ " '- User mentioned needing to work and a technical issue with '\n",
+ " 'Nvidia drivers.\\n'\n",
+ " '- Assistant offered technical advice for driver issue and wished '\n",
+ " 'good luck with work.\\n'\n",
+ " '- User commented on Nvidia and Linux compatibility issues.\\n'\n",
+ " '- Assistant provided detailed advice for handling Nvidia drivers '\n",
+ " 'on Linux.\\n'\n",
+ " '- User ended the conversation, intending to leave.\\n'\n",
+ " '- Assistant said goodbye.\\n'\n",
+ " '',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
"Starting chatml generation\n",
@@ -811,7 +885,7 @@
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": 21,
"metadata": {},
"outputs": [
{
@@ -1011,7 +1085,7 @@
},
{
"cell_type": "code",
- "execution_count": 50,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
@@ -1098,7 +1172,7 @@
},
{
"cell_type": "code",
- "execution_count": 55,
+ "execution_count": 23,
"metadata": {},
"outputs": [
{
@@ -1106,106 +1180,21 @@
"output_type": "stream",
"text": [
"Starting CoT generation\n",
- "{'content': '- Combine initial greetings and the start of the discussion about '\n",
- " '\"Red Dead Redemption 2 (RDR2)\" into a summary.\\n'\n",
- " '- Summarize the detailed conversation about specific missions and '\n",
- " 'characters in \"RDR2\".\\n'\n",
- " '- Retain individual entries about \"Helldivers 2\" due to the '\n",
- " \"user's direct interaction and game preferences.\\n\"\n",
- " '- Summarize discussions around \"Nvidia Drivers\" and \"Linux\" '\n",
- " 'compatibility, emphasizing the solution offered.\\n'\n",
- " '- Retain the closing conversation as it indicates the end of the '\n",
- " 'session. \\n'\n",
- " '\\n'\n",
- " '\\n'\n",
- " '[\\n'\n",
- " ' {\\n'\n",
- " ' \"role\": \"system\",\\n'\n",
- " ' \"name\": \"summary\",\\n'\n",
- " ' \"content\": \"Event: The user discussed finishing \\'Red Dead '\n",
- " \"Redemption 2' and particularly enjoyed the last mission. They \"\n",
- " 'also talked about favorite missions and characters, specifically '\n",
- " 'Arthur over Dutch.\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 12,\\n'\n",
- " ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"im playing helldivers 2. do u know of it\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 13,\\n'\n",
- " ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"Yes, Helldivers 2! It\\'s a great choice if '\n",
- " \"you're into intense co-op action. The game really ramps up with \"\n",
- " 'its twin-stick shooter gameplay, and it\\\\u2019s super fun but '\n",
- " 'also quite challenging. Working together with teammates to '\n",
- " 'complete those missions can get pretty hectic. How are you '\n",
- " 'finding the chaos and team dynamics so far?\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 14,\\n'\n",
- " ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"amazing. my fav build is laser cannon + guard '\n",
- " 'dog. what about u\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 15,\\n'\n",
- " ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"Nice combo! The laser cannon is awesome for '\n",
- " 'tearing through those enemy swarms, and the guard dog drone '\n",
- " 'really helps in keeping the smaller threats at bay. I personally '\n",
- " 'love using the railgun with a shield backpack. It gives a good '\n",
- " 'balance of offense and defense, especially when things get really '\n",
- " 'chaotic. What\\'s been the toughest mission for you so far?\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 16,\\n'\n",
- " ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"dude the charger is so difficult to kill.\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 17,\\n'\n",
- " ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"Yeah, the Charger can be brutal! They really test '\n",
- " \"your reflexes and teamwork. It's all about timing and \"\n",
- " 'coordination with your team to bring those heavy hitters down. '\n",
- " 'Have you tried using more strategic traps or mines? Sometimes '\n",
- " 'setting up the right position with static fields can really make '\n",
- " 'a difference against them. How do your squadmates handle it?\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 18,\\n'\n",
- " ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"we just run and gun\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 19,\\n'\n",
- " ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"Classic strategy! That can definitely be fun, '\n",
- " 'especially in a game as intense as Helldivers 2 where things get '\n",
- " 'chaotic fast. Keeping on the move helps a ton. Just make sure '\n",
- " \"someone's always got your back! Have you guys tried any of the \"\n",
- " 'higher difficulty levels yet, or are you sticking to a certain '\n",
- " 'comfort zone for now?\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"role\": \"system\",\\n'\n",
- " ' \"name\": \"summary\",\\n'\n",
- " ' \"content\": \"Event: The user discussed an Nvidia driver issue, '\n",
- " 'particularly its incompatibility with Linux, and the assistant '\n",
- " 'provided potential solutions and resources for assistance.\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 24,\\n'\n",
- " ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"yep. see u bye!\"\\n'\n",
- " ' },\\n'\n",
- " ' {\\n'\n",
- " ' \"index\": 25,\\n'\n",
- " ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"See you, take care! Bye!\"\\n'\n",
- " ' }\\n'\n",
- " ']\\n',\n",
+ "{'content': '- Summarize the initial casual greeting between User and '\n",
+ " 'Assistant.\\n'\n",
+ " \"- Keep detailed discussion on RDR2, including User's favorite \"\n",
+ " 'moments and characters, as they directly relate to the entities '\n",
+ " 'outlined.\\n'\n",
+ " '- Summarize the transition from RDR2 discussion to Helldivers 2 '\n",
+ " 'without losing game-specific details.\\n'\n",
+ " '- Preserve details on Helldivers 2 gameplay strategies mentioned '\n",
+ " 'by User.\\n'\n",
+ " \"- Summarize User's mention of work and Nvidia driver issue while \"\n",
+ " 'retaining the essence of their tech problem.\\n'\n",
+ " \"- Retain Assistant's advice on Nvidia and Linux compatibility \"\n",
+ " \"issues, as it's relevant to the User's context.\\n\"\n",
+ " '- Keep the farewell message brief but intact to maintain the '\n",
+ " 'conversational closure.',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
"Starting chatml generation\n",
@@ -1225,7 +1214,7 @@
},
{
"cell_type": "code",
- "execution_count": 56,
+ "execution_count": 24,
"metadata": {},
"outputs": [
{
@@ -1236,88 +1225,180 @@
" ' {\\n'\n",
" ' \"role\": \"system\",\\n'\n",
" ' \"name\": \"summary\",\\n'\n",
- " ' \"content\": \"Event: The user discussed finishing \\'Red Dead '\n",
- " \"Redemption 2' and particularly enjoyed the last mission. They \"\n",
- " 'also talked about favorite missions and characters, specifically '\n",
- " 'Arthur over Dutch.\"\\n'\n",
+ " ' \"content\": \"Event: Casual greeting between User and '\n",
+ " 'Assistant, with User mentioning they recently finished playing '\n",
+ " 'Red Dead Redemption 2.\"\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"i just got done with finishing red dead '\n",
+ " 'redemption 2 recently. the last mission was so fkng coolll\",\\n'\n",
+ " ' \"index\": 4\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"Oh man, RDR2 is epic! That ending is intense, '\n",
+ " \"right? What did you think about Arthur's journey throughout the \"\n",
+ " 'game? Got any favorite moments?\",\\n'\n",
+ " ' \"index\": 5\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"blood feuds mission was amazing\",\\n'\n",
+ " ' \"index\": 6\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"Absolutely, the \\\\\"Blood Feuds, Ancient and '\n",
+ " 'Modern\\\\\" mission is a standout! The whole shootout at '\n",
+ " 'Braithwaite Manor is intense. The atmosphere Rockstar created '\n",
+ " 'during that mission with the burning building in the background '\n",
+ " 'is just cinematic perfection. Did you side more with Arthur or '\n",
+ " 'Dutch throughout the game?\",\\n'\n",
+ " ' \"index\": 7\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 12,\\n'\n",
" ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"im playing helldivers 2. do u know of it\"\\n'\n",
+ " ' \"content\": \"arthur of course. dutch just kept becoming '\n",
+ " 'crazier and crazier.\",\\n'\n",
+ " ' \"index\": 8\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"Totally get that. Arthur\\'s character development '\n",
+ " \"is really something else. He starts questioning Dutch's decisions \"\n",
+ " 'and looking at things more critically, which adds so much depth '\n",
+ " \"to his character. Watching Dutch's descent as the gang falls \"\n",
+ " 'apart is pretty intense. Have you thought about checking out any '\n",
+ " 'of the side quests or exploring more of the open world now that '\n",
+ " 'you\\'ve finished the main story?\",\\n'\n",
+ " ' \"index\": 9\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"oh i\\'ve done all the side quests. the widow '\n",
+ " 'missions are great but i also loved the bounty missions (where u '\n",
+ " 'have to talk to gangsters for an author)\",\\n'\n",
+ " ' \"index\": 10\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"Ah, the bounty missions for the author are a '\n",
+ " 'blast! Hunting down those gunslingers for the book gives you such '\n",
+ " \"a great tour of the game's diverse characters. And Charlotte's \"\n",
+ " \"missions, the widow, they're pretty touching, right? It\\\\u2019s \"\n",
+ " 'nice to see Arthur helping her adapt to wilderness life. Adds a '\n",
+ " 'softer side to the game amidst all the chaos.\\\\n\\\\nNow that '\n",
+ " 'you\\'ve conquered RDR2, any other games on your radar?\",\\n'\n",
+ " ' \"index\": 11\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"im playing helldivers 2. do u know of it\",\\n'\n",
+ " ' \"index\": 12\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 13,\\n'\n",
" ' \"role\": \"assistant\",\\n'\n",
" ' \"content\": \"Yes, Helldivers 2! It\\'s a great choice if '\n",
" \"you're into intense co-op action. The game really ramps up with \"\n",
" 'its twin-stick shooter gameplay, and it\\\\u2019s super fun but '\n",
" 'also quite challenging. Working together with teammates to '\n",
" 'complete those missions can get pretty hectic. How are you '\n",
- " 'finding the chaos and team dynamics so far?\"\\n'\n",
+ " 'finding the chaos and team dynamics so far?\",\\n'\n",
+ " ' \"index\": 13\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 14,\\n'\n",
" ' \"role\": \"user\",\\n'\n",
" ' \"content\": \"amazing. my fav build is laser cannon + guard '\n",
- " 'dog. what about u\"\\n'\n",
+ " 'dog. what about u\",\\n'\n",
+ " ' \"index\": 14\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 15,\\n'\n",
" ' \"role\": \"assistant\",\\n'\n",
" ' \"content\": \"Nice combo! The laser cannon is awesome for '\n",
" 'tearing through those enemy swarms, and the guard dog drone '\n",
" 'really helps in keeping the smaller threats at bay. I personally '\n",
" 'love using the railgun with a shield backpack. It gives a good '\n",
" 'balance of offense and defense, especially when things get really '\n",
- " 'chaotic. What\\'s been the toughest mission for you so far?\"\\n'\n",
+ " 'chaotic. What\\'s been the toughest mission for you so far?\",\\n'\n",
+ " ' \"index\": 15\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 16,\\n'\n",
" ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"dude the charger is so difficult to kill.\"\\n'\n",
+ " ' \"content\": \"dude the charger is so difficult to kill.\",\\n'\n",
+ " ' \"index\": 16\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 17,\\n'\n",
" ' \"role\": \"assistant\",\\n'\n",
" ' \"content\": \"Yeah, the Charger can be brutal! They really test '\n",
" \"your reflexes and teamwork. It's all about timing and \"\n",
" 'coordination with your team to bring those heavy hitters down. '\n",
" 'Have you tried using more strategic traps or mines? Sometimes '\n",
" 'setting up the right position with static fields can really make '\n",
- " 'a difference against them. How do your squadmates handle it?\"\\n'\n",
+ " 'a difference against them. How do your squadmates handle it?\",\\n'\n",
+ " ' \"index\": 17\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 18,\\n'\n",
" ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"we just run and gun\"\\n'\n",
+ " ' \"content\": \"we just run and gun\",\\n'\n",
+ " ' \"index\": 18\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 19,\\n'\n",
" ' \"role\": \"assistant\",\\n'\n",
" ' \"content\": \"Classic strategy! That can definitely be fun, '\n",
" 'especially in a game as intense as Helldivers 2 where things get '\n",
" 'chaotic fast. Keeping on the move helps a ton. Just make sure '\n",
" \"someone's always got your back! Have you guys tried any of the \"\n",
" 'higher difficulty levels yet, or are you sticking to a certain '\n",
- " 'comfort zone for now?\"\\n'\n",
+ " 'comfort zone for now?\",\\n'\n",
+ " ' \"index\": 19\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"role\": \"system\",\\n'\n",
- " ' \"name\": \"summary\",\\n'\n",
- " ' \"content\": \"Event: The user discussed an Nvidia driver issue, '\n",
- " 'particularly its incompatibility with Linux, and the assistant '\n",
- " 'provided potential solutions and resources for assistance.\"\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"i think i have to go work soon. also have this '\n",
+ " 'nvidia driver issue that\\'s bugging me\",\\n'\n",
+ " ' \"index\": 20\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"Ah, bummer about the driver issue \\\\u2014 it\\'s '\n",
+ " 'annoying when tech stuff gets in the way of gaming. Maybe try '\n",
+ " \"doing a clean install of the drivers if you haven't already? It \"\n",
+ " 'can sometimes clear up persistent issues.\\\\n\\\\nAlso, good luck '\n",
+ " \"with work! Hopefully, you'll get some time later to sort out the \"\n",
+ " 'driver thing and jump back into some gaming. Let me know how it '\n",
+ " \"goes, and if you need more gaming chats or tech tips, I'm \"\n",
+ " 'here!\",\\n'\n",
+ " ' \"index\": 21\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"user\",\\n'\n",
+ " ' \"content\": \"nvidia and linux don\\'t go well together\",\\n'\n",
+ " ' \"index\": 22\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"assistant\",\\n'\n",
+ " ' \"content\": \"That\\'s true, Nvidia drivers can be tricky to '\n",
+ " 'handle on Linux due to compatibility issues sometimes. You might '\n",
+ " 'want to check out the latest Nvidia driver from their official '\n",
+ " 'site or a stable version known to work well with your specific '\n",
+ " 'Linux distribution. Using proprietary drivers instead of Nouveau '\n",
+ " 'could also potentially solve a lot of issues. Additionally, '\n",
+ " 'forums and community support boards like those on Ubuntu, Arch, '\n",
+ " 'or even broader communities like Reddit\\\\u2019s r/linux_gaming '\n",
+ " 'can be really helpful.\\\\n\\\\nHope that helps, and your driver woes '\n",
+ " 'get sorted soon so you can enjoy your gaming hassle-free!\",\\n'\n",
+ " ' \"index\": 23\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 24,\\n'\n",
" ' \"role\": \"user\",\\n'\n",
- " ' \"content\": \"yep. see u bye!\"\\n'\n",
+ " ' \"content\": \"yep. see u bye!\",\\n'\n",
+ " ' \"index\": 24\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
- " ' \"index\": 25,\\n'\n",
" ' \"role\": \"assistant\",\\n'\n",
- " ' \"content\": \"See you, take care! Bye!\"\\n'\n",
+ " ' \"content\": \"See you, take care! Bye!\",\\n'\n",
+ " ' \"index\": 25\\n'\n",
" ' }\\n'\n",
" ']',\n",
" 'role': 'assistant'}\n"
@@ -1327,11 +1408,18 @@
"source": [
"pprint(summarized_messages)"
]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
"kernelspec": {
- "display_name": "julep",
+ "display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -1345,7 +1433,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.14"
+ "version": "3.12.1"
}
},
"nbformat": 4,
diff --git a/agents-api/notebooks/RecSum-experiments.ipynb b/agents-api/notebooks/RecSum-experiments.ipynb
index 1315533dc..466c7e6cb 100644
--- a/agents-api/notebooks/RecSum-experiments.ipynb
+++ b/agents-api/notebooks/RecSum-experiments.ipynb
@@ -1,18 +1,68 @@
{
"cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "3127f8fc",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: openai in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.51.0)\n",
+ "Requirement already satisfied: anyio<5,>=3.5.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.6.0)\n",
+ "Requirement already satisfied: distro<2,>=1.7.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.9.0)\n",
+ "Requirement already satisfied: httpx<1,>=0.23.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.27.2)\n",
+ "Requirement already satisfied: jiter<1,>=0.4.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (0.5.0)\n",
+ "Requirement already satisfied: pydantic<3,>=1.9.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (2.9.2)\n",
+ "Requirement already satisfied: sniffio in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (1.3.1)\n",
+ "Requirement already satisfied: tqdm>4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.66.5)\n",
+ "Requirement already satisfied: typing-extensions<5,>=4.11 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from openai) (4.12.2)\n",
+ "Requirement already satisfied: idna>=2.8 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from anyio<5,>=3.5.0->openai) (3.10)\n",
+ "Requirement already satisfied: certifi in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)\n",
+ "Requirement already satisfied: httpcore==1.* in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpx<1,>=0.23.0->openai) (1.0.6)\n",
+ "Requirement already satisfied: h11<0.15,>=0.13 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n",
+ "Requirement already satisfied: annotated-types>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)\n",
+ "Requirement already satisfied: pydantic-core==2.23.4 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pydantic<3,>=1.9.0->openai) (2.23.4)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install openai"
+ ]
+ },
{
"cell_type": "code",
"execution_count": 2,
+ "id": "96efe2be",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Requirement already satisfied: python-dotenv in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.0.1)\n"
+ ]
+ }
+ ],
+ "source": [
+ "! pip install python-dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
"id": "b03a4636-d57e-42e9-8a06-fdb7c6803708",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "True"
+ "False"
]
},
- "execution_count": 2,
+ "execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -23,24 +73,20 @@
"load_dotenv(\"../../.env\")"
]
},
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "eb80a352-ad21-423c-9284-32b21d271eba",
- "metadata": {},
- "outputs": [],
- "source": [
- "from openai import Client"
- ]
- },
{
"cell_type": "code",
"execution_count": 4,
- "id": "4619f484-55f6-4122-8e26-27ec9e3506d5",
+ "id": "eb80a352-ad21-423c-9284-32b21d271eba",
"metadata": {},
"outputs": [],
"source": [
- "client = Client()"
+ "import openai\n",
+ "from openai import OpenAI\n",
+ "\n",
+ "api_key = \"YOUR_OPENAI_API_KEY\"\n",
+ "\n",
+ "openai.api_key = api_key\n",
+ "client = OpenAI(api_key=api_key)"
]
},
{
@@ -99,7 +145,7 @@
"\n",
"\n",
"def chat():\n",
- " while (user_input := input(\"You: \")) != \"bye\":\n",
+ " while (user_input := input(\"You: \").lower()) != \"bye\": \n",
" chat_session.append(user(user_input))\n",
"\n",
" result = generate(chat_session)\n",
@@ -362,63 +408,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "You: hey\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "GPT: Hey! How are you doing?\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "You: good, how about you?\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "GPT: I'm doing well, thank you for asking. Is there anything on your mind that you'd like to talk about or get some advice on?\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "You: no why do you say that? did I sound troubled?\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "GPT: Not at all! I just thought I'd check in and see if there's anything on your mind that you might need some advice or someone to talk to about. But if you're doing well, that's great to hear!\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "You: no I didnt say I was ok just that I hadnt thought of asking for advice yet\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "GPT: Ah, I see. Well, I'm here whenever you need a listening ear or some advice. Just let me know how I can help!\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "You: bye\n"
+ "GPT: Hey there! I just wanted to remind you that it's important to take care of yourself both mentally and physically. Make sure to prioritize self-care and engage in activities that bring you joy and peace. Remember, it's okay to say no to things that don't align with your values or make you uncomfortable. Trust your instincts and surround yourself with positive influences. You deserve to be happy and fulfilled, so don't be afraid to pursue your dreams and make choices that are best for you. If you ever need a listening ear or some guidance, I'm always here for you!\n",
+ "GPT: I'm just a program, so I don't have feelings like humans do, but I'm here and ready to help you with anything you need. How can I support you today?\n"
]
}
],
@@ -442,7 +433,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": 13,
"id": "95431b29-73e2-4954-b6fc-1c8814a9249f",
"metadata": {},
"outputs": [],
@@ -452,7 +443,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 14,
"id": "1eaabfe2-f399-428b-84d2-ed8c237b7d3d",
"metadata": {},
"outputs": [],
@@ -475,7 +466,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 15,
"id": "2a726b3c-493c-4df5-81a7-6b7b109c222e",
"metadata": {},
"outputs": [],
@@ -504,7 +495,7 @@
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 16,
"id": "6323b7b2-0aaf-4cea-896b-0c887054ce6e",
"metadata": {},
"outputs": [],
@@ -596,7 +587,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 17,
"id": "0c2eaabc-76a1-412f-beb3-b64510e638a2",
"metadata": {},
"outputs": [
@@ -604,57 +595,74 @@
"name": "stdout",
"output_type": "stream",
"text": [
- "1714643926.0711672\n",
- "0.0017969608306884766\n",
+ "1728353832.57365\n",
+ "0.00043010711669921875\n",
"Starting CoT generation\n",
"{'content': 'Planning step by step:\\n'\n",
- " '- Combine entries 1 and 2 into a summary of the greeting and '\n",
- " 'initial chat.\\n'\n",
- " '- Summarize the conversation about Red Dead Redemption 2 from '\n",
- " 'entries 3 to 10, noting key points about the game and missions '\n",
- " 'discussed.\\n'\n",
- " '- Combine entries 11 and 12 into a summary about transitioning to '\n",
- " 'the game Helldivers 2, including initial thoughts.\\n'\n",
- " '- Summarize the specific discussion about Helldivers 2 gameplay '\n",
- " 'and strategy from entries 13 to 18.\\n'\n",
- " '- Summarize entries 19 and 20 discussing the user having to go to '\n",
- " 'work and dealing with Nvidia driver issues.\\n'\n",
- " '- Combine entries 21 and 22 to summarize the Nvidia and Linux '\n",
- " 'driver compatibility discussion.\\n'\n",
- " '- Combine entries 23 and 24 to a summary of the farewell.',\n",
+ " '- We can consolidate the initial greetings and mention of Red '\n",
+ " 'Dead Redemption 2 into a summary.\\n'\n",
+ " '- The detailed discussion about RDR2 and Helldivers 2 can be '\n",
+ " 'summarized while retaining key elements of the conversation.\\n'\n",
+ " \"- The user's brief mention of work and technical issues can be \"\n",
+ " 'summarized into one entry to capture the issue without losing '\n",
+ " 'context.\\n'\n",
+ " '- Farewells can be combined into a single entry.\\n'\n",
+ " '\\n'\n",
+ " \"Here's how we can compact the history: \\n\"\n",
+ " '\\n'\n",
+ " '1. Summarize the greeting and initial conversation about Red Dead '\n",
+ " 'Redemption 2.\\n'\n",
+ " '2. Summarize the detailed discussion on RDR2, focusing on the '\n",
+ " \"user's favorite moments and questions from the assistant.\\n\"\n",
+ " '3. Summarize the conversation about Helldivers 2, highlighting '\n",
+ " 'user preferences and challenges faced in gameplay.\\n'\n",
+ " \"4. Combine the entries about the user's Nvidia driver issue and \"\n",
+ " 'the farewell into two concise entries.',\n",
" 'role': 'assistant'}\n",
"End CoT generation\n",
- "7.267635345458984\n",
- "7.2676897048950195\n",
+ "6.3223512172698975\n",
+ "6.322365999221802\n",
"Starting chatml generation\n",
"End chatml generation\n",
- "19.629928588867188\n",
+ "26.040874004364014\n",
"{'content': '[\\n'\n",
" ' {\\n'\n",
" ' \"role\": \"system\",\\n'\n",
- " ' \"content\": \"User greets the assistant and mentions finishing '\n",
- " 'Red Dead Redemption 2, praising the final mission. The assistant '\n",
- " \"responds enthusiastically, discussing the game's ending and key \"\n",
- " 'missions.\"\\n'\n",
+ " ' \"name\": \"summary\",\\n'\n",
+ " ' \"content\": \"The user greeted the assistant and shared their '\n",
+ " 'recent completion of Red Dead Redemption 2, expressing excitement '\n",
+ " 'about the game\\'s final mission.\"\\n'\n",
+ " ' },\\n'\n",
+ " ' {\\n'\n",
+ " ' \"role\": \"system\",\\n'\n",
+ " ' \"name\": \"summary\",\\n'\n",
+ " ' \"content\": \"The user and the assistant discussed favorite '\n",
+ " \"moments from Red Dead Redemption 2, focusing on the 'Blood Feuds, \"\n",
+ " \"Ancient and Modern' mission and Arthur's character development. \"\n",
+ " 'The user expressed a preference for Arthur over Dutch and '\n",
+ " 'mentioned completing all side quests, including the widow and '\n",
+ " 'bounty missions.\"\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
" ' \"role\": \"system\",\\n'\n",
- " ' \"content\": \"The conversation shifts to Helldivers 2, with the '\n",
- " 'user sharing their favorite build and the assistant suggesting '\n",
- " 'strategies. They discuss gameplay dynamics and the challenges of '\n",
- " 'specific missions.\"\\n'\n",
+ " ' \"name\": \"summary\",\\n'\n",
+ " ' \"content\": \"The conversation shifted to Helldivers 2, where '\n",
+ " 'the user described their favorite build and gameplay strategy. '\n",
+ " 'They discussed the challenges of facing the Charger enemy and the '\n",
+ " 'run-and-gun approach they use with their squad.\"\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
" ' \"role\": \"system\",\\n'\n",
- " ' \"content\": \"User mentions having to go to work soon and '\n",
- " 'dealing with an Nvidia driver issue. The assistant offers '\n",
- " 'troubleshooting advice for Nvidia drivers on Linux and wishes the '\n",
- " 'user good luck with work.\"\\n'\n",
+ " ' \"name\": \"summary\",\\n'\n",
+ " ' \"content\": \"The user mentioned having to go to work soon and '\n",
+ " 'experiencing issues with Nvidia drivers on Linux. The assistant '\n",
+ " 'provided suggestions for resolving driver compatibility issues.\"\\n'\n",
" ' },\\n'\n",
" ' {\\n'\n",
" ' \"role\": \"system\",\\n'\n",
- " ' \"content\": \"User acknowledges the advice and says goodbye. '\n",
- " 'The assistant wishes them well.\"\\n'\n",
+ " ' \"name\": \"summary\",\\n'\n",
+ " ' \"content\": \"The user said goodbye, indicating they would see '\n",
+ " 'the assistant later.\"\\n'\n",
" ' }\\n'\n",
" ']',\n",
" 'role': 'assistant'}\n"
@@ -676,7 +684,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3 (ipykernel)",
+ "display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -690,7 +698,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.10.14"
+ "version": "3.12.1"
}
},
"nbformat": 4,
diff --git a/docs/api-reference/README.md b/docs/api-reference/README.md
index ed15fbb56..133cd82dc 100644
--- a/docs/api-reference/README.md
+++ b/docs/api-reference/README.md
@@ -1,3 +1,11 @@
+
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# Agents API
[![Run In Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/33213061-a0a1e3a9-9681-44ae-a5c2-703912b32336?action=collection%2Ffork\&source=rip\_markdown\&collection-url=entityId%3D33213061-a0a1e3a9-9681-44ae-a5c2-703912b32336%26entityType%3Dcollection%26workspaceId%3D183380b4-f2ac-44ef-b018-1f65dfc8256b)
diff --git a/docs/api-reference/agents-api-1.md b/docs/api-reference/agents-api-1.md
index 2f154610a..b5f4ac824 100644
--- a/docs/api-reference/agents-api-1.md
+++ b/docs/api-reference/agents-api-1.md
@@ -2,6 +2,14 @@
description: API for creating and modifying Users
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
+
# Users
## List all users
diff --git a/docs/api-reference/agents-api-2.md b/docs/api-reference/agents-api-2.md
index 35a3f3000..61f601336 100644
--- a/docs/api-reference/agents-api-2.md
+++ b/docs/api-reference/agents-api-2.md
@@ -2,6 +2,13 @@
description: API for creating and modifying Sessions
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# Sessions
## List sessions
diff --git a/docs/api-reference/agents-api-3.md b/docs/api-reference/agents-api-3.md
index 8ef294087..7485ba93e 100644
--- a/docs/api-reference/agents-api-3.md
+++ b/docs/api-reference/agents-api-3.md
@@ -2,6 +2,13 @@
description: API for accessing Agent Memories
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# Memories
## Get an agent's memories
diff --git a/docs/api-reference/agents-api-4.md b/docs/api-reference/agents-api-4.md
index 0cab8dad9..863363b5a 100644
--- a/docs/api-reference/agents-api-4.md
+++ b/docs/api-reference/agents-api-4.md
@@ -2,6 +2,13 @@
description: API for creating and modifying docs
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# Docs
## Get all docs (for an agent or user)
diff --git a/docs/api-reference/agents-api-5.md b/docs/api-reference/agents-api-5.md
index 86c29ae67..a1bb28348 100644
--- a/docs/api-reference/agents-api-5.md
+++ b/docs/api-reference/agents-api-5.md
@@ -1,6 +1,13 @@
# Tasks
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
{% hint style="info" %}
Coming Soon
diff --git a/docs/api-reference/agents-api-6.md b/docs/api-reference/agents-api-6.md
index f5f5bc7ed..44581cd22 100644
--- a/docs/api-reference/agents-api-6.md
+++ b/docs/api-reference/agents-api-6.md
@@ -1,5 +1,12 @@
# Task Runs
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
{% hint style="info" %}
**Coming soon.**
{% endhint %}
diff --git a/docs/api-reference/agents-api.md b/docs/api-reference/agents-api.md
index 783a75e74..08792d15f 100644
--- a/docs/api-reference/agents-api.md
+++ b/docs/api-reference/agents-api.md
@@ -2,6 +2,13 @@
description: API for creating and modifying Agents
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# Agents
## List agents
diff --git a/docs/concepts/agents.md b/docs/concepts/agents.md
index c2a42f9d3..1283aadb6 100644
--- a/docs/concepts/agents.md
+++ b/docs/concepts/agents.md
@@ -2,6 +2,13 @@
description: A fundamental building block of an AI app built using Julep.
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# 🤖 Agents
## What is an Agent?
diff --git a/docs/concepts/documents.md b/docs/concepts/documents.md
index 9509677ae..4db791567 100644
--- a/docs/concepts/documents.md
+++ b/docs/concepts/documents.md
@@ -2,6 +2,13 @@
description: Documents to be added for Retrieval Augmented Generation
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# 📖 Documents
A typical RAG application has the following components:
diff --git a/docs/concepts/sessions/README.md b/docs/concepts/sessions/README.md
index 905665736..f8f01d501 100644
--- a/docs/concepts/sessions/README.md
+++ b/docs/concepts/sessions/README.md
@@ -2,6 +2,13 @@
description: A conversation "session" between a user and an agent.
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# 🔁 Sessions
## What is a Session?
diff --git a/docs/concepts/sessions/adaptive-context.md b/docs/concepts/sessions/adaptive-context.md
index 8bb7cf801..dba2df0fe 100644
--- a/docs/concepts/sessions/adaptive-context.md
+++ b/docs/concepts/sessions/adaptive-context.md
@@ -1,5 +1,12 @@
# Adaptive Context ᴺᴱᵂ
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
### What is Adaptive Context?
Adaptive Context is a feature in Julep that intelligently manages the context size for long-running sessions. It allows users to continue adding messages to a session indefinitely without worrying about hitting context window limits or incurring excessive costs.
diff --git a/docs/concepts/users.md b/docs/concepts/users.md
index a15eed32c..15b3d4f51 100644
--- a/docs/concepts/users.md
+++ b/docs/concepts/users.md
@@ -2,6 +2,13 @@
description: A real person or system that needs to interacts with the Agent in your app.
---
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
# 🙎 Users
## What is a User?
diff --git a/docs/explanation/chat_features.md b/docs/explanation/chat_features.md
index a3e4bf0eb..23aad265c 100644
--- a/docs/explanation/chat_features.md
+++ b/docs/explanation/chat_features.md
@@ -1,5 +1,12 @@
# Chat Features in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep provides a robust chat system with various features for dynamic interaction with agents. Here's an overview of the key components and functionalities:
## Chat Input
diff --git a/docs/explanation/context_overflow.md b/docs/explanation/context_overflow.md
index 5176db2dc..5b87811c4 100644
--- a/docs/explanation/context_overflow.md
+++ b/docs/explanation/context_overflow.md
@@ -1,5 +1,12 @@
# Context Overflow Handling in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep provides mechanisms to handle scenarios where the context size grows beyond the `token_budget` or the model's input limit. The behavior is determined by the `context_overflow` setting:
1. `null` (default):
diff --git a/docs/explanation/core_concepts.md b/docs/explanation/core_concepts.md
index a291aeedf..c8a29f0fd 100644
--- a/docs/explanation/core_concepts.md
+++ b/docs/explanation/core_concepts.md
@@ -1,5 +1,12 @@
# Core Concepts in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep is a powerful backend system for managing agent execution. It provides several key components that work together to create flexible and intelligent applications. Here are the core concepts:
## Agent
diff --git a/docs/explanation/default_system_template.md b/docs/explanation/default_system_template.md
index 3d0f5d272..4ba74b2a9 100644
--- a/docs/explanation/default_system_template.md
+++ b/docs/explanation/default_system_template.md
@@ -1,5 +1,12 @@
# Default System Template in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep uses a default system template for sessions when a custom one is not provided. This template is written in Jinja2 and incorporates various elements from the agent, user, and session context. Here's a breakdown of the template:
```jinja
diff --git a/docs/explanation/execution_state_machine.md b/docs/explanation/execution_state_machine.md
index 9acd2ccaf..648d514bd 100644
--- a/docs/explanation/execution_state_machine.md
+++ b/docs/explanation/execution_state_machine.md
@@ -1,5 +1,12 @@
# Execution State Machine in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
In Julep, an Execution represents an instance of a Task that has been started with some input. The Execution follows a specific state machine model, ensuring consistent and predictable behavior throughout its lifecycle.
## Execution States
diff --git a/docs/explanation/metadata_precedence.md b/docs/explanation/metadata_precedence.md
index f704b1373..dd36ce0ce 100644
--- a/docs/explanation/metadata_precedence.md
+++ b/docs/explanation/metadata_precedence.md
@@ -1,5 +1,12 @@
# Metadata Precedence in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
In Julep, several objects can have `metadata` added to them:
- Agent
- User
diff --git a/docs/explanation/multi_agent_sessions.md b/docs/explanation/multi_agent_sessions.md
index b497c0fd2..72fa5d52a 100644
--- a/docs/explanation/multi_agent_sessions.md
+++ b/docs/explanation/multi_agent_sessions.md
@@ -1,5 +1,12 @@
# Multi-Agent Sessions in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep supports different types of sessions based on the number of agents and users involved. This flexibility allows for complex interactions and use cases.
## Types of Sessions
diff --git a/docs/explanation/task_workflows.md b/docs/explanation/task_workflows.md
index 7c77ff686..847cb3157 100644
--- a/docs/explanation/task_workflows.md
+++ b/docs/explanation/task_workflows.md
@@ -1,5 +1,12 @@
# Task Workflows in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Tasks in Julep are powerful, Github Actions-style workflows that define long-running, multi-step actions. They allow for complex operations by defining steps and have access to all Julep integrations.
## Task Structure
diff --git a/docs/explanation/tool_integration.md b/docs/explanation/tool_integration.md
index a0cfd4ae9..a3a71065a 100644
--- a/docs/explanation/tool_integration.md
+++ b/docs/explanation/tool_integration.md
@@ -1,5 +1,12 @@
# Tool Integration in Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep provides a flexible system for integrating various types of tools that agents can use during interactions. These tools enable agents to perform actions, retrieve information, or interact with external systems.
## Types of Tools
diff --git a/docs/how-to-guides/customizing_tasks.md b/docs/how-to-guides/customizing_tasks.md
index 29a39dd19..a5f845214 100644
--- a/docs/how-to-guides/customizing_tasks.md
+++ b/docs/how-to-guides/customizing_tasks.md
@@ -1,5 +1,12 @@
# Customizing Tasks
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This guide covers how to define and customize tasks for agents in Julep.
## Creating a Basic Task
diff --git a/docs/how-to-guides/handling_executions.md b/docs/how-to-guides/handling_executions.md
index 22aeedaa5..fca788642 100644
--- a/docs/how-to-guides/handling_executions.md
+++ b/docs/how-to-guides/handling_executions.md
@@ -1,5 +1,12 @@
# Handling Executions
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This guide covers how to manage and monitor task executions in Julep.
## Starting an Execution
diff --git a/docs/how-to-guides/managing_users.md b/docs/how-to-guides/managing_users.md
index 6bdb94bac..b1f47a016 100644
--- a/docs/how-to-guides/managing_users.md
+++ b/docs/how-to-guides/managing_users.md
@@ -1,5 +1,12 @@
# Managing Users
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This guide covers how to create, update, and delete users in Julep.
## Creating a User
diff --git a/docs/how-to-guides/using_chat_features.md b/docs/how-to-guides/using_chat_features.md
index 63423ff0c..d9aabceaa 100644
--- a/docs/how-to-guides/using_chat_features.md
+++ b/docs/how-to-guides/using_chat_features.md
@@ -1,5 +1,12 @@
# Using Chat Features
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This guide covers how to use the chat features in Julep for dynamic interactions with agents.
## Starting a Chat Session
diff --git a/docs/introduction/getting_started.md b/docs/introduction/getting_started.md
index 6aa590121..f273bb776 100644
--- a/docs/introduction/getting_started.md
+++ b/docs/introduction/getting_started.md
@@ -1,5 +1,12 @@
# Getting Started with Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This guide will help you set up and start using the Julep API.
## Prerequisites
diff --git a/docs/introduction/overview.md b/docs/introduction/overview.md
index a914535b5..26c75bcdb 100644
--- a/docs/introduction/overview.md
+++ b/docs/introduction/overview.md
@@ -1,5 +1,12 @@
# Overview of Julep
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
Julep is a powerful backend system for managing agent execution and interactions. It provides a comprehensive set of features for creating and managing agents, users, sessions, tools, documents, tasks, and executions.
## Key Features
diff --git a/docs/reference/api_endpoints/agent_endpoints.md b/docs/reference/api_endpoints/agent_endpoints.md
index 692931bb2..8634b2098 100644
--- a/docs/reference/api_endpoints/agent_endpoints.md
+++ b/docs/reference/api_endpoints/agent_endpoints.md
@@ -1,5 +1,12 @@
# Agent Endpoints
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This document provides a reference for all Agent API endpoints in Julep.
## List Agents
diff --git a/docs/reference/api_endpoints/doc_endpoints.md b/docs/reference/api_endpoints/doc_endpoints.md
index c168ecac2..2971c1b50 100644
--- a/docs/reference/api_endpoints/doc_endpoints.md
+++ b/docs/reference/api_endpoints/doc_endpoints.md
@@ -1,5 +1,12 @@
# Doc Endpoints
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This document provides a reference for all Doc API endpoints in Julep.
## List Docs for a User
diff --git a/docs/reference/api_endpoints/session_endpoints.md b/docs/reference/api_endpoints/session_endpoints.md
index f7a649594..03bd7559d 100644
--- a/docs/reference/api_endpoints/session_endpoints.md
+++ b/docs/reference/api_endpoints/session_endpoints.md
@@ -1,5 +1,12 @@
# Session Endpoints
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This document provides a reference for all Session API endpoints in Julep.
## List Sessions
diff --git a/docs/reference/api_endpoints/tool_endpoints.md b/docs/reference/api_endpoints/tool_endpoints.md
index a0aeab36a..194713f1f 100644
--- a/docs/reference/api_endpoints/tool_endpoints.md
+++ b/docs/reference/api_endpoints/tool_endpoints.md
@@ -1,5 +1,12 @@
# Tool Endpoints
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This document provides a reference for all Tool API endpoints in Julep.
## List Tools for an Agent
diff --git a/docs/reference/api_endpoints/user_endpoints.md b/docs/reference/api_endpoints/user_endpoints.md
index 9242c7167..ac2578907 100644
--- a/docs/reference/api_endpoints/user_endpoints.md
+++ b/docs/reference/api_endpoints/user_endpoints.md
@@ -1,5 +1,12 @@
# User Endpoints
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This document provides a reference for all User API endpoints in Julep.
## List Users
diff --git a/docs/tutorials/creating_your_first_agent.md b/docs/tutorials/creating_your_first_agent.md
index a21d27b1d..ae79c1e11 100644
--- a/docs/tutorials/creating_your_first_agent.md
+++ b/docs/tutorials/creating_your_first_agent.md
@@ -1,5 +1,12 @@
# Creating Your First Agent
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This tutorial will guide you through the process of creating your first agent using the Julep API.
## Step 1: Prepare the Agent Data
diff --git a/docs/tutorials/integrating_tools.md b/docs/tutorials/integrating_tools.md
index 16889f4a6..2c3233d1a 100644
--- a/docs/tutorials/integrating_tools.md
+++ b/docs/tutorials/integrating_tools.md
@@ -1,5 +1,12 @@
# Integrating Tools
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This tutorial will show you how to integrate tools with your Julep agents.
## Creating a User-Defined Function Tool
diff --git a/docs/tutorials/managing_sessions.md b/docs/tutorials/managing_sessions.md
index 866484912..bffb301fd 100644
--- a/docs/tutorials/managing_sessions.md
+++ b/docs/tutorials/managing_sessions.md
@@ -1,5 +1,12 @@
# Managing Sessions
+*****
+> ### This docs site is currently under construction although this github README below should suffice for now.
+
+![](https://i.giphy.com/vR1dPIYzQmkRzLZk2w.webp)
+*****
+
+
This tutorial will guide you through creating and managing sessions with your Julep agents.
## Creating a Session
diff --git a/example.js b/example.js
new file mode 100644
index 000000000..df2bf0af8
--- /dev/null
+++ b/example.js
@@ -0,0 +1,130 @@
+const { Julep } = require('@julep/sdk');
+const yaml = require('js-yaml');
+const readline = require('readline');
+
+const client = new Julep({ apiKey: 'your_julep_api_key' });
+
+async function createAgent() {
+ const agent = await client.agents.create({
+ name: "Storytelling Agent",
+ model: "gpt-4",
+ about: "You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.",
+ });
+
+ // 🛠️ Add an image generation tool (DALL·E) to the agent
+ await client.agents.tools.create(agent.id, {
+ name: "image_generator",
+ description: "Use this tool to generate images based on descriptions.",
+ integration: {
+ provider: "dalle",
+ method: "generate_image",
+ setup: {
+ api_key: "your_openai_api_key",
+ },
+ },
+ });
+
+ return agent;
+}
+
+const taskYaml = `
+name: Story and Comic Creator
+description: Create a story based on an idea and generate a 4-panel comic strip illustrating the story.
+
+main:
+ # Step 1: Generate a story and outline into 4 panels
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the idea '{{_.idea}}', write a short story suitable for a 4-panel comic strip.
+ Provide the story and a numbered list of 4 brief descriptions for each panel illustrating key moments in the story.
+ unwrap: true
+
+ # Step 2: Extract the panel descriptions and story
+ - evaluate:
+ story: _.split('1. ')[0].trim()
+ panels: _.match(/\\d+\\.\\s*(.*?)(?=\\d+\\.\\s*|$)/g)
+
+ # Step 3: Generate images for each panel using the image generator tool
+ - foreach:
+ in: _.panels
+ do:
+ tool: image_generator
+ arguments:
+ description: _
+
+ # Step 4: Generate a catchy title for the story
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the story below, generate a catchy title.
+
+ Story: {{outputs[1].story}}
+ unwrap: true
+
+ # Step 5: Return the story, the generated images, and the title
+ - return:
+ title: outputs[3]
+ story: outputs[1].story
+ comic_panels: outputs[2].map(output => output.image.url)
+`;
+
+async function createTask(agent) {
+ const task = await client.tasks.create(agent.id, yaml.load(taskYaml));
+ return task;
+}
+
+async function executeTask(task) {
+ const execution = await client.executions.create(task.id, {
+ input: { idea: "A cat who learns to fly" }
+ });
+
+ // 🎉 Watch as the story and comic panels are generated
+ for await (const transition of client.executions.transitions.stream(execution.id)) {
+ console.log(transition);
+ }
+
+ // 📦 Once the execution is finished, retrieve the results
+ const result = await client.executions.get(execution.id);
+ return result;
+}
+
+async function chatWithAgent(agent) {
+ const session = await client.sessions.create({ agent_id: agent.id });
+
+ // 💬 Send messages to the agent
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout
+ });
+
+ const chat = async () => {
+ rl.question("Enter a message (or 'quit' to exit): ", async (message) => {
+ if (message.toLowerCase() === 'quit') {
+ rl.close();
+ return;
+ }
+
+ const response = await client.sessions.chat(session.id, { message });
+ console.log(response);
+ chat();
+ });
+ };
+
+ chat();
+}
+
+// Run the example
+async function runExample() {
+ const agent = await createAgent();
+ const task = await createTask(agent);
+ const result = await executeTask(task);
+ console.log("Task Result:", result);
+ await chatWithAgent(agent);
+}
+
+runExample().catch(console.error);
\ No newline at end of file
diff --git a/example.py b/example.py
index ef6d6f427..1d0e7deda 100644
--- a/example.py
+++ b/example.py
@@ -1,107 +1,109 @@
-from julep import Julep, AsyncJulep
+import yaml
+from julep import Julep
-# 🔑 Initialize the Julep client
-# Or alternatively, use AsyncJulep for async operations
-client = Julep(api_key="your_api_key")
+# Initialize the Julep client
+client = Julep(api_key="your_julep_api_key")
-##################
-## 🤖 Agent 🤖 ##
-##################
-
-# Create a research agent
+# Step 1: Create an Agent
agent = client.agents.create(
- name="Research Agent",
- about="You are a research agent designed to handle research inquiries.",
- model="claude-3.5-sonnet",
+ name="Storytelling Agent",
+ model="gpt-4",
+ about="You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.",
)
-# 🔍 Add a web search tool to the agent
+# Add an image generation tool (DALL·E) to the agent
client.agents.tools.create(
agent_id=agent.id,
- name="web_search", # Should be python valid variable name
- description="Use this tool to research inquiries.",
+ name="image_generator",
+ description="Use this tool to generate images based on descriptions.",
integration={
- "provider": "brave",
- "method": "search",
+ "provider": "dalle",
+ "method": "generate_image",
"setup": {
- "api_key": "your_brave_api_key",
+ "api_key": "your_openai_api_key",
},
},
)
-#################
-## 💬 Chat 💬 ##
-#################
+# Step 2: Create a Task that generates a story and comic strip
+task_yaml = """
+name: Story and Comic Creator
+description: Create a story based on an idea and generate a 4-panel comic strip illustrating the story.
-# Start an interactive chat session with the agent
-session = client.sessions.create(
- agent_id=agent.id,
- context_overflow="adaptive", # 🧠 Julep will dynamically compute the context window if needed
-)
+main:
+ # Step 1: Generate a story and outline into 4 panels
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the idea '{{_.idea}}', write a short story suitable for a 4-panel comic strip.
+ Provide the story and a numbered list of 4 brief descriptions for each panel illustrating key moments in the story.
+ unwrap: true
-# 🔄 Chat loop
-while (user_input := input("You: ")) != "exit":
- response = client.sessions.chat(
- session_id=session.id,
- message=user_input,
- )
+ # Step 2: Extract the panel descriptions and story
+ - evaluate:
+ story: _.split('1. ')[0].strip()
+ panels: re.findall(r'\\d+\\.\\s*(.*?)(?=\\d+\\.\\s*|$)', _)
+
+ # Step 3: Generate images for each panel using the image generator tool
+ - foreach:
+ in: _.panels
+ do:
+ tool: image_generator
+ arguments:
+ description: _
- print("Agent: ", response.choices[0].message.content)
+ # Step 4: Generate a catchy title for the story
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the story below, generate a catchy title.
+ Story: {{outputs[1].story}}
+ unwrap: true
-#################
-## 📋 Task 📋 ##
-#################
+ # Step 5: Return the story, the generated images, and the title
+ - return:
+ title: outputs[3]
+ story: outputs[1].story
+ comic_panels: "[output.image.url for output in outputs[2]]"
+"""
-# Create a recurring research task for the agent
task = client.tasks.create(
agent_id=agent.id,
- name="Research Task",
- description="Research the given topic every 24 hours.",
- #
- # 🛠️ Task specific tools
- tools=[
- {
- "name": "send_email",
- "description": "Send an email to the user with the results.",
- "api_call": {
- "method": "post",
- "url": "https://api.sendgrid.com/v3/mail/send",
- "headers": {"Authorization": "Bearer YOUR_SENDGRID_API_KEY"},
- },
- }
- ],
- #
- # 🔢 Task main steps
- main=[
- #
- # Step 1: Research the topic
- {
- # `_` (underscore) variable refers to the previous step's output
- # Here, it points to the topic input from the user
- "prompt": "Look up topic '{{_.topic}}' and summarize the results.",
- "tools": [{"ref": {"name": "web_search"}}], # 🔍 Use the web search tool from the agent
- "unwrap": True,
- },
- #
- # Step 2: Send email with research results
- {
- "tool": "send_email",
- "arguments": {
- "subject": "Research Results",
- "body": "'Here are the research results for today: ' + _.content",
- "to": "inputs[0].email", # Reference the email from the user's input
- },
- },
- #
- # Step 3: Wait for 24 hours before repeating
- {"sleep": "24 * 60 * 60"},
- ],
+ **yaml.safe_load(task_yaml)
)
-# 🚀 Start the recurring task
-client.executions.create(task_id=task.id, input={"topic": "Python"})
+# Step 3: Execute the Task
+execution = client.executions.create(
+ task_id=task.id,
+ input={"idea": "A cat who learns to fly"}
+)
+
+# Watch as the story and comic panels are generated
+for transition in client.executions.transitions.stream(execution_id=execution.id):
+ print(transition)
+
+# Once the execution is finished, retrieve the results
+result = client.executions.get(execution_id=execution.id)
+print("Task Result:", result)
+
+# Step 4: Chat with the Agent
+session = client.sessions.create(agent_id=agent.id)
+
+# Send messages to the agent
+while True:
+ message = input("Enter a message (or 'quit' to exit): ")
+ if message.lower() == 'quit':
+ break
+
+ response = client.sessions.chat(
+ session_id=session.id,
+ message=message,
+ )
+ print("Agent:", response.choices[0].message.content)
-# 🔁 This will run the task every 24 hours,
-# research for the topic "Python", and
-# send the results to the user's email
+print("Chat session ended.")
diff --git a/example.ts b/example.ts
index 3ef4e1a91..df795dd5e 100644
--- a/example.ts
+++ b/example.ts
@@ -1,117 +1,149 @@
-import Julep from '@julep/sdk';
-
-// 🔑 Initialize the Julep client
-const client = new Julep({
- apiKey: 'your_api_key',
- environment: 'production', // or 'dev' | 'local_multi_tenant' | 'local'
-});
-
-async function main() {
- /*
- * 🤖 Agent 🤖
- */
-
- // Create a research agent
- const agent = await client.agents.createOrUpdate('dad00000-0000-4000-a000-000000000000', {
- name: 'Research Agent',
- about: 'You are a research agent designed to handle research inquiries.',
- model: 'claude-3.5-sonnet',
+import { Julep } from '@julep/sdk';
+import yaml from 'js-yaml';
+import readline from 'readline';
+
+// Add these type declarations at the top of the file
+declare module '@julep/sdk';
+declare module 'js-yaml';
+
+const client = new Julep({ apiKey: 'your_julep_api_key' });
+
+interface Agent {
+ id: string;
+ // Add other properties as needed
+}
+
+interface Task {
+ id: string;
+ // Add other properties as needed
+}
+
+interface Execution {
+ id: string;
+ // Add other properties as needed
+}
+
+async function createAgent(): Promise {
+ const agent = await client.agents.create({
+ name: "Storytelling Agent",
+ model: "gpt-4",
+ about: "You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.",
});
- // 🔍 Add a web search tool to the agent
+ // 🛠️ Add an image generation tool (DALL·E) to the agent
await client.agents.tools.create(agent.id, {
- name: 'web_search',
- description: 'Use this tool to research inquiries.',
+ name: "image_generator",
+ description: "Use this tool to generate images based on descriptions.",
integration: {
- provider: 'brave',
- method: 'search',
+ provider: "dalle",
+ method: "generate_image",
setup: {
- api_key: 'your_brave_api_key',
+ api_key: "your_openai_api_key",
},
},
});
- /*
- * 💬 Chat 💬
- */
+ return agent;
+}
- // Start an interactive chat session with the agent
- const session = await client.sessions.create({
- agentId: agent.id,
- contextOverflow: 'adaptive', /* 🧠 Julep will dynamically compute the context window if needed */
- });
+const taskYaml = `
+name: Story and Comic Creator
+description: Create a story based on an idea and generate a 4-panel comic strip illustrating the story.
+
+main:
+ # Step 1: Generate a story and outline into 4 panels
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the idea '{{_.idea}}', write a short story suitable for a 4-panel comic strip.
+ Provide the story and a numbered list of 4 brief descriptions for each panel illustrating key moments in the story.
+ unwrap: true
+
+ # Step 2: Extract the panel descriptions and story
+ - evaluate:
+ story: _.split('1. ')[0].trim()
+ panels: _.match(/\\d+\\.\\s*(.*?)(?=\\d+\\.\\s*|$)/g)
+
+ # Step 3: Generate images for each panel using the image generator tool
+ - foreach:
+ in: _.panels
+ do:
+ tool: image_generator
+ arguments:
+ description: _
+
+ # Step 4: Generate a catchy title for the story
+ - prompt:
+ - role: system
+ content: You are {{agent.name}}. {{agent.about}}
+ - role: user
+ content: >
+ Based on the story below, generate a catchy title.
+
+ Story: {{outputs[1].story}}
+ unwrap: true
+
+ # Step 5: Return the story, the generated images, and the title
+ - return:
+ title: outputs[3]
+ story: outputs[1].story
+ comic_panels: outputs[2].map(output => output.image.url)
+`;
+
+async function createTask(agent: Agent): Promise {
+ const task = await client.tasks.create(agent.id, yaml.load(taskYaml));
+ return task;
+}
- // 🔄 Chat loop
- const readline = require('readline').createInterface({
- input: process.stdin,
- output: process.stdout,
+async function executeTask(task: Task): Promise {
+ const execution = await client.executions.create(task.id, {
+ input: { idea: "A cat who learns to fly" }
});
- const askQuestion = (query: string) => new Promise((resolve) => readline.question(query, resolve));
+ // 🎉 Watch as the story and comic panels are generated
+ for await (const transition of client.executions.transitions.stream(execution.id)) {
+ console.log(transition);
+ }
- while (true) {
- const userInput = await askQuestion('You: ');
- if (userInput === 'exit') break;
+ // 📦 Once the execution is finished, retrieve the results
+ const result = await client.executions.get(execution.id);
+ return result;
+}
- const response = await client.sessions.chat(session.id, {
- message: userInput,
- });
+async function chatWithAgent(agent: Agent): Promise {
+ const session = await client.sessions.create({ agent_id: agent.id });
- console.log('Agent: ', response.choices[0].message.content);
- }
-
- readline.close();
-
- /*
- * 📋 Task 📋
- */
-
- // Create a recurring research task for the agent
- const task = await client.tasks.create(agent.id, {
- name: 'Research Task',
- description: 'Research the given topic every 24 hours.',
- /* 🛠️ Task specific tools */
- tools: [
- {
- name: 'send_email',
- description: 'Send an email to the user with the results.',
- apiCall: {
- method: 'post',
- url: 'https://api.sendgrid.com/v3/mail/send',
- headers: { Authorization: 'Bearer YOUR_SENDGRID_API_KEY' },
- },
- },
- ],
- /* 🔢 Task main steps */
- main: [
- // Step 1: Research the topic
- {
- prompt: "Look up topic '{{_.topic}}' and summarize the results.",
- tools: [{ ref: { name: 'web_search' } }], /* 🔍 Use the web search tool from the agent */
- unwrap: true,
- },
- // Step 2: Send email with research results
- {
- tool: 'send_email',
- arguments: {
- subject: 'Research Results',
- body: "'Here are the research results for today: ' + _.content",
- to: 'inputs[0].email', // Reference the email from the user's input
- },
- },
- // Step 3: Wait for 24 hours before repeating
- { sleep: 24 * 60 * 60 },
- ],
+ // 💬 Send messages to the agent
+ const rl = readline.createInterface({
+ input: process.stdin,
+ output: process.stdout
});
- // 🚀 Start the recurring task
- await client.executions.create(task.id, { input: { topic: 'TypeScript' } });
+ const chat = async () => {
+ rl.question("Enter a message (or 'quit' to exit): ", async (message) => {
+ if (message.toLowerCase() === 'quit') {
+ rl.close();
+ return;
+ }
+
+ const response = await client.sessions.chat(session.id, { message });
+ console.log(response);
+ chat();
+ });
+ };
+
+ chat();
+}
- /*
- * 🔁 This will run the task every 24 hours,
- * research for the topic "TypeScript", and
- * send the results to the user's email
- */
+// Run the example
+async function runExample() {
+ const agent = await createAgent();
+ const task = await createTask(agent);
+ const result = await executeTask(task);
+ console.log("Task Result:", result);
+ await chatWithAgent(agent);
}
-main().catch(console.error);
\ No newline at end of file
+runExample().catch(console.error);
\ No newline at end of file
diff --git a/memory-store/docker-compose.yml b/memory-store/docker-compose.yml
index 2adf50e81..e785a3526 100644
--- a/memory-store/docker-compose.yml
+++ b/memory-store/docker-compose.yml
@@ -33,5 +33,6 @@ services:
volumes:
cozo_data:
+ external: true
cozo_backup:
external: true
\ No newline at end of file
diff --git a/sdks/node-sdk b/sdks/node-sdk
index 2685cfe51..6ff96ce85 160000
--- a/sdks/node-sdk
+++ b/sdks/node-sdk
@@ -1 +1 @@
-Subproject commit 2685cfe512d6b2907e6bdd1b3294175e20aece99
+Subproject commit 6ff96ce8599538291aeb242e6d11650f2c490616
diff --git a/sdks/python-sdk b/sdks/python-sdk
index aaa88a204..3d763379e 160000
--- a/sdks/python-sdk
+++ b/sdks/python-sdk
@@ -1 +1 @@
-Subproject commit aaa88a204bb85b7903f79b8fb5cca0c3e6882c73
+Subproject commit 3d763379e986b38a9d7f24b99f7f6211f19591a0