Skip to content

Commit

Permalink
Add Mintlify docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bonk1t committed Nov 19, 2024
1 parent aff9add commit 4bec3e7
Show file tree
Hide file tree
Showing 35 changed files with 2,206 additions and 0 deletions.
473 changes: 473 additions & 0 deletions agency-swarm.md

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions docs_new/advanced-topics/asynchronous-execution.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: "Asynchronous Execution"
description: "Enhance the performance of your agency by running agents and tools asynchronously."
icon: "bolt"
---

<Tip>
Asynchronous execution allows agents and tools to operate concurrently, improving overall efficiency.
</Tip>

## Enabling Asynchronous Agents

To enable asynchronous execution for agents, set the `async_mode` parameter to `"threading"` when initializing the agency.

<CodeBlock title="Initialize Agency with Asynchronous Agents" language="python">
agency = Agency(agents=[ceo], async_mode='threading')
</CodeBlock>

**Benefits**:

- Agents operate independently without waiting for others to complete tasks.
- Improved performance in multi-agent setups.

## Enabling Asynchronous Tools

To enable asynchronous execution for tools, set the `async_mode` parameter to `"tools_threading"`.

<CodeBlock title="Initialize Agency with Asynchronous Tools" language="python">
agency = Agency(agents=[ceo], async_mode='tools_threading')
</CodeBlock>

**Benefits**:

- Tools execute concurrently, reducing latency for I/O-bound operations.
- Enhanced responsiveness of agents utilizing tools.

## Considerations

<Warning>
When using asynchronous execution, be mindful of concurrency issues.
</Warning>

- **Concurrency Control**: Ensure thread-safe operations to prevent race conditions. Use thread locks or other synchronization mechanisms if necessary.

- **Resource Management**: Monitor system resources to avoid overconsumption due to multiple threads. Keep an eye on CPU and memory usage.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: "Customizing Prompts and Few-Shot Learning"
description: "Fine-tune agent behavior by customizing prompts and providing few-shot examples."
icon: "magic"
---

Fine-tune agent behavior by customizing prompts and providing few-shot examples.

<Info>
Custom prompts and few-shot learning help your agents understand the desired response style and content, leading to more accurate and tailored outputs.
</Info>

## Custom Prompts

### Modify Instructions

Adjust the `instructions.md` file associated with your agent to change how it responds.

<CodeBlock title="instructions.md" language="markdown">
# Agent Instructions

You are a friendly assistant that helps users with booking flights and hotels.
</CodeBlock>

### Dynamic Prompts

Programmatically alter prompts based on context or user input.

<CodeBlock title="Dynamic Prompt Example" language="python">
base_instructions = "You are an assistant who provides technical support."

additional_context = "Assist the user with troubleshooting network issues."

agent = Agent(
name="SupportAgent",
prompt=f"{base_instructions}\n\n{additional_context}"
)
</CodeBlock>

## Few-Shot Examples

Few-shot examples provide sample interactions to guide agent responses.

### Implementation

<CodeBlock title="Providing Few-Shot Examples" language="python">
```python
examples = [
{"role": "user", "content": "Hi!"},
{"role": "assistant", "content": "Hello! How can I assist you today?"},
{"role": "user", "content": "I need help resetting my password."},
{"role": "assistant", "content": "Sure, I can help with that. Have you tried using the 'Forgot Password' feature?"}
]

agent = Agent(name="Helper", examples=examples)
```
</CodeBlock>

<Note>
These examples help the agent understand the expected conversation flow and response style.
</Note>

## Benefits

<Check>

- **Consistency**: Ensures agents produce consistent and predictable outputs aligned with your desired style.

- **Adaptability**: Tailors agent responses to specific domains, improving user experience.

</Check>
79 changes: 79 additions & 0 deletions docs_new/advanced-topics/open-source-models-support.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: "Open-Source Models Support"
description: "Utilize open-source models to provide flexibility and control over your AI agents."
icon: "code-fork"
---

While OpenAI models are recommended, Agency Swarm supports open-source models through projects that mimic the Assistants API.

<Info>
Utilizing open-source models allows for more flexibility and control over your AI agents.
</Info>

## Supported Projects

<CardGroup>

<Card title="Astra Assistants API" icon="rocket" iconType="solid" href="https://github.com/datastax/astra-assistants-api">
Best option for running open-source models. Supports Assistants API V2.
</Card>

