swarms icon indicating copy to clipboard operation
swarms copied to clipboard

Enhanced Configuration, Token Counting and Unified Output Formatting Schema for swarms Module

Open harshalmore31 opened this issue 10 months ago • 0 comments

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: Added count_tokens method to ChatMessageInput class to count tokens in message content.
  • swarms/schemas/base_schemas.py: Added calculate_usage class method to UsageInfo class to calculate token usage for messages and completion.

New Schemas for Agent and Swarm Configuration:

  • swarms/schemas/base_swarm_schemas.py: Introduced AgentInputConfig class for agent configuration and BaseSwarmSchema class for swarm configuration with detailed validation methods.

Unified Output Schema:

  • swarms/schemas/output_schemas.py: Added Step, AgentTaskOutput, and OutputSchema classes 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/

harshalmore31 avatar Feb 07 '25 19:02 harshalmore31