Tools

Database Query

Run a natural language query against connected SQL databases.

post/v1/tools/database-query

Request body

querystring required

The natural language query to run against connected databases.

Example request

{
  "query": "What were the Q4 revenue trends?",
  "artifacts": [
    {
      "context_filter": {
        "collection": "collection_name",
        "artifacts": [
          "artifact_id_1, artifact_id_2"
        ],
        "metadata_filter": [
          {
            "key": "file_id",
            "operator": "==",
            "value": "artifact_id_1"
          }
        ]
      }
    }
  ]
}

Response

Database query completed successfully.

is_errorboolean

True if the tool encountered an error during execution.

Example response

{
  "content": [
    {
      "sources": [
        {
          "content_type": "text/plain",
          "document": {
            "artifact": "quarterly_report_q3",
            "doc_metadata": {
              "department": "finance",
              "file_name": "Q3_Financial_Report.pdf",
              "page_number": 5
            },
            "object": "ingest.document"
          },
          "id": "chunk_123e4567-e89b-12d3-a456-426614174000",
          "metadata": {
            "abs_idx": 8,
            "author": "Finance Team",
            "date": "2023-10-15",
            "rel_idx": 3,
            "section": "Revenue Analysis",
            "title": "Q3 Financial Report"
          },
          "next_texts": [
            "The technology sector contributed 60% of total growth.",
            "Marketing expenses remained within budget projections."
          ],
          "object": "context.chunk",
          "previous_texts": [
            "Q3 FINANCIAL SUMMARY",
            "This report covers the third quarter performance metrics."
          ],
          "score": 0.856,
          "text": "Revenue increased by 15% compared to the previous quarter, primarily driven by strong performance in the technology sector."
        }
      ]
    }
  ]
}

Changes