Swarm-ai is a TypeScript port of the Python Swarm library developed by OpenAI. This project aims to bring the powerful capabilities of Swarm to the JavaScript ecosystem, allowing developers to leverage the same concepts and functionalities in TypeScript and Node.js environments.
Swarm-ai is a TypeScript library for building conversational AI agents with tool-calling capabilities. It provides a flexible framework for creating and managing AI agents that can engage in conversations and utilize various functions or tools.
- Create AI agents with custom instructions and functions
- Support for context variables in agent instructions
- Function calling capabilities for agents
- Streaming support for real-time interactions
- Easy integration with OpenAI's GPT models
npm install swarm-ai
import { Swarm } from 'swarm-ai';
const client = new Swarm();
const agent = {
name: 'Agent',
model: 'gpt-4o',
instructions: 'You are a helpful agent.',
functions: [],
tool_choice: null,
parallel_tool_calls: true,
};
const messages = [{ role: 'user', content: 'Hi!' }];
(async () => {
const response = await client.run(agent, messages);
if ('messages' in response) {
console.log(response.messages[response.messages.length - 1].content);
}
})();
You can find examples of Swarm-ai usage in the examples
directory.