chat

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package chat implements the narrow DataTug Chat proof of concept: an ADK agent may invoke one DTQL tool, and DataTug executes that tool into a structured secureread.Result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatSchemaContext

func FormatSchemaContext(schema *api.CatalogSchema) string

FormatSchemaContext converts DataTug's stored schema into a compact prompt fragment. It is deterministic so model and snapshot tests stay stable.

func FormatValue

func FormatValue(value any) string

FormatValue applies basic terminal-safe value formatting.

Types

type ADKConversation

type ADKConversation struct {
	// contains filtered or unexported fields
}

ADKConversation is a persistent in-memory ADK session with one DataTug tool.

func NewADKConversation

func NewADKConversation(llm model.LLM, executor DTQLExecutor, sourceURL, schemaContext string, options ...Option) (*ADKConversation, error)

NewADKConversation builds the constrained chat agent. schemaContext is a compact description derived from DataTug's stored dbmodel.

func (*ADKConversation) Ask

func (c *ADKConversation) Ask(ctx context.Context, prompt string) (Turn, error)

Ask runs one persistent chat turn and returns model text separately from every structured query result captured by the tool callback.

type Conversation

type Conversation interface {
	Ask(context.Context, string) (Turn, error)
}

Conversation is the UI-facing chat seam and is trivial to fake in tests.

type DTQLExecutor

type DTQLExecutor interface {
	RunDTQL(context.Context, string, []byte, map[string]any) (secureread.Result, error)
}

DTQLExecutor is the existing DataTug query boundary used by Chat.

type GridColumn

type GridColumn struct {
	Name    string
	Numeric bool
}

GridColumn is the UI-ready description of a structured result column.

type GridModel

type GridModel struct {
	Columns []GridColumn
	Rows    [][]string
	// contains filtered or unexported fields
}

GridModel is the terminal-grid boundary. Values are formatted only here, after query execution has produced a structured secureread.Result.

func NewGridModel

func NewGridModel(result secureread.Result) GridModel

NewGridModel converts a structured query result into display cells while preserving explicit result-column order.

func (*GridModel) Sort

func (m *GridModel) Sort(column int)

Sort toggles ascending/descending ordering for one visible column.

type Option

type Option func(*conversationConfig) error

Option configures the constrained ADK conversation.

func WithThinkingLevel

func WithThinkingLevel(level string) Option

WithThinkingLevel maps the CLI's provider-neutral effort onto ADK's portable thinking budget. pi-go also receives the original level so providers with their own effort controls can apply it directly.

type QueryResult

type QueryResult struct {
	DTQL   string
	Result secureread.Result
	Err    error
}

QueryResult records one structured tool execution for the UI.

type Turn

type Turn struct {
	Text    string
	Queries []QueryResult
}

Turn is one completed agent turn. Text is model prose; Queries remain structured and are never reconstructed from Text.

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI is the Bubble Tea chat model: a scrollable history viewport, inline Bubbles table components, and a fixed bottom input.

func NewUI

func NewUI(ctx context.Context, conversation Conversation, modelName string) *UI

NewUI creates the terminal chat model without starting a real terminal.

func (*UI) Init

func (u *UI) Init() tea.Cmd

func (*UI) Run

func (u *UI) Run() error

Run starts the Bubble Tea program and blocks until it exits.

func (*UI) Update

func (u *UI) Update(message tea.Msg) (tea.Model, tea.Cmd)

func (*UI) View

func (u *UI) View() tea.View

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL