llm

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func RoughEstimateCodeTokens

func RoughEstimateCodeTokens(text string) int

Types

type LLMClient

type LLMClient interface {
	Send(ctx context.Context, messages []Message) (*LLMSendResponse, error)
	Stream(ctx context.Context, messages []Message) <-chan LLMStreamEvent
}

func NewClient

func NewClient(provider LLMProvider, opts LLMClientOptions) (client LLMClient, err error)

type LLMClientOptions

type LLMClientOptions struct {
	Model string
}

type LLMProvider

type LLMProvider string
const (
	LLMProviderOpenAI LLMProvider = "openai"
	LLMProviderOllama LLMProvider = "ollama"
)

type LLMSendResponse

type LLMSendResponse struct {
	Content string
	Usage   LLMTokenUsage
}

type LLMStreamEvent

type LLMStreamEvent struct {
	Content string
	Usage   LLMTokenUsage
	Type    LLMStreamEventType
}

type LLMStreamEventType

type LLMStreamEventType string
const (
	LLMStreamEventTypeMessage  LLMStreamEventType = "content"
	LLMStreamEventTypeComplete LLMStreamEventType = "complete"
	LLMStreamEventTypeError    LLMStreamEventType = "error"
)

type LLMTokenUsage

type LLMTokenUsage struct {
	InputTokens  int64
	OutputTokens int64
}

type Message

type Message struct {
	Role    MessageRole
	Content string
	Hidden  bool
}

type MessageRole

type MessageRole string
const (
	Assistant MessageRole = "assistant"
	User      MessageRole = "user"
	System    MessageRole = "system"
)

Jump to

Keyboard shortcuts

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