Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bonk1t committed Nov 29, 2024
1 parent 089ff64 commit 4fcb35a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 141 deletions.
12 changes: 12 additions & 0 deletions docs_new/core-entities/agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ As the CEO, you are responsible for overseeing all operations.
3. Monitor progress and report back.
```

<Check>

**Best Practices for Writing Instructions:**

- **Clarity**: Be explicit about expectations and responsibilities to avoid ambiguity
- **Alignment**: Ensure instructions align with the overall agency objectives
- **Collaboration**: Define clear protocols for how the agent should interact with other agents
- **Decision-making**: Include specific criteria for how the agent should make decisions
- **Process Details**: Break down complex workflows into clear, actionable steps

</Check>

</Step>

<Step title="4. Initialize the Agent">
Expand Down
83 changes: 64 additions & 19 deletions docs_new/core-entities/tools.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,73 @@ Tools are the building blocks that give agents their capabilities. They are spec

In Agency Swarm, tools are Python classes that inherit from `BaseTool`. They are defined using [Pydantic](https://docs.pydantic.dev/latest/) for data validation and settings management. Each tool encapsulates a specific piece of functionality that an agent can invoke during its operation.

<Note>
**Key characteristics of tools:**

- **Modular:** Each tool performs a single, well-defined task.
- **Reusable:** Tools can be shared among multiple agents.
- **Extensible:** You can create custom tools to interact with APIs, process data, and more.
</Note>

## Basic Process Overview for Creating Tools
## Built-in Tools

To create a new tool in Agency Swarm, follow these steps:
Agency Swarm comes with several built-in tools to enhance agent capabilities:

1. **Plan the Tool's Purpose and Functionality:**
- Define what the tool will do and how it will be used by agents.
2. **Create a New Python Class Inheriting from `BaseTool`:**
- Import `BaseTool` and create a new class that extends it.
3. **Write a Clear Docstring Describing the Tool's Purpose:**
- This docstring is crucial as it helps agents understand how to use the tool.
4. **Define Input Fields with Proper Types and Descriptions:**
- Use Pydantic's `Field` to define the tool's input parameters.
5. **Implement the `run` Method with the Tool's Logic:**
- Write the code that executes the tool's functionality.
6. **Test the Tool Independently:**
- Ensure the tool works as expected before integrating it.
7. **Add the Tool to an Agent's Toolset:**
- Include the tool in the agent's list of available tools.
<Accordion title="Code Interpreter" icon="code">
- **Purpose**: Allows agents to execute code within a Jupyter Notebook environment (without internet access).
- **Integration**:
```python
from agency_swarm.tools import CodeInterpreter

agent = Agent(
name="DataAnalyst",
tools=[CodeInterpreter],
# Other agent parameters
)
```
</Accordion>

<Accordion title="File Search" icon="magnifying-glass">
- **Purpose**: Enables Retrieval-Augmented Generation (RAG) by allowing agents to search files.
- **Integration**:
```python
from agency_swarm.tools import FileSearch

agent = Agent(
name="Researcher",
tools=[FileSearch],
# Other agent parameters
)
```
</Accordion>

## Creating Basic Tools
## Basic Process Overview for Creating Custom Tools

<Steps>
<Step title="Plan the Tool's Purpose and Functionality">
Define what the tool will do and how it will be used by agents.
</Step>
<Step title="Create a New Python Class">
Import `BaseTool` and create a new class that extends it.
</Step>
<Step title="Write a Clear Docstring">
This docstring is crucial as it helps agents understand how to use the tool.
</Step>
<Step title="Define Input Fields">
Use Pydantic's `Field` to define the tool's input parameters.
</Step>
<Step title="Implement the run Method">
Write the code that executes the tool's functionality.
</Step>
<Step title="Test the Tool">
Ensure the tool works as expected before integrating it.
</Step>
<Step title="Add to Agent's Toolset">
Include the tool in the agent's list of available tools.
</Step>
</Steps>

## Creating Custom Tools

Let's walk through creating a simple tool step by step.

Expand Down Expand Up @@ -69,9 +110,11 @@ class Calculator(BaseTool):
return f"Error calculating expression: {e}"
```

#### How Docstrings Affect Agent Behavior
<Note>
**How Docstrings Affect Agent Behavior:**

Docstrings are parsed and included in the OpenAI schema of the respective tools. This allows agents to understand the tools they have at their disposal and perform function calls properly with this awareness. Developers should write good tool docstrings, clearly describing the tool's purpose and usage to facilitate effective agent interactions.
</Note>

### Step 3: Define Input Fields

Expand Down Expand Up @@ -140,9 +183,11 @@ Leverage Pydantic's special types for enhanced validation:

See more special types in [Pydantic's documentation](https://docs.pydantic.dev/latest/api/types/).

#### Field Descriptions and Their Impact
<Note>
**Field Descriptions and Their Impact:**

Field descriptions are used in the OpenAI function schemas presented to agents. They guide the agent in generating the correct inputs when calling the tool. Clear and descriptive field descriptions improve the agent's ability to use the tool effectively.
</Note>

#### Default Values and Their Impact

Expand Down
49 changes: 0 additions & 49 deletions docs_new/how-to-guides/creating-tools.mdx

This file was deleted.

33 changes: 0 additions & 33 deletions docs_new/how-to-guides/defining-agent-instructions.mdx

This file was deleted.

40 changes: 0 additions & 40 deletions docs_new/how-to-guides/using-code-interpreter-and-filesearch.mdx

This file was deleted.

0 comments on commit 4fcb35a

Please sign in to comment.