Skip to content

Building AI agents, atomically

Update documentation

KennyVaneetveldec4aba9df6f83
diff --git a/docs/api/atomic_agents/agents/tool_interface_agent.md b/docs/api/atomic_agents/agents/tool_interface_agent.md
index f844886..3398ed0 100644
--- a/docs/api/atomic_agents/agents/tool_interface_agent.md
+++ b/docs/api/atomic_agents/agents/tool_interface_agent.md
@@ -54,7 +54,7 @@ class ToolInterfaceAgent(BaseChatAgent):
### ToolInterfaceAgent()._get_and_handle_response
-[Show source in tool_interface_agent.py:86](../../../../atomic_agents/agents/tool_interface_agent.py#L86)
+[Show source in tool_interface_agent.py:84](../../../../atomic_agents/agents/tool_interface_agent.py#L84)
Handles obtaining and processing the response from the tool.
diff --git a/docs/api/atomic_agents/lib/components/chat_memory.md b/docs/api/atomic_agents/lib/components/chat_memory.md
index f801a8f..72db5cc 100644
--- a/docs/api/atomic_agents/lib/components/chat_memory.md
+++ b/docs/api/atomic_agents/lib/components/chat_memory.md
@@ -4,43 +4,80 @@
> Auto-generated documentation for [atomic_agents.lib.components.chat_memory](../../../../../atomic_agents/lib/components/chat_memory.py) module.
+#### Attributes
+
+- `memory` - Create a ChatMemory with a maximum of 5 messages: ChatMemory(max_messages=5)
+
+- `content` - Test Case 1: Text()
+
+- `content` - Test Case 2: Text()
+
+- `content` - Test Case 3: Text()
+
+- `content` - Test Case 4: Text()
+
+- `content` - Test Case 5: Text()
+
+- `content` - Test Case 6: Text()
+
+- `content` - Test Case 7: Text()
+
+- `content` - Test Case 8: Text()
+
+
- [ChatMemory](#chatmemory)
- [ChatMemory](#chatmemory-1)
+ - [ChatMemory()._manage_overflow](#chatmemory()_manage_overflow)
- [ChatMemory().add_message](#chatmemory()add_message)
- [ChatMemory().copy](#chatmemory()copy)
- [ChatMemory().dump](#chatmemory()dump)
- [ChatMemory().get_history](#chatmemory()get_history)
+ - [ChatMemory().get_message_count](#chatmemory()get_message_count)
- [ChatMemory().load](#chatmemory()load)
- [Message](#message)
+ - [print_panel](#print_panel)
## ChatMemory
-[Show source in chat_memory.py:20](../../../../../atomic_agents/lib/components/chat_memory.py#L20)
+[Show source in chat_memory.py:19](../../../../../atomic_agents/lib/components/chat_memory.py#L19)
Manages the chat history for an AI agent.
#### Attributes
- `history` *List[Message]* - A list of messages representing the chat history.
+- `max_messages` *Optional[int]* - Maximum number of turns to keep in history.
#### Signature
```python
class ChatMemory:
- def __init__(self): ...
+ def __init__(self, max_messages: Optional[int] = None): ...
+```
+
+### ChatMemory()._manage_overflow
+
+[Show source in chat_memory.py:61](../../../../../atomic_agents/lib/components/chat_memory.py#L61)
+
+Manages the chat history overflow based on max_messages constraint.
+
+#### Signature
+
+```python
+def _manage_overflow(self) -> None: ...
```
### ChatMemory().add_message
-[Show source in chat_memory.py:34](../../../../../atomic_agents/lib/components/chat_memory.py#L34)
+[Show source in chat_memory.py:38](../../../../../atomic_agents/lib/components/chat_memory.py#L38)
-Adds a message to the chat history.
+Adds a message to the chat history and manages overflow.
#### Arguments
- `role` *str* - The role of the message sender.
-- `content` *str* - The content of the message.
-- `tool_message` *Optional[Dict]* - Optional tool message to be included.
+content (Union[str, Dict]): The content of the message.
+- [tool_message](#chatmemory) *Optional[Dict]* - Optional tool message to be included.
- `tool_id` *Optional[str]* - Optional unique identifier for the tool call.
#### Signature
@@ -49,7 +86,7 @@ Adds a message to the chat history.
def add_message(
self,
role: str,
- content: str,
+ content: Union[str, Dict],
tool_message: Optional[Dict] = None,
tool_id: Optional[str] = None,
) -> None: ...
@@ -57,7 +94,7 @@ def add_message(
### ChatMemory().copy
-[Show source in chat_memory.py:82](../../../../../atomic_agents/lib/components/chat_memory.py#L82)
+[Show source in chat_memory.py:109](../../../../../atomic_agents/lib/components/chat_memory.py#L109)
Creates a copy of the chat memory.
@@ -73,7 +110,7 @@ def copy(self) -> "ChatMemory": ...
### ChatMemory().dump
-[Show source in chat_memory.py:64](../../../../../atomic_agents/lib/components/chat_memory.py#L64)
+[Show source in chat_memory.py:78](../../../../../atomic_agents/lib/components/chat_memory.py#L78)
Converts the chat history to a list of dictionaries.
@@ -89,7 +126,7 @@ def dump(self) -> List[Dict]: ...
### ChatMemory().get_history
-[Show source in chat_memory.py:55](../../../../../atomic_agents/lib/components/chat_memory.py#L55)
+[Show source in chat_memory.py:69](../../../../../atomic_agents/lib/components/chat_memory.py#L69)
Retrieves the chat history.
@@ -107,11 +144,27 @@ def get_history(self) -> List[Message]: ...
- [Message](#message)
+### ChatMemory().get_message_count
+
+[Show source in chat_memory.py:121](../../../../../atomic_agents/lib/components/chat_memory.py#L121)
+
+Returns the number of messages in the chat history.
+
+#### Returns
+
+- `int` - The number of messages.
+
+#### Signature
+
+```python
+def get_message_count(self) -> int: ...
+```
+
### ChatMemory().load
-[Show source in chat_memory.py:73](../../../../../atomic_agents/lib/components/chat_memory.py#L73)
+[Show source in chat_memory.py:87](../../../../../atomic_agents/lib/components/chat_memory.py#L87)
-Loads the chat history from a list of dictionaries.
+Loads the chat history from a list of dictionaries using Pydantic's parsing.
#### Arguments
@@ -127,7 +180,7 @@ def load(self, dict_list: List[Dict]) -> None: ...
## Message
-[Show source in chat_memory.py:5](../../../../../atomic_agents/lib/components/chat_memory.py#L5)
+[Show source in chat_memory.py:4](../../../../../atomic_agents/lib/components/chat_memory.py#L4)
Represents a message in the chat history.
@@ -142,4 +195,16 @@ content (Union[str, Dict]): The content of the message.
```python
class Message(BaseModel): ...
+```
+
+
+
+## print_panel
+
+[Show source in chat_memory.py:139](../../../../../atomic_agents/lib/components/chat_memory.py#L139)
+
+#### Signature
+
+```python
+def print_panel(title, content): ...
```
\ No newline at end of file
diff --git a/docs/api/atomic_agents/lib/components/system_prompt_generator.md b/docs/api/atomic_agents/lib/components/system_prompt_generator.md
index 712ac2b..7f3c3b1 100644
--- a/docs/api/atomic_agents/lib/components/system_prompt_generator.md
+++ b/docs/api/atomic_agents/lib/components/system_prompt_generator.md
@@ -17,13 +17,13 @@
## CurrentDateProvider
-[Show source in system_prompt_generator.py:61](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L61)
+[Show source in system_prompt_generator.py:64](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L64)
#### Signature
```python
class CurrentDateProvider(SystemPromptContextProviderBase):
- def __init__(self, format: str = "%Y-%m-%d %H:%M:%S", **kwargs): ...
+ def __init__(self, title, format: str = "%Y-%m-%d %H:%M:%S"): ...
```
#### See also
@@ -32,7 +32,7 @@ class CurrentDateProvider(SystemPromptContextProviderBase):
### CurrentDateProvider().get_info
-[Show source in system_prompt_generator.py:66](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L66)
+[Show source in system_prompt_generator.py:69](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L69)
#### Signature
@@ -44,7 +44,7 @@ def get_info(self) -> str: ...
## LoremIpsumProvider
-[Show source in system_prompt_generator.py:69](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L69)
+[Show source in system_prompt_generator.py:72](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L72)
#### Signature
@@ -58,7 +58,7 @@ class LoremIpsumProvider(SystemPromptContextProviderBase): ...
### LoremIpsumProvider().get_info
-[Show source in system_prompt_generator.py:70](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L70)
+[Show source in system_prompt_generator.py:73](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L73)
#### Signature
@@ -94,7 +94,7 @@ def get_info(self) -> str: ...
## SystemPromptGenerator
-[Show source in system_prompt_generator.py:21](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L21)
+[Show source in system_prompt_generator.py:24](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L24)
#### Signature
@@ -109,7 +109,7 @@ class SystemPromptGenerator:
### SystemPromptGenerator().generate_prompt
-[Show source in system_prompt_generator.py:35](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L35)
+[Show source in system_prompt_generator.py:38](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L38)
#### Signature
@@ -121,7 +121,7 @@ def generate_prompt(self) -> str: ...
## SystemPromptInfo
-[Show source in system_prompt_generator.py:15](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L15)
+[Show source in system_prompt_generator.py:18](../../../../../atomic_agents/lib/components/system_prompt_generator.py#L18)
#### Signature
diff --git a/docs/api/atomic_agents/lib/tools/base.md b/docs/api/atomic_agents/lib/tools/base.md
index cf55d09..4f08020 100644
--- a/docs/api/atomic_agents/lib/tools/base.md
+++ b/docs/api/atomic_agents/lib/tools/base.md
@@ -11,14 +11,14 @@
## BaseTool
-[Show source in base.py:9](../../../../../atomic_agents/lib/tools/base.py#L9)
+[Show source in base.py:11](../../../../../atomic_agents/lib/tools/base.py#L11)
Base class for all tools in the Atomic Agents framework.
#### Attributes
-- `input_schema` *Type[BaseModel]* - The schema for the input data.
-- `output_schema` *Type[BaseModel]* - The schema for the output data.
+- `input_schema` *Type[BaseAgentIO]* - The schema for the input data.
+- `output_schema` *Type[BaseAgentIO]* - The schema for the output data.
- `tool_name` *str* - The name of the tool, derived from the input schema's title.
- `tool_description` *str* - The description of the tool, derived from the input schema's description or overridden by the user.
@@ -35,17 +35,17 @@ class BaseTool:
### BaseTool().run
-[Show source in base.py:33](../../../../../atomic_agents/lib/tools/base.py#L33)
+[Show source in base.py:35](../../../../../atomic_agents/lib/tools/base.py#L35)
Runs the tool with the given parameters. This method should be implemented by subclasses.
#### Arguments
-- `params` *BaseModel* - The input parameters for the tool, adhering to the input schema.
+- `params` *BaseAgentIO* - The input parameters for the tool, adhering to the input schema.
#### Returns
-- `BaseModel` - The output of the tool, adhering to the output schema.
+- `BaseAgentIO` - The output of the tool, adhering to the output schema.
#### Raises
@@ -54,14 +54,18 @@ Runs the tool with the given parameters. This method should be implemented by su
#### Signature
```python
-def run(self, params: Type[BaseModel]) -> BaseModel: ...
+def run(self, params: Type[BaseAgentIO]) -> BaseAgentIO: ...
```
+#### See also
+
+- [BaseAgentIO](../../agents/base_chat_agent.md#baseagentio)
+
## BaseToolConfig
-[Show source in base.py:5](../../../../../atomic_agents/lib/tools/base.py#L5)
+[Show source in base.py:7](../../../../../atomic_agents/lib/tools/base.py#L7)
#### Signature
diff --git a/docs/api/atomic_agents/lib/tools/searx.md b/docs/api/atomic_agents/lib/tools/searx.md
deleted file mode 100644
index c921c43..0000000
--- a/docs/api/atomic_agents/lib/tools/searx.md
+++ /dev/null
@@ -1,113 +0,0 @@
-# Searx
-
-[Atomic_agents Index](../../../README.md#atomic_agents-index) / [Atomic Agents](../../index.md#atomic-agents) / [Lib](../index.md#lib) / [Tools](./index.md#tools) / Searx
-
-> Auto-generated documentation for [atomic_agents.lib.tools.searx](../../../../atomic_agents/lib/tools/searx.py) module.
-
-#### Attributes
-
-- `client` - Initialize the client outside: instructor.from_openai(openai.OpenAI(api_key=os.getenv('OPENAI_API_KEY'), base_url=os.getenv('OPENAI_BASE_URL')))
-
-- `result` - Extract structured data from natural language: client.chat.completions.create(model='gpt-3.5-turbo', response_model=SearxNGSearchTool.input_schema, messages=[{'role': 'user', 'content': 'Search for the latest PC gaming news of May 2024 using 3 different queries.'}])
-
-- `output` - Print the result: SearxNGSearchTool(max_results=15).run(result)
-
-
-- [Searx](#searx)
- - [SearxNGSearchResultSchema](#searxngsearchresultschema)
- - [SearxNGSearchTool](#searxngsearchtool)
- - [SearxNGSearchTool().run](#searxngsearchtool()run)
- - [SearxNGSearchToolOutputSchema](#searxngsearchtooloutputschema)
- - [SearxNGSearchToolSchema](#searxngsearchtoolschema)
-
-## SearxNGSearchResultSchema
-
-[Show source in searx.py:29](../../../../atomic_agents/lib/tools/searx.py#L29)
-
-#### Signature
-
-```python
-class SearxNGSearchResultSchema(BaseModel): ...
-```
-
-
-
-## SearxNGSearchTool
-
-[Show source in searx.py:41](../../../../atomic_agents/lib/tools/searx.py#L41)
-
-Tool for performing searches on SearxNG based on the provided queries and category.
-
-#### Attributes
-
-- `input_schema` *SearxNGSearchToolSchema* - The schema for the input data.
-- `output_schema` *SearxNGSearchToolOutputSchema* - The schema for the output data.
-- `max_results` *int* - The maximum number of search results to return.
-
-#### Signature
-
-```python
-class SearxNGSearchTool(BaseTool):
- def __init__(self, max_results: int = 10, **kwargs): ...
-```
-
-#### See also
-
-- [BaseTool](./base.md#basetool)
-
-### SearxNGSearchTool().run
-
-[Show source in searx.py:65](../../../../atomic_agents/lib/tools/searx.py#L65)
-
-Runs the SearxNGSearchTool with the given parameters.
-
-#### Arguments
-
-- `params` *SearxNGSearchToolSchema* - The input parameters for the tool, adhering to the input schema.
-- `max_results` *Optional[int]* - The maximum number of search results to return.
-
-#### Returns
-
-- [SearxNGSearchToolOutputSchema](#searxngsearchtooloutputschema) - The output of the tool, adhering to the output schema.
-
-#### Raises
-
-- `ValueError` - If the SEARXNG_BASE_URL environment variable is not set.
-- `Exception` - If the request to SearxNG fails.
-
-#### Signature
-
-```python
-def run(
- self, params: SearxNGSearchToolSchema, max_results: Optional[int] = None
-) -> SearxNGSearchToolOutputSchema: ...
-```
-
-#### See also
-
-- [SearxNGSearchToolOutputSchema](#searxngsearchtooloutputschema)
-- [SearxNGSearchToolSchema](#searxngsearchtoolschema)
-
-
-
-## SearxNGSearchToolOutputSchema
-
-[Show source in searx.py:35](../../../../atomic_agents/lib/tools/searx.py#L35)
-
-#### Signature
-
-```python
-class SearxNGSearchToolOutputSchema(BaseModel): ...
-```
-
-
-
-## SearxNGSearchToolSchema
-
-[Show source in searx.py:14](../../../../atomic_agents/lib/tools/searx.py#L14)
-
-#### Signature
-
-```python
-class SearxNGSearchToolSchema(BaseModel): ...
-```
\ No newline at end of file
diff --git a/docs/api/atomic_agents/lib/tools/web_scraping_tool.md b/docs/api/atomic_agents/lib/tools/web_scraping_tool.md
deleted file mode 100644
index 21ff4b3..0000000
--- a/docs/api/atomic_agents/lib/tools/web_scraping_tool.md
+++ /dev/null
@@ -1,108 +0,0 @@
-# Web Scraping Tool
-
-[Atomic_agents Index](../../../README.md#atomic_agents-index) / [Atomic Agents](../../index.md#atomic-agents) / [Lib](../index.md#lib) / [Tools](./index.md#tools) / Web Scraping Tool
-
-> Auto-generated documentation for [atomic_agents.lib.tools.web_scraping_tool](../../../../../atomic_agents/lib/tools/web_scraping_tool.py) module.
-
-#### Attributes
-
-- `client` - Initialize the client outside: instructor.from_openai(openai.OpenAI(api_key=os.getenv('OPENAI_API_KEY'), base_url=os.getenv('OPENAI_BASE_URL')))
-
-- `result` - Extract from webpage: client.chat.completions.create(model='gpt-3.5-turbo', response_model=ContentScrapingTool.input_schema, messages=[{'role': 'user', 'content': 'Scrape the content of https://example.com'}])
-
-- `output` - Print the result: ContentScrapingTool().run(result)
-
-- `result` - Extract from PDF: client.chat.completions.create(model='gpt-3.5-turbo', response_model=ContentScrapingTool.input_schema, messages=[{'role': 'user', 'content': 'Scrape the content of https://pdfobject.com/pdf/sample.pdf'}])
-
-- `output` - Print the result: ContentScrapingTool().run(result)
-
-
-- [Web Scraping Tool](#web-scraping-tool)
- - [ContentScrapingResultSchema](#contentscrapingresultschema)
- - [ContentScrapingTool](#contentscrapingtool)
- - [ContentScrapingTool().run](#contentscrapingtool()run)
- - [ContentScrapingToolOutputSchema](#contentscrapingtooloutputschema)
- - [ContentScrapingToolSchema](#contentscrapingtoolschema)
-
-## ContentScrapingResultSchema
-
-[Show source in web_scraping_tool.py:30](../../../../../atomic_agents/lib/tools/web_scraping_tool.py#L30)
-
-#### Signature
-
-```python
-class ContentScrapingResultSchema(BaseModel): ...
-```
-
-
-
-## ContentScrapingTool
-
-[Show source in web_scraping_tool.py:40](../../../../../atomic_agents/lib/tools/web_scraping_tool.py#L40)
-
-Tool for scraping web pages or PDFs and converting content to markdown.
-
-#### Attributes
-
-- `input_schema` *ContentScrapingToolSchema* - The schema for the input data.
-- `output_schema` *ContentScrapingToolOutputSchema* - The schema for the output data.
-
-#### Signature
-
-```python
-class ContentScrapingTool(BaseTool):
- def __init__(self, **kwargs): ...
-```
-
-#### See also
-
-- [BaseTool](./base.md#basetool)
-
-### ContentScrapingTool().run
-
-[Show source in web_scraping_tool.py:61](../../../../../atomic_agents/lib/tools/web_scraping_tool.py#L61)
-
-Runs the ContentScrapingTool with the given parameters.
-
-#### Arguments
-
-- `params` *ContentScrapingToolSchema* - The input parameters for the tool, adhering to the input schema.
-
-#### Returns
-
-- [ContentScrapingToolOutputSchema](#contentscrapingtooloutputschema) - The output of the tool, adhering to the output schema.
-
-#### Signature
-
-```python
-def run(self, params: ContentScrapingToolSchema) -> ContentScrapingToolOutputSchema: ...
-```
-
-#### See also
-
-- [ContentScrapingToolOutputSchema](#contentscrapingtooloutputschema)
-- [ContentScrapingToolSchema](#contentscrapingtoolschema)
-
-
-
-## ContentScrapingToolOutputSchema
-
-[Show source in web_scraping_tool.py:34](../../../../../atomic_agents/lib/tools/web_scraping_tool.py#L34)
-
-#### Signature
-
-```python
-class ContentScrapingToolOutputSchema(BaseModel): ...
-```
-
-
-
-## ContentScrapingToolSchema
-
-[Show source in web_scraping_tool.py:16](../../../../../atomic_agents/lib/tools/web_scraping_tool.py#L16)
-
-#### Signature
-
-```python
-class ContentScrapingToolSchema(BaseModel): ...
-```
\ No newline at end of file