Skip to main content

Features

QALITA Studio offers a powerful conversational interface to interact with your data quality. Discover all its capabilities.

Conversational Chat​

Streaming Mode​

Streaming mode displays model responses in real-time using Server-Sent Events (SSE).

Advantages:

  • ✅ Immediate feedback
  • ✅ Better user experience
  • ✅ Real-time token delivery
  • ✅ Optimized for long responses

API Endpoint:

curl -X POST https://your-platform/api/v1/studio/chat/stream \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "Explain data quality",
"conversation_id": "my-conv-123"
}'

SSE Response Format:

data: {"content": "Data quality refers to"}
data: {"content": " the accuracy, completeness"}
data: {"content": ", and consistency of data."}
data: [DONE]

Fallback Behavior:

  • If streaming fails, falls back to direct LLM streaming
  • If that fails, returns chunked response for visual streaming effect

Non-Streaming Mode​

Traditional mode with complete response at the end.

API Endpoint:

curl -X POST https://your-platform/api/v1/studio/chat \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"message": "Hello",
"conversation_id": "my-conv-123"
}'

Response:

{
"ok": true,
"response": "Hello! How can I help you with your data quality needs?",
"conversation_id": "my-conv-123",
"analysis_completed": false,
"analysis_result": null,
"scripts_generated": null
}

Conversation Management​

Each conversation is identified by a unique conversation_id.

Format:

  • Alphanumeric with hyphens and underscores
  • Example: conv_20241020_143022_a1b2c3d4

Auto-generation:

If no conversation_id is provided, one is automatically generated based on date/time and a random suffix.

Contextual Enrichment​

Studio automatically enriches your prompts with context from the QALITA Platform.

Enriched Context Structure​

The frontend sends enriched context data that the agent uses to personalize responses:

Request with context:

{
"message": "Explain this problem",
"context": {
"issue_id": 123,
"source_id": 456,
"project_id": 1,
"enriched": {
"issue": {
"id": 123,
"title": "High null rate in customer_email",
"status": "open",
"description": "45% null values detected"
},
"source": {
"id": 456,
"name": "customers",
"type": "postgresql"
},
"schema": [
{ "key": "column_name", "value": "customer_email" },
{ "key": "data_type", "value": "varchar" }
],
"recommendations": [
{ "content": "Add NOT NULL constraint", "severity": "high" }
],
"metrics": [{ "key": "score", "value": 55.0 }],
"dataSample": {
"headers": ["id", "customer_email", "name"],
"rows": [
["1", "john@example.com", "John"],
["2", null, "Jane"]
],
"totalRows": 10000
}
}
}
}

Context Components​

ComponentDescription
IssueTitle, status, description, scope, due date
SourceName, type, description
SchemaColumn names and data types
RecommendationsQuality improvement suggestions
MetricsQuality scores and counts
Data SamplePreview of actual data

System Prompt Construction​

The agent constructs a rich system prompt including:

Tu es un assistant expert en qualité des données...

# Contexte actuel

## Ticket en cours
- **Titre**: High null rate in customer_email
- **Statut**: open
- **Description**: 45% null values detected

## Source de données
- **Nom**: customers
- **Type**: postgresql

## Schéma de la source (15 colonnes)
**Colonnes**: id, customer_email, name, ...

## Recommandations de qualité (3 suggestions)
1. 🔴 Add NOT NULL constraint
...

## Métriques de qualité
- **Score moyen**: 55.0%

## Aperçu des données (10000 lignes au total)
**Colonnes**: id, customer_email, name
**Échantillon** (3 premières lignes):
1. 1 | john@example.com | John
2. 2 | | Jane
...

This enrichment provides the LLM with full awareness of the user's working context.

Conversation Management​

Conversations in Studio are stored in the Platform database and linked to issues, sources, and projects.

Conversation Model​

Each conversation record includes:

FieldDescription
idDatabase ID
conv_idUnique conversation identifier
filenameStored as <conv_id>.jsonl
partner_idOrganization ID
issue_idLinked issue (optional)
source_idLinked source (optional)
project_idLinked project (optional)
line_countNumber of messages
created_atCreation timestamp
updated_atLast update timestamp

Contextual Conversations​

Retrieve conversations based on current context:

Endpoint: GET /api/v1/studio/conversations/context

Query Parameters:

  • source_id: Get conversations from issues linked to this source
  • issue_id: Get conversations from this specific issue
  • project_id: Get conversations from all project sources and issues

