llm

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EstimateTokens

func EstimateTokens(text string) int

func MapToolToParam

func MapToolToParam(name, desc string, schema json.RawMessage) openai.ChatCompletionToolParam

Types

type Client

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

func NewClient

func NewClient(baseURL, token, model string) *Client

func (*Client) ChatStream

func (c *Client) ChatStream(ctx context.Context, messages []Message, tools []openai.ChatCompletionToolParam) <-chan Delta

func (*Client) GetModel

func (c *Client) GetModel() string

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context) ([]string, error)

func (*Client) SetProgram

func (c *Client) SetProgram(p *tea.Program)

func (*Client) UpdateConfig

func (c *Client) UpdateConfig(baseURL, token, model string)

func (*Client) ValidateCredentials

func (c *Client) ValidateCredentials(ctx context.Context) error

type Delta

type Delta struct {
	Type     string
	Text     string
	ToolName string
	ToolArgs string
	ToolID   string
}

type Message

type Message struct {
	Role       string     `json:"role"`
	Content    string     `json:"content,omitempty"`
	ToolCalls  []ToolCall `json:"tool_calls,omitempty"`
	ToolCallID string     `json:"tool_call_id,omitempty"`
}

type RetryConfig

type RetryConfig struct {
	MaxAttempts int
	BaseDelay   time.Duration
	MaxDelay    time.Duration
	Multiplier  float64
}

type RetryMsg

type RetryMsg struct {
	Message string
	Error   bool
}

type ToolCall

type ToolCall struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Args string `json:"args"`
}

type ToolResult

type ToolResult struct {
	ToolCallID string `json:"tool_call_id"`
	Content    string `json:"content"`
}

Jump to

Keyboard shortcuts

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