internal

package
v0.0.0-...-837e5df Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSystemPrompt string

DefaultSystemPrompt is used when no custom --prompt file is provided.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger *zap.Logger) context.Context

ContextWithLogger adds a logger to the context

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *zap.Logger

LoggerFromContext extracts the logger from the context

func NewLogger

func NewLogger(level zapcore.Level, format LogFormat) (*zap.Logger, error)

NewLogger creates a new zap logger with the given level and format

Types

type AnthropicLLMClient

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

AnthropicLLMClient handles communication with the Anthropic API

func NewAnthropicLLMClient

func NewAnthropicLLMClient(apiKey string, model string, opts map[string]string, systemPrompt string) *AnthropicLLMClient

NewAnthropicLLMClient creates a new Anthropic LLM client. Supported options:

  • "effort": output effort level (low, medium, high, max). Defaults to "low".
  • "thinking": extended thinking budget in tokens (e.g. "10000"). Minimum 1024.

func (*AnthropicLLMClient) Query

func (c *AnthropicLLMClient) Query(ctx context.Context, queryString string) (*LLMResponse, error)

Query sends a query to the Anthropic API and returns the structured response

type Column

type Column struct {
	Name   string `json:"name" jsonschema:"column name"`
	Type   string `json:"type" jsonschema:"PostgreSQL type name: text, int4, int8, float8, float4, int2, bool, timestamp, date, uuid, varchar"`
	Length int    `` /* 140-byte string literal not displayed */
}

Column represents a column definition

type Connection

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

Connection represents a single client connection

func NewConnection

func NewConnection(conn net.Conn, systemPrompt string, tlsConfig *tls.Config) *Connection

NewConnection creates a new Connection instance

func (*Connection) Handle

func (c *Connection) Handle(ctx context.Context) error

Handle processes the connection lifecycle

type LLMClient

type LLMClient interface {
	Query(ctx context.Context, queryString string) (*LLMResponse, error)
}

LLMClient is the interface for all LLM provider clients.

type LLMResponse

type LLMResponse struct {
	Results []ResultSet `json:"results" jsonschema:"array of result sets, one per SQL statement"`
}

LLMResponse represents the structured output from the LLM

type LogFormat

type LogFormat string

LogFormat represents the output format for the logger.

const (
	LogFormatConsole LogFormat = "console"
	LogFormatJSON    LogFormat = "json"
)

func (LogFormat) MarshalText

func (f LogFormat) MarshalText() ([]byte, error)

func (*LogFormat) UnmarshalText

func (f *LogFormat) UnmarshalText(text []byte) error

type OpenAILLMClient

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

OpenAILLMClient handles communication with the OpenAI API

func NewOpenAILLMClient

func NewOpenAILLMClient(apiKey string, model string, opts map[string]string, systemPrompt string) *OpenAILLMClient

NewOpenAILLMClient creates a new OpenAI LLM client. It reads the "reasoning_effort" option from opts; if absent, defaults to the lowest supported effort for the model.

func (*OpenAILLMClient) Query

func (c *OpenAILLMClient) Query(ctx context.Context, queryString string) (*LLMResponse, error)

Query sends a query to the OpenAI API and returns the structured response

type ResultSet

type ResultSet struct {
	Columns    []Column    `json:"columns" jsonschema:"column definitions; empty for non-SELECT statements"`
	Rows       [][]*string `` /* 198-byte string literal not displayed */
	CommandTag string      `json:"command_tag" jsonschema:"PostgreSQL command tag like SELECT 3, INSERT 0 1, UPDATE 2, DELETE 1, CREATE TABLE"`
}

ResultSet represents a single SQL statement's result

type Server

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

Server handles incoming TCP connections and manages connection lifecycle

func NewServer

func NewServer(host string, port int, systemPrompt string, tlsConfig *tls.Config) *Server

NewServer creates a new Server instance. If tlsConfig is non-nil, the server will accept SSL upgrades during the PostgreSQL startup handshake.

func (*Server) Close

func (s *Server) Close()

Close terminates all active connections and waits for cleanup

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start begins accepting connections and blocks until ctx is cancelled

Jump to

Keyboard shortcuts

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