Skip to main content
When querying a Deployment using a Knowledge Base, it is possible to fetch the details of the knowledge base retrievals during generation.

Invoking with retrieval

When using Invoke a Deployment, use the optional field include_retrievals to embed the retrieval chunks within the response payload. Here are examples on how to use the include_retrievals field in the invoke_options object in your queries payload.
curl --location 'https://my.orq.ai/v2/deployments/invoke' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer xxxxx' \
--data '{
    "key": "deployment_key",
    "messages": [
        {
            "role": "user",
            "content": ""
        }
    ],
    "invoke_options": {
        "include_retrievals": true
    }
}'
Your invokation will then embed the response chunks from the response field retrievals as follow

The retrieval results will be embedded in the retrieval_metadata field, they contain the document details as well as metadata related to the file and search score.

The retrievals are returned in the following format:
Retrievals will contain an array of chunks Each chunk holds the source details and scores (search and re-ranking).
{
    "retrievals": [
        {
            "document": "<chunk_data>",
            "metadata": {
                "file_name": "<filename>",
                "file_type": "application/pdf",
                "page_number": 24,
                "search_score": 0.7886787056922913,
                "rerank_score": 0.19868536
            }
        },
        {
            "document": "<chunk_data>",
            "metadata": {
                "file_name": "<filename>",
                "file_type": "application/pdf",
                "page_number": 25,
                "search_score": 0.746787056030011,
                "rerank_score": 0.1683825
            }
        }
    ]
}