Response:

{
"source_conversations": [
{
"id": 1,
"conv_id": "conv_20241020_143022",
"filename": "conv_20241020_143022.jsonl",
"project_id": 1,
"project_name": "E-Commerce",
"issue_id": 123,
"issue_title": "High null rate",
"source_id": 456,
"source_name": "customers",
"line_count": 12,
"created_at": "2024-10-20T14:30:22Z",
"updated_at": "2024-10-20T14:35:00Z"
}
],
"issue_conversations": [...],
"project_conversations": [...],
"total_count": 5
}

Conversation Grouping​

Conversations are grouped by context:

  1. Issue Conversations: Directly linked to the selected issue
  2. Source Conversations: From other issues linked to the same source
  3. Project Conversations: From all sources and issues in the project

This allows users to see related conversations when working on similar data quality topics.

Data Tools​

Studio's agent can interact directly with your data sources through the Worker infrastructure using LangChain tools.

Available Tools​

ToolDescription
execute_sql_queryRun SQL queries on database sources
read_source_dataRead data from files or tables
describe_sourceGet metadata, schema, row count
sample_source_dataGet random samples
count_rowsCount rows with optional condition
filter_dataFilter data by condition
aggregate_dataGroup by and aggregate

Whose rights the tools use​

Data tools run with the rights of the person asking, not with the agent's own. If you cannot read a source yourself, asking Studio about it is refused too, with the reason — the assistant is not a way around the platform's permissions.

Two consequences worth knowing:

  • A source declared with the user access modality is readable only by the person it is bound to. Studio will explain the refusal rather than fail silently.
  • A user who is deactivated, or who left the team, can no longer read anything through the agent: the tools refuse every call made on their behalf.

Platform tools follow your role. Studio also has tools that manage the platform (packs, routines, tickets, projects, reports, jobs). Each one needs the same permission as the matching screen or API route, read from your role when the tool runs, and Studio only offers the assistant the tools your role allows. A datascientist, for example, can open and update tickets but cannot create routines, projects or reports through Studio, and a datamanager cannot list or create routines. If your role changes during a conversation, the next call follows the new role. A refused call does nothing, and the assistant tells you which permission was missing.

ToolPermission needed
list_packspack:get.all
get_pack_detailspack:get
list_sourcessource:get.all
list_routinesroutine:get
create_routineroutine:create + license
list_usersuser:get.all
create_issueissue:create + license
list_issuesissue:get.all
update_issue, comment_issue, close_issueissue:update
list_projectsproject:get.all
create_projectproject:create + license
link_source_to_projectproject:create + license
create_reportreport:create + license
configure_reportreport:update
list_recent_jobsjob:get.all
get_job_metricsjob:get
get_source_recommendationsrecommendation:get

"+ license" means the tool also needs the team's license to be valid, exactly like the matching API route. The private and internal packs, the projects and the reports of another team are never reachable through these tools.

Agents act for their owner. An autonomous agent runs with the rights of its owner: the user who created it, or the user who last changed its instructions, sources, projects, tools, schedule, autonomy level or AI model, resumed it, or replied to it in its conversation. Saving one of these settings, resuming the agent or replying to it therefore makes you the user it acts for, since its scheduled runs read that conversation; renaming it, changing its description or working hours, or pausing it does not. The sources you give an agent must belong to your team and be readable by you, and when a change or a reply makes you its owner, so must every source it already has; otherwise saving or sending is refused with the reason. An agent created from a project page gets the project's sources that you can read.

At each scheduled run the owner is checked again. When the owner is deactivated, has left the team or no longer has a role that may run agents, the agent is paused before the run: the run is recorded as failed with the reason, and an administrator who resumes or reconfigures the agent becomes its new owner.

Two more rules for agents:

  • Switching off every tool in an agent's settings leaves it with no tool at all.
  • In an agent's run history, the result of a tool that read a source you cannot read is hidden and replaced by a notice, whatever your role. The call itself stays listed. A list of sources shows only the sources you can read.

How It Works​

┌─────────────┐    gRPC     ┌─────────────┐    Local    ┌─────────────┐
│ Studio │ ────────→ │ Worker │ ────────→ │ Source │
│ (Agent) │ ←──────── │ │ ←──────── │ (DB/File) │
└─────────────┘ Response └─────────────┘ Data └─────────────┘
  1. Agent decides to use a data tool based on user request
  2. Tool sends gRPC request to the Worker that holds the source: the one it is bound to, or a connected Worker that declares it in its sources-conf.yaml (see Which Worker serves a source)
  3. Worker executes the operation locally
  4. Results are formatted and returned to the agent
  5. Agent incorporates results into its response

