openaipreset

package
v1.32.0 Latest Latest
Warning

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

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
var ErrResponsesJSONRequired = errors.New("openaipreset: responses JSON transport required")

ErrResponsesJSONRequired는 strict Responses JSON contract를 fallback 없이 충족할 수 없을 때 반환된다.

Functions

func UsageFromResponseUsage

func UsageFromResponseUsage(usage *responses.ResponseUsage) sharedllm.Usage

Types

type Client

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

func New

func New(baseURL, apiKey, model string, opts ...Option) (*Client, error)

func (*Client) Complete

func (*Client) GenerateJSON

func (c *Client) GenerateJSON(ctx context.Context, systemPrompt, userPrompt string, schema map[string]any) (string, error)

func (*Client) GenerateJSONInto added in v1.29.0

func (c *Client) GenerateJSONInto(
	ctx context.Context,
	task string,
	prompts PromptLayers,
	schema map[string]any,
	out any,
) error

func (*Client) GenerateLayeredResponsesJSON added in v1.30.1

func (c *Client) GenerateLayeredResponsesJSON(ctx context.Context, task string, prompts PromptLayers, schema map[string]any) (string, error)

GenerateLayeredResponsesJSON returns every Responses output_text fragment before object extraction or destination decoding. It is intentionally strict: callers using this boundary can validate the complete provider surface first.

func (*Client) Model

func (c *Client) Model() string

func (*Client) RunInto

func (c *Client) RunInto(ctx context.Context, task, prompt string, schema map[string]any, out any) error

type CompletionRequest

type CompletionRequest struct {
	Messages           []Message
	Model              string
	Temperature        *float64
	ReasoningEffort    string
	WebSearch          bool
	CacheKey           string
	ResponseFormat     *ResponseFormat
	InstructionProfile *sharedllm.InstructionProfile
}

type CompletionResponse

type CompletionResponse struct {
	Text  string
	Model string
	Usage sharedllm.Usage
}

func CompletionFromResponse

func CompletionFromResponse(resp *responses.Response, requestedModel string) CompletionResponse

type Message

type Message = sharedllm.Message

type Option

type Option func(*config)

func WithAllowChatCompletionsFallback

func WithAllowChatCompletionsFallback(enabled bool) Option

func WithChatCompletions

func WithChatCompletions() Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

func WithReasoningEffort

func WithReasoningEffort(effort string) Option

func WithSchemaName

func WithSchemaName(name string) Option

func WithTemperature

func WithTemperature(temperature float64) Option

func WithUsageReporter

func WithUsageReporter(reporter sharedllm.UsageReporter) Option

func WithWebSearch

func WithWebSearch(enabled bool) Option

type PromptLayers added in v1.29.0

type PromptLayers struct {
	Invariant string
	Developer string
	User      string
}

type ResponseFormat

type ResponseFormat struct {
	Name   string
	Schema map[string]any
	Strict bool
}

Jump to

Keyboard shortcuts

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