Dashboard API

Dashboard chat models.

class sqldbagent.dashboard.models.ChatMessageModel(**data)[source]

Bases: BaseModel

Rendered 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:
role: str
content: str
kind: str
name: str | None
status: str | None
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: BaseModel

Persisted 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.

  • 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:
  • data (Any)

  • thread_id (str)

  • datasource_name (str)

  • schema_name (str | None)

  • created_at (datetime)

  • updated_at (datetime)

  • message_count (int)

  • latest_snapshot_id (str | None)

  • last_user_message (str | None)

  • last_assistant_message (str | None)

thread_id: str
datasource_name: str
schema_name: str | None
created_at: datetime
updated_at: datetime
message_count: int
latest_snapshot_id: str | None
last_user_message: str | None
last_assistant_message: str | None
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: BaseModel

Dashboard-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.

  • example_questions – Snapshot-aware starter questions for the dashboard chat.

  • available_threads – Persisted dashboard thread summaries for selection.

Parameters:
thread_id: str
datasource_name: str
schema_name: str | None
messages: list[ChatMessageModel]
dashboard_payload: dict[str, object]
observability: dict[str, object]
latest_snapshot_id: str | None
latest_snapshot_summary: str | None
tool_call_digest: list[str]
diagram_bundle: DiagramBundleModel | None
prompt_bundle: PromptBundleModel | None
example_questions: list[str]
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)[source]

Bases: object

Run persisted chat turns over the shared sqldbagent agent stack.

Parameters:
__init__(*, settings=None, model=None, checkpointer=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.

Return type:

None

static new_thread_id()[source]

Return a new stable thread identifier.

Return type:

str

run_turn(*, thread_id, user_message, datasource_name, schema_name=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.

Returns:

Dashboard-ready state after the turn.

Return type:

ChatSessionModel

load_thread(*, thread_id, datasource_name, schema_name=None)[source]

Load the current persisted state for one thread.

Parameters:
  • thread_id (str) – LangGraph thread identifier.

  • datasource_name (str) – Datasource identifier.

  • schema_name (str | None, default: None) – Optional schema focus.

Returns:

Dashboard-ready state snapshot for the thread.

Return type:

ChatSessionModel

list_threads(*, datasource_name=None, schema_name=None)[source]

List persisted dashboard thread summaries.

Parameters:
  • datasource_name (str | None, default: None) – Optional datasource filter.

  • schema_name (str | None, default: None) – Optional schema filter.

Returns:

Matching thread summaries ordered by most recently updated first.

Return type:

list[DashboardThreadEntryModel]

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:

str

update_prompt_bundle_enhancement(*, datasource_name, schema_name, active, user_context, business_rules, 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.

  • business_rules (str | None) – Business rules and caveats.

  • 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 None when no snapshot exists yet for the schema.

Return type:

PromptBundleModel | None