Example Usage​

User asks: "Show me the columns with null values"

Agent uses: describe_source tool → gets schema, then execute_sql_query → runs SQL to check nulls

Response includes: Actual data from your source

Tool Responses​

Tool results are formatted for LLM consumption:

Execution time: 45ms
Columns: id, name, email, created_at

Rows (20 shown, 1000 total):
id | name | email | created_at
------------------------------------
1 | John Doe | john@ex.com | 2024-01-15
2 | Jane Smith | null | 2024-01-16
...

Executed queries​

Under each answer, Studio keeps an Executed queries block listing, in order, every tool the agent called to build that answer. The block stays open once the answer is complete; fold it to hide it.

Each query shows its tool name, its status (OK or ERROR) and, for execute_sql_query, a one-line preview of the SQL. Expand a query to see:

  • the full SQL statement, with a button to copy it;
  • the other arguments of the call;
  • the intermediate result the agent received, or the error. A result longer than 20,000 characters is cut, and Studio shows how many characters were kept.

When the block holds SQL, two buttons at its top copy all the statements at once or download them as a .sql file, numbered in execution order.

The block is saved with the conversation. It comes back when you reopen the conversation in Studio, and it also shows in the conversations of an issue. See Message Format for the stored fields. Because the saved results come from your sources, opening a saved conversation requires read access to them: see Access to a Stored Conversation.

Only execute_sql_query carries the SQL text written by the agent. Structured tools such as count_rows, filter_data or aggregate_data show their parameters: the Worker builds their SQL itself and does not report it back.

Over the stream, each query is sent as a tool_executing event, then a tool_result event carrying the same tool_id:

data: {"tool_executing": "execute_sql_query", "tool_id": "call_1", "tool_args": {"source_id": 3, "sql": "SELECT count(*) FROM orders"}}
data: {"tool_result": {"tool_id": "call_1", "tool_name": "execute_sql_query", "ok": true, "result": "...", "error": null}}

Data Preview​

Preview source data directly through Studio.

Preview Endpoint​

GET /api/v1/studio/sources/{source_id}/preview

Query Parameters:

  • limit: Maximum rows (default 1000, max 10000)
  • source_version_id: Specific version
  • query: Custom SQL query (for databases)

Response:

{
"ok": true,
"data_type": "table",
"headers": ["id", "name", "email"],
"rows": [
{ "values": ["1", "John", "john@example.com"] },
{ "values": ["2", "Jane", "jane@example.com"] }
],
"total_rows": 10000
}

Data Types:

  • table: Structured data with headers/rows
  • text: Plain text content
  • json: JSON content
  • image: Base64 encoded image
  • pdf: Base64 encoded PDF
  • error: Error response

Database sources​

For a database source, the preview reads the object set in the source's Tables or SQL query field (table_or_query in the worker's source configuration):

Field valueWhat is previewed
A table or view name, e.g. ordersThat table or view
A SQL query (SELECT …, WITH …)The result of that query
* or empty (the default)The first table or view of the schema, in alphabetical order

Set one table name, * or one query: packs do not split a comma-separated list of names, and the preview would only show the first one.

With *, the schema is the one set on the source, or the database user's default schema. On PostgreSQL with no schema set and nothing in the default one, the preview takes the first table or view of the other non-system schemas, in the order a pack scan reads them. The worker log names the object it picked. To look at another table, ask the Studio agent: describe_source lists the tables and views, and the other data tools accept any of them.

When there is nothing to show, the error says why and what to change:

  • No table or view is visible in the schema with the source's credentials: check the schema set on the source and the database grants (USAGE on the schema, SELECT on its tables), or set the field to a table name or a query.
  • The object picked for * cannot be read: the error names it. Set the field to a table the database user can read, or grant SELECT on it.

Large tables​

