Open-Source Models
Utilize open-source models with Agency Swarm.
While OpenAI is generally recommended, there are situations where you might prefer open-source models. The following projects offer alternatives by mimicking the Assistants API:
Supported Projects
Astra Assistants API
The best and the easiest option for running Open Source models. Supports Assistants API V2. See example notebook and official examples.
Open Assistant API
Fully local, stable, and tested, but only supports Assistants V1. See example here.
OpenOpenAI
Unverified.
LiteLLM
Assistants API Proxy in development.
Astra Assistants API
1. Create an account on Astra Assistants API and obtain an API key.
Open the Astra Assistants API and create an account. Once you have an account, you can obtain an API key by clicking on the “Generate Token” button.
2. Add Astra DB Token to your .env file:
Copy the token from the file that starts with “AstraCS:” and paste it into your .env
file.
3. Add other model provider API keys to .env as well:
4. Install the Astra Assistants API and Gradio:
5. Patch the OpenAI client:
6. Create an agent:
Create an agent and replace the model
parameter with the name of the model you want to use. With Astra Assistants, you can upload files as usual using files_folder
.
7. Create an agency:
You can add more agents as needed, just ensure all manager agents support function calling.
8. Start Gradio:
To utilize your agency in Gradio, apply a specific non-streaming demo_gradio
method from the agency-swarm-lab repository:
For complete examples, see the implementation notebook and official Astra Assistants examples.
General Instructions
To use agency-swarm with any other projects that mimic the Assistants API, generally, you need to follow these steps:
Install the previous version of agency-swarm as most projects are not yet compatible with streaming and Assistants V2:
Switch out the OpenAI client:
Set the model parameter:
Start Gradio:
To utilize your agency in Gradio, apply a specific non-streaming demo_gradio
method from the agency-swarm-lab repository:
For backend integrations, simply use:
Limitations
Be aware of the limitations when using open-source models.
- Function calling is not supported by most open-source models: This limitation prevents the agent from communicating with other agents in the agency. Therefore, it must be positioned at the end of the agency chart and cannot utilize any tools.
- RAG is typically limited: Most open-source assistants API implementations have restricted Retrieval-Augmented Generation capabilities. It is recommended to develop a custom tool with your own vector database.
- Code Interpreter is not supported: The Code Interpreter feature is still under development for all open-source assistants API implementations.
Future Plans
Updates will be provided as new open-source assistant API implementations stabilize.
If you successfully integrate other projects with agency-swarm, please share your experience through an issue or pull request.