Dashboard API¶
Dashboard chat models.
- class sqldbagent.dashboard.models.ChatMessageModel(**data)[source]¶
Bases:
BaseModelRendered chat transcript entry for dashboard surfaces.
- Variables:
role – Message role shown in the dashboard.
content – Human-readable message body.
kind – Original LangChain/LangGraph message type.
name – Optional tool or actor name.
status – Optional tool status marker.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class sqldbagent.dashboard.models.DashboardTurnProgressModel(**data)[source]¶
Bases:
BaseModelOne dashboard progress event emitted during an agent turn.
- Variables:
phase – High-level execution phase such as bootstrap, tool, or response.
label – Short user-facing progress label.
detail – Optional supporting detail for the current step.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class sqldbagent.dashboard.models.DashboardThreadEntryModel(**data)[source]¶
Bases:
BaseModelPersisted dashboard thread summary used for thread selection.
- Variables:
thread_id – Stable thread identifier used by the LangGraph checkpointer.
datasource_name – Datasource identifier associated with the thread.
schema_name – Optional schema focus for the thread.
display_name – Optional user-friendly thread title.
created_at – First time the thread was observed by the dashboard.
updated_at – Most recent time the dashboard refreshed the thread entry.
message_count – Number of rendered transcript messages currently known.
latest_snapshot_id – Latest snapshot bound into the thread state, if any.
last_user_message – Most recent user message preview.
last_assistant_message – Most recent assistant message preview.
- Parameters:
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- class sqldbagent.dashboard.models.ChatSessionModel(**data)[source]¶
Bases:
BaseModelDashboard-ready snapshot of one agent conversation thread.
- Variables:
thread_id – Stable thread identifier used by the LangGraph checkpointer.
datasource_name – Datasource identifier backing the session.
schema_name – Optional schema focus.
messages – Rendered chat transcript entries.
dashboard_payload – Dashboard-friendly state payload from the agent state.
observability – Dashboard-friendly runtime and tracing status payload.
latest_snapshot_id – Latest known stored snapshot id.
latest_snapshot_summary – Latest known stored snapshot summary.
tool_call_digest – Compressed tool-call history from the agent state.
diagram_bundle – Stored schema-diagram bundle associated with the session.
prompt_bundle – Stored prompt bundle associated with the session.
retrieval_manifest – Stored retrieval-index manifest associated with the session.
example_questions – Snapshot-aware starter questions for the dashboard chat.
available_threads – Persisted dashboard thread summaries for selection.
- Parameters:
data (
Any)thread_id (str)
datasource_name (str)
schema_name (str | None)
messages (list[ChatMessageModel])
latest_snapshot_id (str | None)
latest_snapshot_summary (str | None)
diagram_bundle (DiagramBundleModel | None)
prompt_bundle (PromptBundleModel | None)
retrieval_manifest (RetrievalIndexManifestModel | None)
available_threads (list[DashboardThreadEntryModel])
- messages: list[ChatMessageModel]¶
- retrieval_manifest: RetrievalIndexManifestModel | None¶
- available_threads: list[DashboardThreadEntryModel]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
Dashboard chat service built on top of the persisted LangGraph agent.
- class sqldbagent.dashboard.service.DashboardChatService(*, settings=None, model=None, checkpointer=None, store=None)[source]¶
Bases:
objectRun persisted chat turns over the shared sqldbagent agent stack.
- Parameters:
- __init__(*, settings=None, model=None, checkpointer=None, store=None)[source]¶
Initialize the dashboard chat service.
- Parameters:
settings (
AppSettings|None, default:None) – Optional application settings.model (
Any|None, default:None) – Optional prebuilt LangChain-compatible model for tests.checkpointer (
Any|None, default:None) – Optional externally managed checkpointer for tests.store (
Any|None, default:None) – Optional externally managed long-term memory store for tests or dashboard-session reuse.
- Return type:
None
- run_turn(*, thread_id, user_message, datasource_name, schema_name=None, progress_callback=None)[source]¶
Run one user turn through the persisted agent session.
- Parameters:
thread_id (
str) – LangGraph thread identifier.user_message (
str) – User message content.datasource_name (
str) – Datasource identifier.schema_name (
str|None, default:None) – Optional schema focus.progress_callback (
Callable[[DashboardTurnProgressModel],None] |None, default:None) – Optional callback used to surface progress events while the agent turn is running.
- Returns:
Dashboard-ready state after the turn.
- Return type:
- load_thread(*, thread_id, datasource_name, schema_name=None)[source]¶
Load the current persisted state for one thread.
- Parameters:
- Returns:
Dashboard-ready state snapshot for the thread.
- Return type:
- list_threads(*, datasource_name=None, schema_name=None)[source]¶
List persisted dashboard thread summaries.
- update_thread_display_name(*, thread_id, datasource_name, schema_name, display_name)[source]¶
Persist an optional user-friendly display name for one thread.
- supports_async_queries(*, datasource_name)[source]¶
Return whether the datasource has a supported async query path.
- run_safe_query(*, datasource_name, sql, max_rows=None, mode='sync', access_mode='read_only')[source]¶
Run one guarded query through the shared query service.
- Parameters:
datasource_name (
str) – Datasource identifier.sql (
str) – SQL text to lint, guard, and execute.max_rows (
int|None, default:None) – Optional row-limit override.mode (
str, default:"sync") – Execution mode, eithersyncorasync.access_mode (
str, default:"read_only") – Requested execution mode, eitherread_onlyorwritable.
- Returns:
Guard and execution result.
- Return type:
QueryExecutionResult
- render_prompt_markdown(bundle)[source]¶
Render one stored prompt bundle as Markdown for dashboard downloads.
- Parameters:
bundle (
PromptBundleModel) – Prompt bundle to render.- Returns:
Human-readable Markdown prompt artifact.
- Return type:
- update_prompt_bundle_enhancement(*, datasource_name, schema_name, active, user_context, business_rules, additional_effective_context, answer_style, refresh_generated=False)[source]¶
Update prompt-enhancement state and regenerate the prompt bundle.
- Parameters:
datasource_name (
str) – Datasource identifier.schema_name (
str) – Schema name.active (
bool) – Whether the enhancement should be active.user_context (
str|None) – Freeform user context or domain notes.additional_effective_context (
str|None) – Extra instructions that should be injected directly into the effective prompt.answer_style (
str|None) – Preferred answer style for downstream outputs.refresh_generated (
bool, default:False) – Whether DB-aware guidance should be regenerated.
- Returns:
Updated prompt bundle or
Nonewhen no snapshot exists yet for the schema.- Return type:
PromptBundleModel|None
- refresh_prompt_bundle_context(*, datasource_name, schema_name)[source]¶
Regenerate schema-aware prompt context from the latest stored snapshot.
- explore_prompt_bundle_context(*, datasource_name, schema_name, table_names=None, max_tables=4, unique_value_limit=8, sync_memory=True, create_snapshot_if_missing=True)[source]¶
Generate live prompt context and persist it into the prompt bundle.
- Parameters:
datasource_name (
str) – Datasource identifier.schema_name (
str) – Schema name.table_names (
list[str] |None, default:None) – Optional explicit focus tables.max_tables (
int, default:4) – Maximum number of tables to explore live.unique_value_limit (
int, default:8) – Maximum number of distinct values per column.sync_memory (
bool, default:True) – Whether to sync a concise summary into long-term memory.create_snapshot_if_missing (
bool, default:True) – Whether to bootstrap a new snapshot first.
- Returns:
Updated prompt bundle, or
Nonewhen no stored snapshot exists for the schema.- Return type:
PromptBundleModel|None