A preview returns at most the requested rows, whatever the size of the table:

  • Rows are capped whatever the query says: a LIMIT 10000000 typed in a query still returns at most the requested rows.

    • On PostgreSQL the query is read as SELECT * FROM (query) LIMIT n, so the database sends no more rows than requested.
    • On PostgreSQL, MySQL, MariaDB and SQLite, LIMIT is added to a query that has no LIMIT or FETCH FIRST of its own. A limit inside a comment or a string does not count.
    • On MySQL and MariaDB, a query that carries its own large LIMIT still makes the database send all of those rows: the worker reads and discards the ones it does not keep, so memory stays bounded but the time does not.
    • SQL Server and Oracle get no LIMIT: the worker stops reading after the requested rows.
  • The data is read before any row count. total_rows is exact when the preview returned fewer rows than requested. When a table preview returned as many rows as requested, the total is counted only where the count is bounded. A full preview of a SQL query, from the field or from the request, leaves the total empty on every database.

    DatabaseTotal of a full table preview
    PostgreSQLExact count, skipped above 1,000,000 estimated rows (QALITA_PREVIEW_COUNT_MAX_ROWS) and cancelled after 5 s
    SQLiteExact count
    MySQL, MariaDB, SQL Server, OracleLeft empty: the UI shows the number of rows read
  • On PostgreSQL, preview statements run with a 45 s statement timeout (QALITA_PREVIEW_STATEMENT_TIMEOUT), below the platform's 60 s preview wait. The agent's data tools run with 110 s (QALITA_DATA_TOOLS_STATEMENT_TIMEOUT), below the platform's 120 s wait for a data tool. The worker only ever lowers the timeout: a stricter statement_timeout set on the database user or the database stays in force. When the worker's timeout fires, the error says so:

    The database did not answer within 45 s and cancelled the preview (statement timeout set by the worker). The table is probably too large for this query: preview a narrower query (WHERE on an indexed column, fewer columns, no ORDER BY or aggregate over the whole table), or raise QALITA_PREVIEW_STATEMENT_TIMEOUT on the worker (keep it under the platform's 60 s preview wait).

    When the timeout came from the database side, the error gives its value and says to ask the database administrator instead. The other databases have no statement timeout yet: a query that runs too long ends with the platform's 504 Worker did not respond in time.

  • The agent's describe_source gets its row count the same way on PostgreSQL: above 1,000,000 estimated rows, or after 5 s, it leaves the count out. count_rows always counts exactly, within the data tools statement timeout.

  • The agent's sample_source_data uses TABLESAMPLE SYSTEM on PostgreSQL tables above 100,000 estimated rows instead of sorting the whole table at random.

These limits are worker settings, see CLI environment variables.

API Endpoints Reference​

All endpoints require authentication via Bearer token.

Chat​

MethodEndpointDescription
POST/api/v1/studio/chatSend message to agent
POST/api/v1/studio/chat/streamStreaming SSE response

Status & Capabilities​

MethodEndpointDescription
GET/api/v1/studio/statusWorker connection status
GET/api/v1/studio/agent/capabilitiesAgent and LLM status

Data Preview​

MethodEndpointDescription
GET/api/v1/studio/sources/{id}/previewPreview source data
POST/api/v1/studio/sources/{id}/previewPreview with body params

Conversations​

MethodEndpointDescription
GET/api/v1/studio/conversations/contextGet contextual conversations

Advanced Use Cases​

1. Issue Analysis with Complete Context​

import requests

headers = {"Authorization": "Bearer YOUR_TOKEN"}

response = requests.post('https://your-platform/api/v1/studio/chat',
headers=headers,
json={
"message": "Analyze this problem and suggest solutions",
"context": {
"issue_id": 123,
"source_id": 456,
"enriched": {
"issue": {
"id": 123,
"title": "Duplicate customer records",
"status": "open"
},
"source": {
"id": 456,
"name": "customers",
"type": "postgresql"
}
}
},
"conversation_id": "analysis_issue123"
}
)

print(response.json()["response"])

2. Streaming Response Handling​

import requests
import json

def stream_chat(message, context=None):
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}

response = requests.post(
'https://your-platform/api/v1/studio/chat/stream',
headers=headers,
json={"message": message, "context": context},
stream=True
)

for line in response.iter_lines():
if line:
line = line.decode('utf-8')
if line.startswith('data: '):
data = line[6:]
if data == '[DONE]':
break
chunk = json.loads(data)
if 'content' in chunk:
print(chunk['content'], end='', flush=True)
print()

stream_chat("Describe the schema of this source", {"source_id": 456})

3. Multi-Step Investigation with History​

conversation_id = "investigation_202410"
messages_history = []

def chat_with_history(message, context):
global messages_history

