llm

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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