Skip to content

Commit

Permalink
Refactor asset organization and enhance documentation:
Browse files Browse the repository at this point in the history
- Moved asset files from `atomic-agents/.assets/` to `.assets/`.
- Created a new `DEV_GUIDE.md` for contributing instructions, including setup and testing guidelines. (still under construction)
- Updated `README.md` to reflect changes in installation instructions, usage examples, and improved content on the framework's features.
- Revised quickstart examples in `atomic-examples/quickstart/README.md` to clarify setup and execution.
- Refined dependencies in `pyproject.toml` files, ensuring compatibility and removing unnecessary ones.
  • Loading branch information
KennyVaneetvelde committed Oct 13, 2024
1 parent 0645c36 commit 9d38d26
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 46 deletions.
Binary file added .assets/atomic-cli.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
21 changes: 21 additions & 0 deletions DEV_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1. Fork the repository
2. Create a new branch (`git checkout -b feature-branch`)
3. Make your changes
4. Commit your changes (`git commit -m 'Add some feature'`)
5. Push to the branch (`git push origin feature-branch`)
6. Open a pull request

## Formatting and Linting
To format & lint the code before committing, you must run the following two commands:

`black atomic_agents`

`flake8 atomic_agents`


## Testing
To run the tests, run the following command:
`pytest --cov atomic_agents`

To view the coverage report, run the following command:
`coverage html`
121 changes: 86 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,99 @@
# NOTICE:
A NEW VERSION OF ATOMIC AGENTS IS UNDER DEVELOPMENT. THIS README IS OUTDATED.
CHECK BACK SOON FOR AN UPDATE.

# Atomic Agents
<img src="./.assets/logo.png" alt="Atomic Agents" width="600"/>

