agents.rag.unified_factory

Unified RAG Factory.

from typing import Any, Dict Create any RAG agent using either traditional or ChainAgent approach. Integrates with multi-agent system.

Classes

RAGFactory

Unified factory for creating RAG agents.

RAGStyle

Implementation style.

RAGType

Available RAG types.

Functions

create_rag(rag_type, documents[, style])

Simple function to create any RAG agent.

create_rag_chain(rag_type, documents, **kwargs)

Create a RAG agent as a ChainAgent.

create_rag_multi(rag_type, documents, **kwargs)

Create a RAG agent as a MultiAgent.

create_rag_pipeline(rag_types, documents[, style])

Create a pipeline of RAG agents.

example_usage()

Examples of how to use the unified factory.

Module Contents

class agents.rag.unified_factory.RAGFactory

Unified factory for creating RAG agents.

static create(rag_type, documents, llm_config=None, style=RAGStyle.CHAIN, name=None, **kwargs)

Create any RAG agent.

Parameters:
  • rag_type (RAGType) – Type of RAG to create

  • documents (list[langchain_core.documents.Document]) – Documents for retrieval

  • llm_config (haive.core.models.llm.base.LLMConfig | None) – LLM configuration

  • style (RAGStyle) – Implementation style

  • name (str | None) – Agent name

  • **kwargs – Additional arguments

Returns:

The created RAG agent

Return type:

haive.agents.base.agent.Agent | haive.agents.chain.ChainAgent

class agents.rag.unified_factory.RAGStyle

Bases: str, enum.Enum

Implementation style.

Initialize self. See help(type(self)) for accurate signature.

class agents.rag.unified_factory.RAGType

Bases: str, enum.Enum

Available RAG types.

Initialize self. See help(type(self)) for accurate signature.

agents.rag.unified_factory.create_rag(rag_type, documents, style='chain', **kwargs)

Simple function to create any RAG agent.

Parameters:
Return type:

haive.agents.base.agent.Agent | haive.agents.chain.ChainAgent

agents.rag.unified_factory.create_rag_chain(rag_type, documents, **kwargs)

Create a RAG agent as a ChainAgent.

Parameters:
  • rag_type (str | RAGType)

  • documents (list[langchain_core.documents.Document])

Return type:

haive.agents.chain.ChainAgent

agents.rag.unified_factory.create_rag_multi(rag_type, documents, **kwargs)

Create a RAG agent as a MultiAgent.

Parameters:
  • rag_type (str | RAGType)

  • documents (list[langchain_core.documents.Document])

agents.rag.unified_factory.create_rag_pipeline(rag_types, documents, style=RAGStyle.CHAIN, **kwargs)

Create a pipeline of RAG agents.

Parameters:
Return type:

haive.agents.chain.ChainAgent

agents.rag.unified_factory.example_usage()

Examples of how to use the unified factory.

Return type:

Dict[str, Any]