Execute an agentic query with autonomous tool access and conversation handling
query
method which retrieves and generates responses from existing documents, the agent can dynamically decide which tools to use based on the query requirements, execute code, analyze documents, create graphs, and more.
query
(str): Natural language query for the Morphik agentDict[str, Any]
: A comprehensive response dictionary containing:
response
(str): The agent’s final text responsetool_history
(List[Dict]): Detailed history of all tool executionsdisplay_objects
(List[Dict]): Structured content objects for rich displaysources
(List[Dict]): Source attribution for all referenced contentresponse
(str)tool_history
(List[Dict])tool_name
(str): Name of the executed tooltool_args
(dict): Arguments passed to the tooltool_result
(str/dict): The result returned by the tooldisplay_objects
(List[Dict])type
(str): Either “text” or “image”content
(str): For text objects, this is markdown content. For image objects, this is the image datasource
(str): Source ID linking to the original contentcaption
(str, for images): Description or caption for image objectssources
(List[Dict])sourceId
(str): Unique identifier for the sourcedocumentName
(str): Human-readable document namedocumentId
(str): Document identifiercontent
(str): Relevant content from the sourcequery
MethodFeature | query | agent_query |
---|---|---|
Approach | Retrieval-based: finds relevant chunks and generates response | Agent-based: autonomously decides and uses tools |
Tools | None (fixed retrieval pipeline) | Full tool access (retrieve, analyze, code, graphs, etc.) |
Response Type | CompletionResponse object | Dict[str, Any] with rich structure |
Autonomy | Fixed workflow | Dynamic decision making |
Capabilities | Document retrieval and QA | Multi-modal analysis, computation, memory |
Use Case | Direct questions about documents | Complex research and analysis tasks |
tool_history
to understand what the agent diddisplay_objects
for rich content presentationsources
for attribution and verificationquery
: For simple document-based Q&Aretrieve_chunks
: For manual document retrievalcreate_graph
: For knowledge graph creationlist_documents
: For document discovery