[![PyPI version](https://badge.fury.io/py/atomic-agents.svg)](https://badge.fury.io/py/atomic-agents)

A versatile framework designed to facilitate the creation and management of intelligent agents, with an optional CLI tool.
The Atomic Agents framework is designed to be modular, extensible, and easy to use. The main goal of the framework is to get rid of redundant complexity, unnecessary abstractions, and hidden assumptions while still providing a flexible and powerful framework for building AI applications through atomicity. The resulting framework provides a set of tools and agents that can be combined to create powerful applications. The framework is built on top of [Instructor](https://github.com/jxnl/instructor) and leverages the power of [Pydantic](https://docs.pydantic.dev/latest/) for data/schema validation and serialization.

<!-- ![alt text](./.assets/architecture_highlevel_overview.png) -->
<img src="./.assets/architecture_highlevel_overview.png" alt="High-level architecture overview of Atomic Agents" width="600"/>
<img src="./.assets/what_is_sent_in_prompt.png" alt="Diagram showing what is sent to the LLM in the prompt" width="600"/>

## Installation
To install Atomic Agents, you can use pip:

```bash
pip install atomic-agents
```

This also installs the CLI *Atomic Assembler* which can be used to download Tools (and soon also Agents and Pipelines).

## Quickstart & Examples
A complete list of examples can be found in the [examples](./atomic-examples/) directory.

We do our best to thoroughly document each example, but if something is unclear, please don't hesitate to open an issue or a pull request in order to improve the documentation.

Here's a quick snippet demonstrating how easy it is to create a powerful agent with Atomic Agents:

```python
# Define a custom output schema
class CustomOutputSchema(BaseIOSchema):
chat_message: str = Field(..., description="The chat message from the agent.")
suggested_questions: List[str] = Field(..., description="Suggested follow-up questions.")

# Set up the system prompt
system_prompt_generator = SystemPromptGenerator(
background=["This assistant is knowledgeable, helpful, and suggests follow-up questions."],
steps=[
"Analyze the user's input to understand the context and intent.",
"Formulate a relevant and informative response.",
"Generate 3 suggested follow-up questions for the user."
],
output_instructions=[
"Provide clear and concise information in response to user queries.",
"Conclude each response with 3 relevant suggested questions for the user."
]
)

# Initialize the agent
agent = BaseAgent(
config=BaseAgentConfig(
client=your_openai_client, # Replace with your actual client
model="gpt-4",
system_prompt_generator=system_prompt_generator,
memory=AgentMemory(),
output_schema=CustomOutputSchema
)
)

# 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}")
```

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:

- [1_basic_chatbot.py](./atomic-examples/quickstart/quickstart/1_basic_chatbot.py): A minimal chatbot example to get you started.
- [2_basic_custom_chatbot.py](./atomic-examples/quickstart/quickstart/2_basic_custom_chatbot.py): A more advanced example with a custom system prompt.
- [3_basic_custom_chatbot_with_custom_schema.py](./atomic-examples/quickstart/quickstart/3_basic_custom_chatbot_with_custom_schema.py): A more advanced example with a custom output schema.
- [4_basic_chatbot_different_providers.py](./atomic-examples/quickstart/quickstart/4_basic_chatbot_different_providers.py): Demonstrates how to use different providers like Ollama or Groq.

These examples provide a great starting point for understanding and using Atomic Agents.

You can install Atomic Agents with different options:
## Running the CLI
To run the CLI simply run the following command:

- Full installation (framework + CLI):
```bash
pip install atomic-agents
```
```bash
atomic
```

- Core framework only:
```bash
pip install atomic-agents[core]
```
After running this command you should be presented with a menu, allowing you to download Tools.
<img src="./.assets/atomic-cli.png" alt="Atomic CLI menu" width="400"/>

- CLI tool only:
```bash
pip install atomic-agents[cli]
```
## 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 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).

## Getting Started
## Contributing
We welcome contributions! Please follow these steps to contribute:

### Prerequisites
- Python 3.10 or later
See the [Developer Guide](./DEV_GUIDE.md) for more information on how to contribute to Atomic Agents.

### Installation
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

1. Either install the Atomic Agents package through pip, or locally from source:
```bash
pip install atomic-agents
```
or
```bash
cd atomic-agents
pip install -e .
```
## Star History

2. Install the Atomic Assembler CLI. This is optional, but it provides a convenient way to grab new Atomic Tools from the [Atomic Forge](atomic-forge):
```bash
pip install atomic-assembler
```
[![Star History Chart](https://api.star-history.com/svg?repos=BrainBlend-AI/atomic-agents&type=Date)](https://star-history.com/#BrainBlend-AI/atomic-agents&Date)
69 changes: 69 additions & 0 deletions atomic-examples/quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Atomic Agents Quickstart Examples

This directory contains quickstart examples for the Atomic Agents project. These examples demonstrate various features and capabilities of the Atomic Agents framework.

## Getting Started

To run these examples:

1. Clone the main Atomic Agents repository:
```
git clone https://github.com/BrainBlend-AI/atomic-agents
```

2. Navigate to the quickstart directory:
```
cd atomic-agents/atomic-examples/quickstart
```

3. Install the dependencies using Poetry:
```
poetry install
```

4. Run the examples using Poetry:
```
poetry run python quickstart/1_basic_chatbot.py
```

## Example Files

### 1. Basic Chatbot (1_basic_chatbot.py)

This example demonstrates a simple chatbot using the Atomic Agents framework. It includes:
- Setting up the OpenAI API client
- Initializing a basic agent with default configurations
- Running a chat loop where the user can interact with the agent

### 2. Custom Chatbot (2_basic_custom_chatbot.py)

This example shows how to create a custom chatbot with:
- A custom system prompt
- Customized agent configuration
- A chat loop with rhyming responses

### 3. Custom Chatbot with Custom Schema (3_basic_custom_chatbot_with_custom_schema.py)

This example demonstrates:
- Creating a custom output schema for the agent
- Implementing suggested follow-up questions in the agent's responses
- Using a custom system prompt and agent configuration

### 4. Chatbot with Different Providers (4_basic_chatbot_different_providers.py)

This example showcases:
- How to use different AI providers (OpenAI, Groq, Ollama)
- Dynamically selecting a provider at runtime
- Adapting the agent configuration based on the chosen provider

## Running the Examples

To run any of the examples, use the following command:

```
poetry run python quickstart/<example_file_name>.py
```

Replace `<example_file_name>` with the name of the example you want to run (e.g., `1_basic_chatbot.py`).

These examples provide a great starting point for understanding and working with the Atomic Agents framework. Feel free to modify and experiment with them to learn more about the capabilities of Atomic Agents.
5 changes: 3 additions & 2 deletions atomic-examples/quickstart/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
atomic-agents = {path = "../..", develop = true}
groq = "^0.11.0"
mistralai = "^1.1.0"
openai = ">=1.35.12,<2.0.0"
groq = ">=0.11.0,<1.0.0"
mistralai = ">=1.1.0,<2.0.0"


[build-system]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ def setup_client(provider):
from groq import Groq

api_key = os.getenv("GROQ_API_KEY")
client = instructor.from_groq(Groq(api_key=api_key), mode=instructor.Mode.TOOLS)
client = instructor.from_groq(Groq(api_key=api_key), mode=instructor.Mode.JSON)
model = "mixtral-8x7b-32768"
elif provider == "mistral":
from mistralai.client import MistralClient

api_key = os.getenv("MISTRAL_API_KEY")
client = instructor.from_mistral(MistralClient(api_key=api_key), model="mistral-large-latest")
model = "mistral-large-latest"
elif provider == "ollama":
from openai import OpenAI as OllamaClient

Expand All @@ -52,7 +46,7 @@ def setup_client(provider):


# Prompt the user to choose a provider
provider = console.input("[bold yellow]Choose a provider (openai/groq/mistral/ollama): [/bold yellow]").lower()
provider = console.input("[bold yellow]Choose a provider (openai/groq/ollama): [/bold yellow]").lower()

# Set up the client and model based on the chosen provider
client, model = setup_client(provider)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ packages = [
[tool.poetry.dependencies]
python = ">=3.11,<4.0"
instructor = ">=1.3.4,<2.0.0"
openai = ">=1.35.12,<2.0.0"
pydantic = ">=2.8.0,<3.0.0"
rich = ">=13.7.1,<14.0.0"
gitpython = ">=3.1.43,<4.0.0"
Expand All @@ -29,6 +28,7 @@ python-dotenv = "^1.0.1"
[tool.poetry.group.dev.dependencies]
black = ">=24.8.0,<25.0.0"
flake8 = ">=7.1.1,<8.0.0"
openai = ">=1.35.12,<2.0.0"
pytest = ">=8.3.3,<9.0.0"
pytest-cov = ">=5.0.0,<6.0.0"

Expand Down

0 comments on commit 9d38d26

Please sign in to comment.