swarms
swarms copied to clipboard
Enhanced Configuration, Token Counting and Unified Output Formatting Schema for swarms Module
This pull request introduces significant enhancements to the swarms module by adding new classes and methods for better handling of token counting, agent configuration, and output formatting. The most important changes include the addition of token counting capabilities, the introduction of new schemas for agent input and swarm configuration, and the creation of a unified output schema.
Token Counting Enhancements:
swarms/schemas/base_schemas.py: Addedcount_tokensmethod toChatMessageInputclass to count tokens in message content.swarms/schemas/base_schemas.py: Addedcalculate_usageclass method toUsageInfoclass to calculate token usage for messages and completion.
New Schemas for Agent and Swarm Configuration:
swarms/schemas/base_swarm_schemas.py: IntroducedAgentInputConfigclass for agent configuration andBaseSwarmSchemaclass for swarm configuration with detailed validation methods.
Unified Output Schema:
swarms/schemas/output_schemas.py: AddedStep,AgentTaskOutput, andOutputSchemaclasses for representing and formatting the output of agent tasks and swarm executions.
These changes collectively enhance the functionality and robustness of the swarms module, enabling more detailed tracking and configuration of agents and swarms.
📚 Documentation preview 📚: https://swarms--770.org.readthedocs.build/en/770/