Skip to content

Commit 671e9b3

Browse files
Documentation improvements
1 parent d954df8 commit 671e9b3

File tree

6 files changed

+486
-740
lines changed

6 files changed

+486
-740
lines changed

docs/api/components.md

+92
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,45 @@
22

33
## Agent Memory
44

5+
The `AgentMemory` class manages conversation history and state for AI agents:
6+
7+
```python
8+
from atomic_agents.lib.components.agent_memory import AgentMemory
9+
from atomic_agents.lib.base.base_io_schema import BaseIOSchema
10+
11+
# Initialize memory with optional max messages
12+
memory = AgentMemory(max_messages=10)
13+
14+
# Add messages with proper schemas
15+
memory.add_message(
16+
role="assistant",
17+
content=BaseIOSchema(...)
18+
)
19+
20+
# Access history
21+
history = memory.get_history()
22+
23+
# Manage turns
24+
memory.initialize_turn() # Start new turn
25+
turn_id = memory.get_current_turn_id()
26+
27+
# Persistence
28+
serialized = memory.dump() # Save to string
29+
memory.load(serialized) # Load from string
30+
31+
# Create copy
32+
new_memory = memory.copy()
33+
```
34+
35+
Key features:
36+
- Message history management with role-based messages
37+
- Turn-based conversation tracking
38+
- Support for multimodal content
39+
- Serialization and deserialization
40+
- Memory size management
41+
- Deep copy functionality
42+
43+
For full API details:
544
```{eval-rst}
645
.. automodule:: atomic_agents.lib.components.agent_memory
746
:members:
@@ -12,6 +51,59 @@
1251

1352
## System Prompt Generator
1453

54+
The `SystemPromptGenerator` creates structured system prompts for AI agents:
55+
56+
```python
57+
from atomic_agents.lib.components.system_prompt_generator import (
58+
SystemPromptGenerator,
59+
SystemPromptContextProviderBase
60+
)
61+
62+
# Create basic generator
63+
generator = SystemPromptGenerator(
64+
background=[
65+
"You are a helpful AI assistant.",
66+
"You specialize in technical support."
67+
],
68+
steps=[
69+
"1. Understand the user's request",
70+
"2. Analyze available information",
71+
"3. Provide clear solutions"
72+
],
73+
output_instructions=[
74+
"Use clear, concise language",
75+
"Include step-by-step instructions",
76+
"Cite relevant documentation"
77+
]
78+
)
79+
80+
# Generate prompt
81+
prompt = generator.generate_prompt()
82+
```
83+
84+
### Context Providers
85+
86+
Create custom context providers by extending `SystemPromptContextProviderBase`:
87+
88+
```python
89+
class CustomContextProvider(SystemPromptContextProviderBase):
90+
def __init__(self, title: str):
91+
super().__init__(title=title)
92+
self.data = {}
93+
94+
def get_info(self) -> str:
95+
return f"Custom context: {self.data}"
96+
97+
# Use with generator
98+
generator = SystemPromptGenerator(
99+
background=["You are a helpful AI assistant."],
100+
context_providers={
101+
"custom": CustomContextProvider("Custom Info")
102+
}
103+
)
104+
```
105+
106+
For full API details:
15107
```{eval-rst}
16108
.. automodule:: atomic_agents.lib.components.system_prompt_generator
17109
:members:

docs/api/index.md

+15-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,22 @@ The agents module provides the base classes for creating AI agents:
2828

2929
### Components
3030

31-
The components module contains building blocks for extending agent functionality:
31+
The components module contains essential building blocks:
3232

33-
- `AgentMemory`: Manages conversation history and context
34-
- `SystemPromptGenerator`: Creates dynamic system prompts
35-
- `SystemPromptContextProvider`: Provides contextual information for prompts
33+
- `AgentMemory`: Manages conversation history and state with support for:
34+
- Message history with role-based messages
35+
- Turn-based conversation tracking
36+
- Multimodal content
37+
- Serialization and persistence
38+
- Memory size management
39+
40+
- `SystemPromptGenerator`: Creates structured system prompts with:
41+
- Background information
42+
- Processing steps
43+
- Output instructions
44+
- Dynamic context through context providers
45+
46+
- `SystemPromptContextProviderBase`: Base class for creating custom context providers that can inject dynamic information into system prompts
3647

3748
[Learn more about components](components.md)
3849

@@ -52,6 +63,4 @@ The utils module provides helper functions and utilities:
5263
For practical examples and guides on using these components, see:
5364

5465
- [Quickstart Guide](../guides/quickstart.md)
55-
- [Basic Concepts](../guides/basic_concepts.md)
5666
- [Tools Guide](../guides/tools.md)
57-
- [Advanced Usage](../guides/advanced_usage.md)

docs/guides/advanced_usage.md

-241
This file was deleted.

0 commit comments

Comments
 (0)