A lightweight, LLM-agnostic framework for building AI agents with dynamic agent switching. Supports 100+ language models through litellm.
- Lightweight Core: Minimal base implementation that's easy to understand and extend
- LLM Agnostic: Support for OpenAI, Anthropic, Google, and many more through litellm
- Dynamic Agent Switching: Switch between specialized agents during execution
- Type-Safe Context: Full type safety for context parameters and outputs
- Stateful Chat Interface: Build chat applications with built-in state management
- Event Streaming: Real-time streaming of agent responses and tool calls
import asyncio
from liteswarm.core import Swarm
from liteswarm.types import LLM, Agent, Message
async def main() -> None:
# Create a simple agent
agent = Agent(
id="assistant",
instructions="You are a helpful assistant.",
llm=LLM(model="gpt-4o"),
)
# Create swarm and execute
swarm = Swarm()
result = await swarm.execute(
agent=agent,
messages=[Message(role="user", content="Hello!")],
)
print(result.agent_response.content)
if __name__ == "__main__":
asyncio.run(main())
pip install liteswarm
For more details, check out:
- Advanced Usage for more advanced features
- Examples for more code examples
- API Reference for detailed documentation
- Contributing for how to contribute to the project