Overview

Understanding Julep’s core concepts is essential for building effective AI applications. This guide covers the fundamental components and how they work together.

Agents

Agents are AI-powered entities that can perform tasks and interact with users. They are the central building blocks of Julep applications.

agent = client.agents.create(
    name="Customer Service Agent",
    model="claude-3.5-sonnet",
    about="An AI assistant that helps with customer inquiries"
)

Key aspects of agents:

  • Identity: Each agent has a name and description that defines its role
  • Model: The underlying language model (e.g., Claude, GPT-4)
  • Memory: Ability to maintain context across interactions
  • Tools: Access to various capabilities through integrated tools

Tasks

Tasks are multi-step workflows that agents can execute. They define a sequence of actions to achieve a specific goal.

name: Process Customer Inquiry
description: Handle a customer question and provide a response

main:
  - prompt:
      - role: system
        content: "You are a customer service agent."
      - role: user
        content: "{{inputs.question}}"
  
  - tool: search_knowledge_base
    arguments:
      query: "{{_.content}}"
  
  - prompt:
      - role: system
        content: "Use this information to answer: {{_.search_results}}"
      - role: user
        content: "{{inputs.question}}"

Key aspects of tasks:

  • Structure: Defined sequence of steps
  • Steps Types: Various actions like prompts, tool calls, and control flow
  • Context: Access to inputs and previous step results
  • Tools: Integration with external services and APIs

Sessions

Sessions maintain the state and context of interactions between users and agents.

session = client.sessions.create(
    agent_id=agent.id,
    user_id=user.id,
    context_overflow="adaptive"
)

response = client.sessions.chat(
    session_id=session.id,
    messages=[{"role": "user", "content": "Hello!"}]
)

Key aspects of sessions:

  • State Management: Maintains conversation history
  • Context: Preserves relevant information across interactions
  • Memory: Handles long-term and working memory
  • User Association: Links conversations to specific users

Tools

Tools extend an agent’s capabilities by providing access to external functionality.

tools:
  - name: search_knowledge_base
    type: integration
    integration:
      provider: elasticsearch
      setup:
        endpoint: "https://search.example.com"
        index: "knowledge_base"

Types of tools:

  1. User-defined Functions: Custom functions you implement
  2. System Tools: Built-in Julep API operations
  3. Integrations: Pre-built third-party service connections
  4. API Calls: Direct external API interactions

Executions

Executions are instances of tasks being run with specific inputs.

execution = client.executions.create(
    task_id=task.id,
    input={"question": "How do I reset my password?"}
)

# Monitor execution status
while execution.status not in ['succeeded', 'failed']:
    execution = client.executions.get(execution.id)

Key aspects of executions:

  • State: Tracks progress and status
  • Input/Output: Manages data flow
  • History: Records step-by-step execution
  • Error Handling: Manages failures and retries

Documents

Documents store information that agents can reference during tasks.

document = client.agents.docs.create(
    agent_id=agent.id,
    title="Product Manual",
    content="Detailed product information...",
    metadata={"category": "documentation"}
)

# Search documents
results = client.agents.docs.search(
    agent_id=agent.id,
    text="password reset",
    metadata_filter={"category": "documentation"}
)

Key aspects of documents:

  • Storage: Persistent knowledge base
  • Search: Semantic search capabilities
  • Metadata: Additional context and categorization
  • Versioning: Document history and updates

Putting It All Together

Here’s how these concepts work together in a typical Julep application:

  1. Create an Agent with specific capabilities
  2. Define Tasks the agent can perform
  3. Use Tools to extend functionality
  4. Maintain context with Sessions
  5. Store knowledge in Documents
  6. Run Executions to complete tasks

Next Steps

Now that you understand the core concepts, you can: