ai

package
v1.20.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MaxToolFeedbackRunes = 4096
View Source
const SystemPromptTemplate = `` /* 1157-byte string literal not displayed */

Variables

This section is empty.

Functions

func BoundToolFeedback

func BoundToolFeedback(value string) string

BoundToolFeedback limits locally computed tool output before it is sent to the remote model. The complete output remains available in the local TUI.

func BuildSystemPrompt

func BuildSystemPrompt(dbType string, schemaInfo *db.SchemaInfo, catalog string) string

func FormatDBName

func FormatDBName(dbType string) string

Types

type AIResponse

type AIResponse struct {
	Type        ResponseType `json:"type"`
	SQL         string       `json:"sql,omitempty"`
	JSCode      string       `json:"js_code,omitempty"`
	DatasetID   string       `json:"dataset_id,omitempty"`
	Format      string       `json:"format,omitempty"`
	FilePath    string       `json:"filepath,omitempty"`
	Content     string       `json:"content,omitempty"`
	Explanation string       `json:"explanation"`
	Actions     []ToolAction `json:"actions,omitempty"`
}

type ChatMessage

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Client

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

func NewClient

func NewClient(cfg config.AIConfig, httpClient *http.Client) *Client

func (*Client) ChatCompletion

func (c *Client) ChatCompletion(ctx context.Context, messages []ChatMessage) (*AIResponse, *errors.XError)

type ResponseType

type ResponseType string
const (
	TypeSQL    ResponseType = "sql"
	TypeJS     ResponseType = "js"
	TypeExport ResponseType = "export"
	TypeReport ResponseType = "report"
	TypeText   ResponseType = "text"
)

type SQLResponse

type SQLResponse = AIResponse

type Service

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

func NewService

func NewService(cfg config.AIConfig, client *Client) *Service

func (*Service) ChatCompletion

func (s *Service) ChatCompletion(ctx context.Context, messages []ChatMessage) (*AIResponse, *errors.XError)

func (*Service) GenerateResponse

func (s *Service) GenerateResponse(ctx context.Context, userPrompt string, schemaInfo *db.SchemaInfo, dbType string, catalog string) (*AIResponse, *errors.XError)

func (*Service) GenerateSQL

func (s *Service) GenerateSQL(ctx context.Context, userPrompt string, schemaInfo *db.SchemaInfo, dbType string) (*AIResponse, *errors.XError)

type ToolAction added in v1.20.1

type ToolAction struct {
	ID          string       `json:"id,omitempty"`
	Type        ResponseType `json:"type"`
	SQL         string       `json:"sql,omitempty"`
	JSCode      string       `json:"js_code,omitempty"`
	DatasetID   string       `json:"dataset_id,omitempty"`
	Format      string       `json:"format,omitempty"`
	FilePath    string       `json:"filepath,omitempty"`
	Content     string       `json:"content,omitempty"`
	Explanation string       `json:"explanation,omitempty"`
}

Jump to

Keyboard shortcuts

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