The Context Store API allows you to manage context stores, which are used to store and retrieve SQL prompts and associated metadata. This API provides endpoints for creating, retrieving, updating, and deleting context stores.
Endpoint:/api/v1/context-storesMethod:GETDescription: Retrieves a list of all context stores.
Response:
3. Retrieve a Specific Context Store
Endpoint:/api/v1/context-stores/{context_store_id}Method:GETDescription: Retrieves the details of a specific context store entry identified by context_store_id.
Response:
4. Retrieve Similar Context Stores
Endpoint:/api/v1/context-stores/semantic-searchMethod:POSTDescription: Retrieves the details of top k most similar context store entries excluding the exact match.
POST /api/v1/context-stores
Content-Type: application/json
{
"db_connection_id": "db123",
"prompt": "What is the total revenue?",
"sql": "SELECT SUM(amount) AS revenue FROM sales",
"metadata": {"created_by": "admin"}
}
{
"id": "ctx123",
"db_connection_id": "db123",
"prompt": "What is the total revenue?",
"sql": "SELECT SUM(amount) AS revenue FROM sales",
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
GET /api/v1/context-stores
[
{
"id": "ctx123",
"db_connection_id": "db123",
"prompt": "What is the total revenue?",
"sql": "SELECT SUM(amount) AS revenue FROM sales",
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
]
GET /api/v1/context-stores/ctx123
{
"id": "ctx123",
"db_connection_id": "db123",
"prompt": "What is the total revenue?",
"sql": "SELECT SUM(amount) AS revenue FROM sales",
"metadata": {"created_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
POST /api/v1/context-stores/semantic-search
Content-Type: application/json
{
"db_connection_id": "db123"
"prompt": How many regency in,
"top_k": 3
}
[
{
"prompt_text": "How many regency in Kutai?",
"sql": "SELECT SUM(amount) AS revenue FROM sales",
"score": "0.8117260634899139"
}
]
PUT /api/v1/context-stores/ctx123
Content-Type: application/json
{
"prompt": "What is the total revenue from Q1?",
"sql": "SELECT SUM(amount) AS revenue FROM sales WHERE quarter = 'Q1'",
"metadata": {"updated_by": "admin"}
}
{
"id": "ctx123",
"db_connection_id": "db123",
"prompt": "What is the total revenue from Q1?",
"sql": "SELECT SUM(amount) AS revenue FROM sales WHERE quarter = 'Q1'",
"metadata": {"updated_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}
DELETE /api/v1/context-stores/ctx123
{
"id": "ctx123",
"db_connection_id": "db123",
"prompt": "What is the total revenue from Q1?",
"sql": "SELECT SUM(amount) AS revenue FROM sales WHERE quarter = 'Q1'",
"metadata": {"updated_by": "admin"},
"created_at": "2024-09-09T12:34:56Z"
}