Documentation
¶
Overview ¶
Package openailegacy implements the legacy OpenAI Chat Completions backend connector using github.com/openai/openai-go/v3. It maps lipapi.Call to chat/completions and streams canonical events from the official SSE stream.
Index ¶
- Constants
- func CompletionEvents(comp openai.ChatCompletion) []lipapi.Event
- func New(cfg Config) execbackend.Backend
- func NewChatStream(s *ssestream.Stream[openai.ChatCompletionChunk], maxPending int) lipapi.ManagedEventStream
- func ParamsForCall(call *lipapi.Call, cand routing.AttemptCandidate) (openai.ChatCompletionNewParams, error)
- type Config
Constants ¶
const (
DefaultBaseURL = "https://api.openai.com/v1"
)
const ID = "openai-legacy"
ID is the reserved plugin identifier for the legacy OpenAI-compatible backend.
Variables ¶
This section is empty.
Functions ¶
func CompletionEvents ¶
func CompletionEvents(comp openai.ChatCompletion) []lipapi.Event
CompletionEvents converts a non-streaming ChatCompletion response into canonical events.
func New ¶
func New(cfg Config) execbackend.Backend
New returns a runtime backend that invokes the OpenAI Chat Completions API using openai-go.
func NewChatStream ¶
func NewChatStream(s *ssestream.Stream[openai.ChatCompletionChunk], maxPending int) lipapi.ManagedEventStream
func ParamsForCall ¶
func ParamsForCall(call *lipapi.Call, cand routing.AttemptCandidate) (openai.ChatCompletionNewParams, error)
ParamsForCall builds an OpenAI Chat Completions create payload from a canonical call.
Types ¶
type Config ¶
type Config struct {
BaseURL string
APIKey string
// APIKeys is the ordered credential list for this backend instance.
// When non-empty, APIKey should match APIKeys[0] for SDK compatibility.
APIKeys []string
// Credentials is the structured credential list. When set, it takes precedence
// over APIKey/APIKeys and preserves non-secret credential IDs for diagnostics.
Credentials []credpool.Credential
// HTTPClient is optional; when nil the SDK default is used.
HTTPClient *http.Client
// SDKMaxRetries optionally sets the official SDK MaxRetries (nil = SDK default).
// Integration tests that assert a single upstream attempt on 429/401 should use a pointer to 0.
SDKMaxRetries *int
DefaultVerbosity lipapi.VerbosityLevel
}
Config configures the legacy OpenAI Chat Completions backend connector (official SDK). BaseURL must include the API prefix (e.g. https://api.openai.com/v1).