Skip to content

Building AI agents, atomically

Some modification on README.ms

Koichi KAWAMURAb8cc7cb90a9e
diff --git a/README.md b/README.md
index 6bf0b91..1edfe91 100644
--- a/README.md
+++ b/README.md
@@ -95,13 +95,21 @@ We strive to thoroughly document each example, but if something is unclear, plea
Here's a quick snippet demonstrating how easy it is to create a powerful agent with Atomic Agents:
```python
+from pydantic import Field
+from openai import OpenAI
+import instructor
+from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig, BaseAgentInputSchema
+from atomic_agents.lib.base.base_io_schema import BaseIOSchema
+from atomic_agents.lib.components.system_prompt_generator import SystemPromptGenerator
+from atomic_agents.lib.components.agent_memory import AgentMemory
+
# Define a custom output schema
class CustomOutputSchema(BaseIOSchema):
"""
docstring for the custom output schema
"""
chat_message: str = Field(..., description="The chat message from the agent.")
- suggested_questions: List[str] = Field(..., description="Suggested follow-up questions.")
+ suggested_questions: list[str] = Field(..., description="Suggested follow-up questions.")
# Set up the system prompt
system_prompt_generator = SystemPromptGenerator(
@@ -117,22 +125,27 @@ system_prompt_generator = SystemPromptGenerator(
]
)
+# Initialize OpenAI client
+client = instructor.from_openai(OpenAI())
+
# Initialize the agent
agent = BaseAgent[BaseAgentInputSchema, CustomOutputSchema](
config=BaseAgentConfig(
- client=your_openai_client, # Replace with your actual client
+ client=client,
model="gpt-4o-mini",
system_prompt_generator=system_prompt_generator,
memory=AgentMemory(),
)
)
-# Use the agent
-response = agent.run(user_input)
-print(f"Agent: {response.chat_message}")
-print("Suggested questions:")
-for question in response.suggested_questions:
- print(f"- {question}")
+# Example usage
+if __name__ == "__main__":
+ user_input = "Tell me about atomic agents framework"
+ response = agent.run(BaseAgentInputSchema(chat_message=user_input))
+ print(f"Agent: {response.chat_message}")
+ print("Suggested questions:")
+ for question in response.suggested_questions:
+ print(f"- {question}")
```
This snippet showcases how to create a customizable agent that responds to user queries and suggests follow-up questions. For full, runnable examples, please refer to the following files in the `atomic-examples/quickstart/quickstart/` directory:
@@ -269,9 +282,11 @@ from web_search_agent.tools.another_search import AnotherSearchTool
# Update the output schema
query_agent.config.output_schema = AnotherSearchTool.input_schema
```
+
This design pattern simplifies the process of chaining agents and tools, making your AI applications more adaptable and easier to maintain.
## Running the CLI
+
To run the CLI, simply run the following command:
```bash
@@ -293,24 +308,27 @@ uv run atomic
After running this command, you will be presented with a menu allowing you to download tools.
Each tool's has its own:
+
- Input schema
- Output schema
- Usage example
- Dependencies
- Installation instructions
-<img src="./.assets/atomic-cli-tool-menu.png" alt="Atomic CLI tool example" width="600"/>
+![Atomic CLI tool example](./.assets/atomic-cli-tool-menu.png)
The `atomic-assembler` CLI gives you complete control over your tools, avoiding the clutter of unnecessary dependencies. It makes modifying tools straightforward additionally, each tool comes with its own set of tests for reliability.
**But you're not limited to the CLI!** If you prefer, you can directly access the tool folders and manage them manually by simply copying and pasting as needed.
-<img src="./.assets/atomic-cli.png" alt="Atomic CLI menu" width="400"/>
+![Atomic CLI menu](./.assets/atomic-cli.png)
## Provider & Model Compatibility
+
Atomic Agents depends on the [Instructor](https://github.com/jxnl/instructor) package. This means that in all examples where OpenAI is used, any other API supported by Instructor can also be used—such as Ollama, Groq, Mistral, Cohere, Anthropic, Gemini, and more. For a complete list, please refer to the Instructor documentation on its [GitHub page](https://github.com/jxnl/instructor).
## API Documentation
+
API documentation can be found [here](https://brainblend-ai.github.io/atomic-agents/).
## Atomic Forge
@@ -340,6 +358,7 @@ We welcome contributions! Please see the [Developer Guide](/guides/DEV_GUIDE.md)
For full development setup and guidelines, please refer to the [Developer Guide](/guides/DEV_GUIDE.md).
## License
+
This project is licensed under the MIT License—see the [LICENSE](LICENSE) file for details.
## Star History
diff --git a/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py b/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
index 97c6f57..055ec39 100644
--- a/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
+++ b/atomic-examples/quickstart/quickstart/5_custom_system_role_for_reasoning_models.py
@@ -23,8 +23,8 @@ console = Console()
client = instructor.from_openai(openai.OpenAI(api_key=API_KEY))
# System prompt generator setup
-sysyem_prompt_generator = SystemPromptGenerator(
- background=["You are a math genious."],
+system_prompt_generator = SystemPromptGenerator(
+ background=["You are a math genius."],
steps=["Think logically step by step and solve a math problem."],
output_instructions=["Answer in plain English plus formulas."],
)
@@ -33,7 +33,7 @@ agent = BaseAgent[BaseAgentInputSchema, BaseAgentOutputSchema](
config=BaseAgentConfig(
client=client,
model="o3-mini",
- sysyem_prompt_generator=sysyem_prompt_generator,
+ system_prompt_generator=system_prompt_generator,
# It is a convention to use "developer" as the system role for reasoning models from OpenAI such as o1, o3-mini.
# Also these models are often used without a system prompt, which you can do by setting system_role=None
system_role="developer",