llm

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDiagnosticLimit = 4096
)

Variables

View Source
var (
	ErrNilContext         = errors.New("llm: context is nil")
	ErrNilJSONGenerator   = errors.New("llm: json generator is nil")
	ErrInvalidJSONRequest = errors.New("llm: invalid json request")
)
View Source
var (
	ErrOpenAIEmptyOutput   = errors.New("llm: openai empty output")
	ErrOpenAIRefusalOutput = errors.New("llm: openai refusal output")
)

Functions

func RedactDiagnostic

func RedactDiagnostic(text string, limit int) string

func ValidateJSONRequest

func ValidateJSONRequest(req JSONRequest) error

Types

type JSONGenerator

type JSONGenerator interface {
	GenerateJSON(ctx context.Context, req JSONRequest) (JSONResponse, error)
}

type JSONRequest

type JSONRequest struct {
	TaskName        string
	SystemPrompt    string
	UserPrompt      string
	SchemaName      string
	Schema          map[string]any
	Model           string
	Temperature     *float64
	ReasoningEffort string
	WebSearch       bool
	ChatCompletions bool
}

type JSONResponse

type JSONResponse struct {
	Text         string
	Model        string
	Usage        Usage
	FallbackUsed bool
}

func RunJSON

func RunJSON(ctx context.Context, generator JSONGenerator, req JSONRequest, provider string, reporter UsageReporter) (JSONResponse, error)

type NoopUsageReporter

type NoopUsageReporter struct{}

func (NoopUsageReporter) RecordUsage

type OpenAICompatibleConfig

type OpenAICompatibleConfig struct {
	BaseURL                      string
	APIKey                       string
	HTTPClient                   *http.Client
	AllowChatCompletionsFallback bool
}

type OpenAICompatibleJSONGenerator

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

func (*OpenAICompatibleJSONGenerator) GenerateJSON

type Usage

type Usage struct {
	InputTokens           int
	OutputTokens          int
	TotalTokens           int
	CachedInputTokens     int
	ReasoningOutputTokens int
}

type UsageReporter

type UsageReporter interface {
	RecordUsage(ctx context.Context, provider, model string, usage Usage)
}

Directories

Path Synopsis
Package openaipreset는 pkg/llm의 OpenAI 호환 JSON 생성 경로를 functional-options 클라이언트로 감싼 재사용 프리셋이다.
Package openaipreset는 pkg/llm의 OpenAI 호환 JSON 생성 경로를 functional-options 클라이언트로 감싼 재사용 프리셋이다.

Jump to

Keyboard shortcuts

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