Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(documentation): Init #984

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion agents-api/agents_api/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def get_handler(system: SystemDef) -> Callable:
from ..models.docs.list_docs import list_docs as list_docs_query
from ..models.entry.get_history import get_history as get_history_query
from ..models.session.create_session import create_session as create_session_query
from ..models.session.delete_session import delete_session as delete_session_query
from ..models.session.get_session import get_session as get_session_query
from ..models.session.list_sessions import list_sessions as list_sessions_query
from ..models.session.update_session import update_session as update_session_query
Expand Down
8 changes: 4 additions & 4 deletions agents-api/agents_api/metrics/counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
INF,
)
counter = Counter(
f"db_query_counter",
f"Number of db calls",
"db_query_counter",
"Number of db calls",
labelnames=labelnames,
)
summary = Summary(
f"db_query_latency_summary",
"db_query_latency_summary",
"Database query latency summary",
labelnames=labelnames,
)
hist = Histogram(
f"db_query_latency_hist",
"db_query_latency_hist",
"Database query latency histogram",
labelnames=labelnames,
buckets=buckets,
Expand Down
3 changes: 1 addition & 2 deletions agents-api/agents_api/routers/healthz/check_health.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from uuid import UUID

from ...autogen.openapi_model import Agent, ListResponse
from ...models.agent.list_agents import list_agents as list_agents_query
from .router import router

Expand All @@ -10,7 +9,7 @@
async def check_health() -> dict:
try:
# Check if the database is reachable
agents = list_agents_query(
list_agents_query(
developer_id=UUID("00000000-0000-0000-0000-000000000000"),
)
except Exception as e:
Expand Down
20 changes: 20 additions & 0 deletions documentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Julep Mintlify Documentation

## Development

Install the [Mintlify CLI](https://www.npmjs.com/package/mintlify) to preview the documentation changes locally. To install, use the following command

```
npm i -g mintlify
```

Run the following command at the root of your documentation (where mint.json is)

```
mintlify dev
```

### Troubleshooting

- Mintlify dev isn't running - Run `mintlify install` it'll re-install dependencies.
- Page loads as a 404 - Make sure you are running in a folder with `mint.json`
51 changes: 51 additions & 0 deletions documentation/api-reference/introduction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Introduction
description: 'Introduction to the Julep REST API'
---

<CardGroup cols={2}>
<Card
title="Agent Endpoints"
icon="robot"
href="/api-reference/agents/create"
>
Create, update, and manage AI agents
</Card>
<Card
title="Task Endpoints"
icon="list-check"
href="/api-reference/tasks/create"
>
Create and execute AI tasks and workflows
</Card>
<Card
title="Session Endpoints"
icon="comments"
href="/api-reference/sessions/create"
>
Manage conversation sessions and state
</Card>
<Card
title="Tool Endpoints"
icon="plug"
href="/api-reference/tools/register"
>
Register and manage agent tools
</Card>
</CardGroup>

## Authentication

<Note>
Authentication is done via API keys.
</Note>

API keys are used to authenticate requests to the Julep API. They can be created in the [Julep dashboard](https://dashboard.julep.ai).

To create an API key, go to the Julep dashboard and navigate to the "API Keys" section.

To use an API key, include it in the `Authorization` header of your request.

```
Authorization: Bearer YOUR_API_KEY
```
195 changes: 195 additions & 0 deletions documentation/building-blocks/agents/agent-memory.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
title: 'Agent Memory'
description: 'Understanding how agents maintain state and context across interactions'
---

## Overview

Agent memory in Julep allows AI agents to maintain state and context across multiple interactions. This enables more coherent and contextually aware conversations and task executions.

## Types of Memory

Julep provides several types of memory for agents:

### 1. Session Memory

Session memory persists throughout a single conversation session:

```python Python
# Create a session with memory
session = client.sessions.create(
agent_id=agent.id,
user_id=user.id,
context_overflow="adaptive" # Memory management strategy
)
```

### 2. Long-term Memory

Long-term memory persists across sessions and is stored in the agent's document store:

```python Python
# Store information in long-term memory
document = client.agents.docs.create(
agent_id=agent.id,
title="User Preferences",
content="User prefers dark mode and concise responses",
metadata={"type": "preferences"}
)
```

### 3. Working Memory

Working memory is available during task execution:

```yaml
main:
- evaluate:
remembered_value: "some_value"

- prompt:
- role: user
content: "Use the remembered value: {{_.remembered_value}}"
```

## Memory Management

### Context Window Management

Julep offers different strategies for managing context windows:

1. **Fixed**: Maintains a fixed number of messages
2. **Adaptive**: Dynamically adjusts based on token usage
3. **Summary**: Periodically summarizes older context

```python Python
session = client.sessions.create(
agent_id=agent.id,
context_overflow="adaptive",
max_messages=50 # Optional: limit number of messages
)
```

### Document Store

The document store serves as long-term memory:

```python Python
# Store a document
doc = client.agents.docs.create(
agent_id=agent.id,
title="Meeting Notes",
content="Important points from the meeting...",
metadata={"date": "2024-03-24"}
)

# Search stored documents
results = client.agents.docs.search(
agent_id=agent.id,
text="meeting points",
metadata_filter={"date": "2024-03-24"}
)
```

## Memory Access in Tasks

Tasks can access different types of memory:

```yaml
main:
# Access session context
- prompt:
- role: system
content: "Previous context: {{session.context}}"

# Search long-term memory
- tool: search_documents
arguments:
query: "user preferences"

# Use working memory
- evaluate:
stored_value: "important_data"
- prompt:
- role: user
content: "Use the stored value: {{_.stored_value}}"
```

## Best Practices

1. **Memory Organization**
- Use clear document titles and metadata
- Organize documents by type and purpose
- Regularly clean up outdated information

2. **Context Management**
- Choose appropriate context overflow strategies
- Monitor token usage in sessions
- Use summaries for long conversations

3. **Memory Usage**
- Store important information in long-term memory
- Use working memory for temporary data
- Leverage session memory for conversation context

## Example: Complex Memory Usage

Here's an example combining different types of memory:

```python Python
# Create a session with memory management
session = client.sessions.create(
agent_id=agent.id,
user_id=user.id,
context_overflow="adaptive",
metadata={
"preferences": {
"language": "en",
"style": "formal"
}
}
)

# Store long-term information
client.agents.docs.create(
agent_id=agent.id,
title="User Profile",
content="Detailed user preferences and history...",
metadata={
"type": "profile",
"last_updated": "2024-03-24"
}
)

# Create a task that uses multiple memory types
task = client.tasks.create(
agent_id=agent.id,
yaml="""
main:
# Access session context
- prompt:
- role: system
content: "Session context: {{session.context}}"

# Search long-term memory
- tool: search_documents
arguments:
query: "user profile"

# Store in working memory
- evaluate:
profile_data: _.documents[0].content

# Use the combined information
- prompt:
- role: user
content: "Use profile data: {{_.profile_data}}"
"""
)
```

## Next Steps

1. [Learn about agent tools](/building-blocks/agents/agent-tools)
2. [Understand task basics](/building-blocks/tasks/task-basics)
3. [Explore session management](/building-blocks/sessions/session-management)
Loading
Loading