response = requests.post(
'https://your-platform/api/v1/studio/chat',
headers={"Authorization": "Bearer YOUR_TOKEN"},
json={
"message": message,
"context": context,
"conversation_id": conversation_id,
"messages_history": messages_history
}
)

result = response.json()

# Update history
messages_history.append({"role": "user", "content": message})
messages_history.append({"role": "assistant", "content": result["response"]})

return result["response"]

# Multi-step conversation
context = {"issue_id": 123, "source_id": 456}

print(chat_with_history("Summarize this issue", context))
print(chat_with_history("What are the potential causes?", context))
print(chat_with_history("Propose a step-by-step action plan", context))

4. Data Exploration via Agent​

# Ask the agent to explore data - it will use data tools automatically
response = requests.post(
'https://your-platform/api/v1/studio/chat',
headers={"Authorization": "Bearer YOUR_TOKEN"},
json={
"message": "Show me the top 10 customers with the most null email addresses and suggest how to fix them",
"context": {"source_id": 456}
}
)

# The agent will:
# 1. Use describe_source to understand the schema
# 2. Use execute_sql_query to find customers with null emails
# 3. Provide analysis and recommendations
print(response.json()["response"])

Error Handling​

Common Errors​

400 - Agent not available:

{
"detail": "Agent module not available. Please install langchain and langgraph."
}

503 - LLM not configured:

{
"detail": "No LLM configuration found for partner 1. Please configure an LLM provider in Settings > AI."
}

Previews and data tools reach the source through a Worker. When none can serve it, the API answers with a structured detail (code, message, params) that names the Worker to act on, and Studio shows it translated.

503 - The Worker that holds the source is not connected (params.worker_name names it; for a source with the user access modality, the bound Worker):

{
"detail": {
"code": "WORKER_NOT_CONNECTED",
"message": "The worker remote-worker that declares this source is not connected. Start it and try again.",
"params": { "worker_id": 4, "worker_name": "remote-worker" }
}
}

503 - No Worker connected at all (same code, params.worker_id is null):

{
"detail": {
"code": "WORKER_NOT_CONNECTED",
"message": "No worker is currently connected for this organization. Start one and try again.",
"params": { "worker_id": null, "worker_name": null }
}
}

503 - No connected Worker declares the source (params.worker_names lists the connected ones):

{
"detail": {
"code": "SOURCE_NOT_ON_WORKER",
"message": "No connected worker declares this source in its configuration (connected: worker-a). Add the source to the worker that can reach it, or start that worker, then try again.",
"params": {
"worker_id": null,
"worker_name": null,
"worker_names": "worker-a"
}
}
}

504 - Worker timeout (the chosen Worker got the request but did not answer in time):

{
"detail": {
"code": "WORKER_TIMEOUT",
"message": "The worker remote-worker did not respond in time.",
"params": { "worker_id": 4, "worker_name": "remote-worker" }
}
}

A plain 503 with "detail": "Failed to send request to worker" means the Worker disconnected between routing and sending: the preview retries it automatically. Data tools report the same codes to the agent, in their result: {"ok": false, "error": "The worker remote-worker did not respond in time.", "code": "WORKER_TIMEOUT"}.

Chat Response Errors​

Errors during chat are returned in the response body:

{
"ok": false,
"response": null,
"conversation_id": "conv_xyz",
"error": "Agent error: Connection to Ollama refused"
}

Streaming Errors​

In SSE mode, errors are sent as data events:

data: {"error": "LLM timeout after 60 seconds"}
data: [DONE]

Performance​

Optimizations​

  • SSE Streaming: Reduces perceived latency for long responses
  • Automatic Fallbacks: Graceful degradation when streaming unavailable
  • Worker Connection Pool: Reuse of gRPC connections
  • Data Tool Caching: Results cached per request

Timeouts​

OperationTimeout
Chat (non-streaming)60s
Chat (streaming)No timeout (SSE)
Data preview60s
Data tools120s per operation
Database statement, preview (worker, PostgreSQL)45s (QALITA_PREVIEW_STATEMENT_TIMEOUT)
Database statement, data tools (worker, PostgreSQL)110s (QALITA_DATA_TOOLS_STATEMENT_TIMEOUT)
Database connection (worker)10s (PostgreSQL, MySQL, MariaDB)

Limits​

  • Data preview rows: Max 10,000 rows
  • Tool result rows: Max 20 rows displayed in LLM context
  • Context size: Depends on LLM provider

Next Steps​