Chat With Context • AI Agent SDK
chat_with_context: Chat with pre-retrieved context.
chat_with_context
Method
</div>
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') -> strParameters
ParamField
strUser message/question
ParamField
ContextPackContextPack from RAG.retrieve()
Returns
ResponseField
strAgent 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)Uses
chat
Used By
Source
View on GitHubpraisonaiagents/agent/agent.py at line 6931