diff --git a/README-CN.md b/README-CN.md index c74aeea3d..55ea307ca 100644 --- a/README-CN.md +++ b/README-CN.md @@ -28,6 +28,9 @@ ***** +> [!TIP] +> 👨‍💻 来参加 devfest.ai 活动?加入我们的 [Discord](https://discord.com/invite/JTSBGRZrzj) 并查看下方详情。 +
🌟 贡献者和 DevFest.AI 参与者: @@ -79,10 +82,6 @@
-> [!TIP] -> 🐛 发现了 bug?有建议?我们很乐意听取您的意见! -> 加入我们的 [Discord](https://discord.com/invite/JTSBGRZrzj) 或提交 [issue](https://github.com/julep-ai/julep/issues)。 - ## 简介 Julep 是一个开源平台,用于创建具有可定制工作流的持久 AI 代理。它提供了开发、管理和部署 AI 驱动应用程序的工具,注重灵活性和易用性。 diff --git a/README-JP.md b/README-JP.md index 8138e2b03..8f9e49cc2 100644 --- a/README-JP.md +++ b/README-JP.md @@ -28,6 +28,9 @@ ***** +> [!TIP] +> 👨‍💻 devfest.aiイベントに参加されましたか?私たちの[Discord](https://discord.com/invite/JTSBGRZrzj)に参加して、以下の詳細をご確認ください。 +
🌟 コントリビューターとDevFest.AI参加者の皆様へ: @@ -79,10 +82,6 @@ Julepプロジェクトに新しいコントリビューターを歓迎します
-> [!TIP] -> 🐛 バグを見つけましたか?提案がありますか?私たちはあなたの意見を聞きたいです! -> [Discord](https://discord.com/invite/JTSBGRZrzj)に参加するか、[issue](https://github.com/julep-ai/julep/issues)を開いてください。 - ## 紹介 Julepは、カスタマイズ可能なワークフローを持つ持続可能なAIエージェントを作成するためのオープンソースプラットフォームです。柔軟性と使いやすさに重点を置いて、AI駆動のアプリケーションを開発、管理、展開するためのツールを提供します。 diff --git a/README.md b/README.md index d3613dff7..ec251b7b6 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,11 @@ ***** +> [!TIP] +> 👨‍💻 Here for the devfest.ai event? Join our [Discord](https://discord.com/invite/JTSBGRZrzj) and check out the details below. +
-🌟 Contributors and DevFest.AI Participants: +🌟 Contributors and DevFest.AI Participants ## 🌟 Call for Contributors! @@ -79,155 +82,185 @@ Exciting news! We're participating in DevFest.AI throughout October 2024! 🗓
-> [!TIP] -> 🐛 Found a bug? Have a suggestion? We'd love to hear from you! -> Join our [Discord](https://discord.com/invite/JTSBGRZrzj) or open an [issue](https://github.com/julep-ai/julep/issues). - -## Introduction - -Julep is an open-source platform for creating persistent AI agents with customizable workflows. It provides tools to develop, manage, and deploy AI-driven applications, focusing on flexibility and ease of use. - -With Julep, you can: -- Quickly develop AI agents that retain context and state across interactions -- Design and execute sophisticated workflows tailored to your AI agents -- Seamlessly integrate various tools and APIs into your AI workflows -- Effortlessly manage persistent sessions and user interactions - -Whether you're developing a chatbot, automating tasks, or building a complex AI assistant, Julep provides the flexibility and features you need to turn your ideas into reality swiftly and efficiently. +## Quick Intro -
-Here's a quick python example: +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. + +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. + +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. + +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 + +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: + +```yaml +name: Research Agent + +# Optional: Define the input schema for the task +input_schema: + type: object + properties: + topic: + type: string + description: The main topic to research + +# Define the tools that the agent can use +tools: +- name: web_search + type: integration + integration: + provider: brave + setup: + api_key: "YOUR_BRAVE_API_KEY" + +- name: discord_webhook + type: api_call + api_call: + url: "YOUR_DISCORD_WEBHOOK_URL" + method: POST + headers: + Content-Type: application/json + +# Define the main workflow +# ------------------------ + +# There are a few different types of steps you can define in Julep: +# - prompt: for generating new queries, results, follow-ups, etc. +# - evaluate: for performing calculations, evaluations, etc. +# - tool: for calling external APIs, databases, etc. +# - map-reduce: for performing a workflow over a list of items in parallel +# ... and more! + +# Special variables: +# - inputs: for accessing the input to the task +# - outputs: for accessing the output of previous steps +# - _: for accessing the output of the previous step + +main: +- prompt: + - role: system + content: >- + You are a research assistant. + Generate 100 diverse search queries related to the topic: + {{inputs[0].topic}} + + Write one query per line. + unwrap: true + +- evaluate: + search_queries: "_.split('\n')" + +- over: "_.search_queries" + map: + tool: web_search + arguments: + query: "_" + on_error: + parallelism: 100 + +- evaluate: + results: "'\n'.join([item.result for item in _])" + +- 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')" + +- 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 _])" + +- 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}} + unwrap: true + +- tool: discord_webhook + arguments: + content: > + **Research Summary for {{inputs[0].topic}}** + + {{_}} +``` - +> [!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. -

-from julep import Julep, AsyncJulep
 
-# 🔑 Initialize the Julep client
-#     Or alternatively, use AsyncJulep for async operations
-client = Julep(api_key="your_api_key")
+## Key Features
 
-##################
-## 🤖 Agent 🤖 ##
-##################
+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.
 
-# Create a research agent
-agent = client.agents.create(
-    name="Research Agent",
-    model="claude-3.5-sonnet",
-    about="You are a research agent designed to handle research inquiries.",
-)
+Julep is ideal for applications that require AI use cases beyond simple prompt-response models.
 
-# 🔍 Add a web search tool 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.",
-    integration={
-        "provider": "brave",
-        "method": "search",
-        "setup": {
-            "api_key": "your_brave_api_key",
-        },
-    },
-)
+## Why Julep vs. LangChain?
 
-#################
-## 💬 Chat 💬 ##
-#################
+### Different Use Cases
 
-# 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
-)
+Think of LangChain and Julep as tools with different focuses within the AI development stack.
 
-# 🔄 Chat loop
-while (user_input := input("You: ")) != "exit":
-    response = client.sessions.chat(
-        session_id=session.id,
-        message=user_input,
-    )
+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.
 
-    print("Agent: ", response.choices[0].message.content)
+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.
 
+Use Julep if you imagine building a complex AI assistant that needs to:
 
-#################
-## 📋 Task 📋 ##
-#################
+- 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.
 
-# 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"},
-    ],
-)
+Then Julep provides the infrastructure to support all that without you having to build it from scratch.
 
-# 🚀 Start the recurring task
-client.executions.create(task_id=task.id, input={"topic": "Python"})
+### Different Form Factor
 
-# 🔁 This will run the task every 24 hours,
-#    research for the topic "Python", and
-#    send the results to the user's email
+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.
 
-# 🎉 Watch as the story and comic panels are generated
-# Changed 'client.executions.stream' to 'client.executions.transitions.stream'
-await client.executions.transitions.stream(execution_id=execution.id)
-
-
+Julep is built for heavy-lifting, multi-step, and long-running workflows and there's no limit to how complex the workflow 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. -## Features +LangChain might be sufficient and quicker to implement for simple use cases that involve a linear chain of prompts and API calls. -Julep simplifies the process of building persistent AI agents with customizable workflows. Key features include: +### In Summary -- **Persistent AI Agents**: Create and manage AI agents that maintain context across interactions. -- **Customizable Workflows**: Design complex, multi-step AI workflows using Tasks. -- **Tool Integration**: Seamlessly integrate various tools and APIs into your AI workflows. -- **Document Management**: Efficiently manage and search through documents for your agents. -- **Session Management**: Handle persistent sessions for continuous interactions. -- **Flexible Execution**: Support for parallel processing, conditional logic, and error handling in workflows. +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. ## Installation @@ -243,93 +276,34 @@ or pip install julep ``` -> [!TIP] +> [!NOTE] > ~~Get your API key [here](https://app.julep.ai/api-keys).~~ > > While we are in beta, you can reach out on [Discord](https://discord.com/invite/JTSBGRZrzj) to get your API key. -## Quick Start Guide - -### Step 1: Import Julep - -First, import the Julep SDK into your project: +> [!TIP] +> 💻 Are you a _show me the code!™_ kind of person? We have created a ton of cookbooks for you to get started with. **Check out the [cookbooks](/cookbooks)** to browse through examples. +> +> 💡 There's also lots of ideas that you can build on top of Julep. **Check out the [list of ideas](/cookbooks/IDEAS.md)** to get some inspiration. -```javascript -const Julep = require('@julep/sdk'); -``` +## Python Quick Start 🐍 -or +### Step 1: Create an Agent ```python -from julep import AsyncJulep -``` +import yaml +from julep import Julep # or AsyncJulep -### Step 2: Initialize the Agent - -Create a new agent with basic settings: - -```javascript -const julep = new Julep({ apiKey: 'your-api-key' }); - -const agent = await julep.agents.create({ - name: 'ResearchAssistant', - model: 'gpt-4-turbo', - about: "You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.", -}); -``` +client = Julep(api_key="your_julep_api_key") -or - -```python -client = AsyncJulep(api_key="your_api_key") - -agent = await client.agents.create( +agent = client.agents.create( name="Storytelling Agent", - model="gpt-4-turbo", + model="gpt-4o", about="You are a creative storytelling agent that can craft engaging stories and generate comic panels based on ideas.", ) -``` - -### Step 3: Chat with the Agent - -Start an interactive chat session with the agent: - -```javascript -const session = await julep.sessions.create({ - agentId: agent.id, -}); - -// Send messages to the agent -const response = await julep.sessions.chat({ - sessionId: session.id, - message: 'Hello, can you tell me a story?', -}); - -console.log(response); -``` - -or - -```python -session = await client.sessions.create(agent_id=agent.id) - -# Send messages to the agent -response = await client.sessions.chat( - session_id=session.id, - message="Hello, can you tell me a story?", -) - -print(response) -``` - - -### Step 4: Create a multi-step Task - -Let's define a multi-step task to create a story and generate a paneled comic strip based on an input idea: -```python # 🛠️ Add an image generation tool (DALL·E) to the agent -await client.agents.tools.create( +client.agents.tools.create( agent_id=agent.id, name="image_generator", description="Use this tool to generate images based on descriptions.", @@ -337,183 +311,317 @@ await client.agents.tools.create( "provider": "dalle", "method": "generate_image", "setup": { - "api_key": "your_dalle_api_key", + "api_key": "your_openai_api_key", }, }, ) +``` + +### Step 2: Create a Task that generates a story and comic strip + +Let's define a multi-step task to create a story and generate a paneled comic strip based on an input idea: +```python # 📋 Task # Create a task that takes an idea and creates a story and a 4-panel comic strip -task = await client.tasks.create( +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. + +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].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: _ + + # 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: "[output.image.url for output in outputs[2]]" +""" + +task = client.tasks.create( agent_id=agent.id, - 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].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": "_", - }, - }, - }, - }, - # 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.\n\nStory: {{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": "[output.image.url for output in outputs[2]]", - } - }, - ], + **yaml.safe_load(task_yaml) ) ``` -> [!TIP] -> node.js version of this is similar. - -### Step 5: Execute the Task +### Step 3: Execute the Task ```python # 🚀 Execute the task with an input idea -execution = await client.executions.create( +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 -await client.executions.transitions.stream(execution_id=execution.id) +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) ``` -This example demonstrates how to create an agent with a custom tool, define a complex task with multiple steps, and execute it to generate a creative output. +### Step 4: Chat with the Agent - +Start an interactive chat session with the agent: + +```python +session = client.sessions.create(agent_id=agent.id) + +# 💬 Send messages to the agent +while (message := input("Enter a message: ")) != "quit": + response = client.sessions.chat( + session_id=session.id, + message=message, + ) + + print(response) +``` > [!TIP] -> You can find another node.js example [here](example.ts) or python example [here](example.py). +> You can find the full python example [here](example.py). -## Concepts -Julep is built on several key technical components that work together to create powerful AI workflows: +## Node.js Quick Start 🟩 -### Agents -AI-powered entities backed by large language models (LLMs) that execute tasks and interact with users. Agents are the core functional units of Julep. +### Step 1: Create an Agent -```mermaid -graph TD - Agent[Agent] --> LLM[Large Language Model] - Agent --> Tasks[Tasks] - Agent --> Users[Users] - Tasks --> Tools[Tools] +```javascript +import { Julep } from '@julep/sdk'; +import yaml from 'js-yaml'; + +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; +} ``` -### Users -Entities that interact with agents. Users can be associated with sessions and have their own metadata, allowing for personalized interactions. +### Step 2: Create a Task that generates a story and comic strip -```mermaid -graph LR - User[User] --> Sessions[Sessions] - Sessions --> Agents[Agents] - Sessions --> Metadata[Metadata] +```javascript +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; +} ``` -### Sessions -Stateful interactions between agents and users. Sessions maintain context across multiple exchanges and can be configured for different behaviors, including context management and overflow handling. +### Step 3: Execute the Task -```mermaid -graph LR - Sessions[Sessions] --> Agents[Agents] - Sessions --> Users[Users] - Sessions --> ContextManagement[Context Management] - Sessions --> OverflowHandling[Overflow Handling] +```javascript +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; +} ``` -### Tasks -Multi-step, programmatic workflows that agents can execute. Tasks define complex operations and can include various types of steps, such as prompts, tool calls, and conditional logic. +### Step 4: Chat with the Agent -```mermaid -graph TD - Tasks[Tasks] --> Steps[Workflow Steps] - Steps --> Prompt[Prompt] - Steps --> ToolCalls[Tool Calls] - Steps --> ConditionalLogic[Conditional Logic] +```javascript +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); ``` -### Tools -Integrations that extend an agent's capabilities. Tools can be user-defined functions, system tools, or third-party API integrations. They allow agents to perform actions beyond text generation. +> [!TIP] +> You can find the full Node.js example [here](example.js). -```mermaid -graph LR - Tools[Tools] --> UserDefinedFunctions[User-Defined Functions] - Tools --> SystemTools[System Tools] - Tools --> ThirdPartyAPIs[Third-Party APIs] -``` +## Components -### Documents -Text or data objects that can be associated with agents or users. Documents are vectorized and stored in a vector database, enabling semantic search and retrieval during agent interactions. +Julep is made up of the following components: -```mermaid -graph LR - Documents[Documents] --> VectorDatabase[Vector Database] - Documents --> SemanticSearch[Semantic Search] - Documents --> AgentsOrUsers[Agents or Users] -``` +- **Julep Platform**: The Julep platform is a cloud service that runs your workflows. It includes a language for describing workflows, a server for running those workflows, and an SDK for interacting with the platform. +- **Julep SDKs**: Julep SDKs are a set of libraries for building workflows. There are SDKs for Python and JavaScript, with more on the way. +- **Julep API**: The Julep API is a RESTful API that you can use to interact with the Julep platform. + +### 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: + +1. **Your Application Code:** + - You use the Julep SDK in your application to define agents, tasks, and workflows. + - The SDK provides functions and classes that make it easy to set up and manage these components. + +2. **Julep Backend Service:** + - The SDK communicates with the Julep backend over the network. + - The backend handles execution of tasks, maintains session state, stores documents, and orchestrates workflows. + +3. **Integration with Tools and APIs:** + - Within your workflows, you can integrate external tools and services. + - The backend facilitates these integrations, so your agents can, for example, perform web searches, access databases, or call third-party APIs. + +In simpler terms: +- Julep is a platform for building stateful AI agents. +- You use the SDK (like a toolkit) in your code to define what your agents do. +- The backend service (which you can think of as the engine) runs these definitions, manages state, and handles complexity. + +## Concepts -### Executions -Instances of tasks that have been initiated with specific inputs. Executions have their own lifecycle and state machine, allowing for monitoring, management, and resumption of long-running processes. +Julep is built on several key technical components that work together to create powerful AI workflows: ```mermaid -graph LR - Executions[Executions] --> Tasks[Tasks] - Executions --> Lifecycle[Lifecycle] - Executions --> Monitoring[Monitoring] - Executions --> Management[Management] - Executions --> Resumption[Resumption] +graph TD + User[User] --> Session[Session] + Session --> Agent[Agent] + Agent --> Tasks[Tasks] + Agent --> LLM[Large Language Model] + Tasks --> Tools[Tools] + Tasks --> Documents[Documents] + Documents --> VectorDB[Vector Database] + Agent --> Executions[Executions] + + classDef core fill:#f9f,stroke:#333,stroke-width:2px; + class Agent,Tasks,Session core; ``` -For a more detailed explanation of these concepts and their interactions, please refer to our [Concepts Documentation](https://github.com/julep-ai/julep/blob/dev/docs/julep-concepts.md). +- **Agents**: AI-powered entities backed by large language models (LLMs) that execute tasks and interact with users. +- **Users**: Entities that interact with agents through sessions. +- **Sessions**: Stateful interactions between agents and users, maintaining context across multiple exchanges. +- **Tasks**: Multi-step, programmatic workflows that agents can execute, including various types of steps like prompts, tool calls, and conditional logic. +- **Tools**: Integrations that extend an agent's capabilities, including user-defined functions, system tools, or third-party API integrations. +- **Documents**: Text or data objects associated with agents or users, vectorized and stored for semantic search and retrieval. +- **Executions**: Instances of tasks that have been initiated with specific inputs, with their own lifecycle and state machine. + +For a more detailed explanation of these concepts and their interactions, please refer to our [Concepts Documentation](/docs/julep-concepts.md). ## Understanding Tasks @@ -621,14 +729,15 @@ Easily manage and search through documents for your agents: ```python # Upload a document document = client.documents.create( - file="path/to/document.pdf", + title="AI advancements", + content="AI is changing the world...", metadata={"category": "research_paper"} ) # Search documents results = client.documents.search( query="AI advancements", - filter={"category": "research_paper"} + metadata_filter={"category": "research_paper"} ) ``` @@ -645,34 +754,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) - -## Examples and Tutorials - -Discover example projects and tutorials to help you get started and build upon provided examples: - -- [Example Projects](https://github.com/julep-ai/julep/tree/main/examples) -- [Tutorials](https://docs.julep.ai/tutorials) - -## Contributing - -We welcome contributions to the project! Learn how to contribute and our code of conduct: - -- [Contributing Guidelines](https://github.com/julep-ai/julep/blob/main/CONTRIBUTING.md) -- [Code of Conduct](https://github.com/julep-ai/julep/blob/main/CODE_OF_CONDUCT.md) - -## Support and Community - -Join our community to get help, ask questions, and share your ideas: - -- [Discord](https://discord.com/invite/JTSBGRZrzj) -- [GitHub Discussions](https://github.com/julep-ai/julep/discussions) -- [Twitter](https://twitter.com/julep_ai) - -## License - -This project is licensed under the [Apache License 2.0](https://github.com/julep-ai/julep/blob/main/LICENSE). - -## Acknowledgements - -We would like to express our gratitude to all contributors and the open-source community for their valuable resources and contributions. +- [Executions API](https://api.julep.ai/api/docs#tag/executions) \ No newline at end of file