Chat With Context • AI Agent SDK

chat_with_context: Chat with pre-retrieved context.

chat_with_context

Method

</div>

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

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

Parameters

ParamField str

User message/question

ParamField ContextPack

ContextPack from RAG.retrieve()

Returns

ResponseField str

Agent response with optional citations

Usage

python
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)

Uses

  • chat

Used By

Source

View on GitHub

praisonaiagents/agent/agent.py at line 6931


Related Documentation