<Card title="Open Assistant API" icon="users" iconType="solid" href="https://github.com/MLT-OSS/open-assistant-api">
Fully local and stable, supports Assistants API V1.
</Card>

</CardGroup>

## Integration Steps

<Steps>

<Step title="Install Required Packages" icon="download" iconType="solid">
Use pip to install necessary packages.

<CodeBlock language="bash">
pip install astra-assistants-api gradio
</CodeBlock>
</Step>

<Step title="Set Up API Clients" icon="cogs" iconType="solid">
Configure your API clients to use the open-source models.

<CodeBlock language="python">
from openai import OpenAI
from astra_assistants import patch
from agency_swarm import set_openai_client

client = patch(OpenAI())
set_openai_client(client)
</CodeBlock>
</Step>

<Step title="Create Agents with Open-Source Models" icon="user-plus" iconType="solid">
Instantiate your agents using the open-source models.

<CodeBlock language="python">
ceo = Agent(name="CEO", model='ollama/llama3')
</CodeBlock>
</Step>

<Step title="Run the Agency" icon="play" iconType="solid">
Start your agency with the configured agents.

<CodeBlock language="python">
agency = Agency([ceo])
agency.run_demo()
</CodeBlock>
</Step>

</Steps>

## Limitations

<Warning>
Be aware of the limitations when using open-source models.
</Warning>

- **Function Calling**: Not supported by most open-source models.
- **Retrieval-Augmented Generation**: Often limited; consider custom implementations.
- **Code Interpreter**: Not supported in current open-source assistants.
56 changes: 56 additions & 0 deletions docs_new/advanced-topics/production-readiness.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Production Readiness"
description: "Prepare your agency for production by enhancing reliability, scalability, and security."
icon: "check-circle-o"
---

<Info>
Ensuring your agency is production-ready involves careful planning and implementation of best practices.
</Info>

## Key Considerations

<AccordionGroup>

<Accordion title="Robust Error Handling" icon="bug" iconType="solid">
Implement comprehensive error handling within agents and tools to gracefully handle unexpected issues.

<Tip>
Use try-except blocks and logging to capture and manage exceptions.
</Tip>
</Accordion>

<Accordion title="Security Measures" icon="shield-alt" iconType="solid">
Secure API keys, enforce access controls, and sanitize inputs to protect against vulnerabilities.

<Warning>
Never hard-code API keys or sensitive information in your code.
</Warning>
</Accordion>

<Accordion title="Monitoring and Logging" icon="eye" iconType="solid">
Use monitoring tools to track performance and detect anomalies. Maintain logs for auditing and debugging.

</Accordion>

<Accordion title="Scalability" icon="arrows-alt" iconType="solid">
Design for horizontal scaling to handle increased loads efficiently.

<Tip>
Consider using cloud services that support auto-scaling features.
</Tip>
</Accordion>

</AccordionGroup>

## Best Practices

<Check>

- **Testing**: Thoroughly test agents and tools under various conditions, including edge cases.

- **Documentation**: Maintain clear documentation for maintenance and onboarding of new team members.

- **Continuous Integration/Continuous Deployment (CI/CD)**: Set up pipelines for automated testing and deployment to streamline updates.

</Check>
50 changes: 50 additions & 0 deletions docs_new/api-reference/api-reference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
title: "API Reference"
description: "Gain a deeper understanding of the core classes and methods available in Agency Swarm."
icon: "book"
---

## Agents

<Frame caption="Agent Class Documentation">
::: agency_swarm.agents.agent
:::
</Frame>

## Agency

<Frame caption="Agency Class Documentation">
::: agency_swarm.agency.agency
:::
</Frame>

## ToolFactory

<Frame caption="ToolFactory Class Documentation">
::: agency_swarm.tools.ToolFactory
:::
</Frame>

## Agents (Agent Class Methods)

<Frame caption="Agent Class Methods Documentation">
```python
::: agency_swarm.agents.agent.Agent
```
</Frame>

## Agency (Agency Class Methods)

<Frame caption="Agency Class Methods Documentation">
```python
::: agency_swarm.agency.agency.Agency
```
</Frame>

## ToolFactory (ToolFactory Class Methods)

<Frame caption="ToolFactory Class Methods Documentation">
```python
::: agency_swarm.tools.ToolFactory
```
</Frame>
Loading

0 comments on commit 4bec3e7

Please sign in to comment.