Skip to content

Conversation

@harshalmore31
Copy link
Contributor

@harshalmore31 harshalmore31 commented Jun 18, 2025

This pull request introduces a comprehensive integration of Retrieval-Augmented Generation (RAG) functionality into the Swarms framework. It includes a new example script (simple_rag_example.py), updates to the Agent class to support RAG operations, and enhancements to the AgentRAGHandler. These changes aim to improve the framework's ability to retrieve and utilize external knowledge dynamically.

RAG Integration Enhancements:

  • New Example Script: Added simple_rag_example.py, demonstrating the usage of RAG with a simple memory store and Swarms Agent. The example includes memory querying, manual saves, and integration of RAG into agent workflows.
  • Agent Class Updates: Extended the Agent class with methods for enabling, disabling, and managing RAG functionality, including memory queries, saving to memory, and retrieving statistics. Legacy methods were replaced with new RAG-specific handlers. [1] [2] [3]
  • RAG Handler Enhancements: Improved the AgentRAGHandler to ensure default relevance keywords are used when none are provided in the RAG configuration.

Code Refactoring:

  • Initialization Improvements: Refactored Agent initialization to support RAG configuration directly and ensure proper setup of the RAG handler. Legacy methods for memory querying and handling were deprecated. [1] [2]
  • Memory and Tool Handling: Updated _run and related methods in Agent to incorporate RAG operations seamlessly during task execution and final memory consolidation. [1] [2]

Framework Updates:

  • Structs Module: Added RAGConfig to the Swarms structs module to facilitate RAG configuration management. [1] [2]
  • Agent Persistence: Enhanced _save_additional_components and _reinitialize_after_load methods to support saving and reinitializing RAG handler statistics. [1] [2] [FEAT] [Integrate AgentRAGHandler] #880

📚 Documentation preview 📚: https://swarms--903.org.readthedocs.build/en/903/

- Introduced a new example demonstrating RAG integration with Swarms framework.
- Added SimpleMemoryStore class for in-memory storage and querying.
- Enhanced Agent class with RAG configuration and methods for RAG operations.
- Updated RAGConfig to include default relevance keywords for insights extraction.
@harshalmore31 harshalmore31 changed the title Integrated agent_rag_handler with the agent class feat. Integrated agent_rag_handler with the agent class Jun 18, 2025
@harshalmore31 harshalmore31 linked an issue Jun 19, 2025 that may be closed by this pull request
def __init__(self):
self.memories = []

def add(self, content: str, metadata: dict = None) -> bool:

Check failure

Code scanning / Pyre

Incompatible variable type Error

Incompatible variable type [9]: metadata is declared to have type Dict[typing.Any, typing.Any] but is used as type None.

return self.rag_handler.query_memory(query, context_type)

def tool_execution_retry(self, response: any, loop_count: int):

Check failure

Code scanning / Pyre

Parsing failure Error

Parsing failure [404]: unindent does not match any outer indentation level
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] [Integrate AgentRAGHandler]

1 participant