Skip to main content

chat_with_context

Method
This is a method of the Agent class in the agent module.
Chat with pre-retrieved context. This method allows AutoRagAgent or manual workflows to inject pre-retrieved context into the agent’s chat, enabling conditional retrieval without duplicating RAG logic.

Signature

def chat_with_context(message: str, context: 'ContextPack') -> str

Parameters

message
str
required
User message/question
context
ContextPack
required
ContextPack from RAG.retrieve()

Returns

Returns
str
Agent response with optional citations

Usage

from praisonaiagents import AutoRagAgent

    auto_rag = AutoRagAgent(agent=my_agent)
    result = auto_rag.chat("What are the key findings?")

    # Or manually:
    context_pack = rag.retrieve("What are the key findings?")
    response = agent.chat_with_context("What are the key findings?", context_pack)