llm

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginCodexOAuthDeviceCode added in v0.2.6

func LoginCodexOAuthDeviceCode(ctx context.Context) error

func LoginCodexOAuthInteractive added in v0.2.6

func LoginCodexOAuthInteractive(ctx context.Context) error

Types

type ChatResult

type ChatResult struct {
	Content   string
	ToolCalls []ToolCall
}

func (ChatResult) HasToolCalls

func (r ChatResult) HasToolCalls() bool

type Client

type Client struct {
	Provider    string
	BaseURL     string
	APIKey      string
	Model       string
	MaxTokens   int
	Temperature *float64
	Headers     map[string]string
	HTTP        HTTPDoer
}

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, messages []Message, tools []ToolDefinition) (*ChatResult, error)

type CodexOAuthToken added in v0.2.6

type CodexOAuthToken struct {
	AccessToken string
	AccountID   string
}

func LoadCodexOAuthToken added in v0.2.6

func LoadCodexOAuthToken() (CodexOAuthToken, error)

func (CodexOAuthToken) Valid added in v0.2.6

func (t CodexOAuthToken) Valid() bool

type FunctionDefinition

type FunctionDefinition struct {
	Name        string     `json:"name"`
	Description string     `json:"description,omitempty"`
	Parameters  JSONSchema `json:"parameters"`
}

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type JSONSchema

type JSONSchema struct {
	Type        string                `json:"type,omitempty"`
	Description string                `json:"description,omitempty"`
	Properties  map[string]JSONSchema `json:"properties,omitempty"`
	Required    []string              `json:"required,omitempty"`
	Enum        []string              `json:"enum,omitempty"`
	Items       *JSONSchema           `json:"items,omitempty"`

	// Raw can be used when the schema cannot be expressed with this subset.
	// If set, other fields should be left empty.
	Raw json.RawMessage `json:"-"`
}

JSONSchema is a small subset of JSON Schema used for tool parameters.

func (JSONSchema) MarshalJSON

func (s JSONSchema) MarshalJSON() ([]byte, error)

type Message

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

Message is an OpenAI-compatible chat message. We only model the fields clawlet needs.

type ToolCall

type ToolCall struct {
	ID        string
	Name      string
	Arguments json.RawMessage
}

type ToolCallPayload

type ToolCallPayload struct {
	ID       string              `json:"id"`
	Type     string              `json:"type"`
	Function ToolCallPayloadFunc `json:"function"`
}

ToolCallPayload is used inside assistant messages to request tool execution.

type ToolCallPayloadFunc

type ToolCallPayloadFunc struct {
	Name      string `json:"name"`
	Arguments string `json:"arguments"`
}

type ToolDefinition

type ToolDefinition struct {
	Type     string             `json:"type"`
	Function FunctionDefinition `json:"function"`
}

Jump to

Keyboard shortcuts

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