openai

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrIncompleteStream means a provider closed without a terminal response event.
	ErrIncompleteStream = errors.New("incomplete provider stream")
	// ErrMalformedStream means a provider emitted invalid SSE event JSON.
	ErrMalformedStream = errors.New("malformed provider stream")
)

Functions

This section is empty.

Types

type APIStatusError

type APIStatusError struct {
	Status int
	Body   string
	Code   string
}

APIStatusError conveys an HTTP error response from an upstream LLM API. Use errors.As to extract structured status/body details from a wrapped chain.

func (*APIStatusError) Error

func (e *APIStatusError) Error() string

func (*APIStatusError) ProviderErrorCode

func (e *APIStatusError) ProviderErrorCode() string

ProviderErrorCode implements tacklr.ProviderStatus.

func (*APIStatusError) ProviderHTTPStatus

func (e *APIStatusError) ProviderHTTPStatus() int

ProviderHTTPStatus implements tacklr.ProviderStatus.

type OpenAIInferenceStrategy

type OpenAIInferenceStrategy struct {

	// CacheKey is prompt_cache_key (and x-grok-conv-id on xAI). Durable session id.
	CacheKey string
	// contains filtered or unexported fields
}

func NewOpenAIInferenceStrategy

func NewOpenAIInferenceStrategy(client *http.Client) *OpenAIInferenceStrategy

func NewOpenRouterInferenceStrategy

func NewOpenRouterInferenceStrategy(client *http.Client) *OpenAIInferenceStrategy

NewOpenRouterInferenceStrategy returns an OpenAI Responses strategy preconfigured for OpenRouter.

OpenRouter validates prompt_cache_options.mode and rejects "implicit", so the strategy pins a key-only cache profile: prompt_cache_key is sent, while the GPT-5.6 cache options and content-block breakpoints stay off the wire.

func (*OpenAIInferenceStrategy) Clone

Clone returns a strategy the harness can mutate per turn. Parent and child turns share the host strategy and run at the same time. The copy keeps the HTTP client and model settings. Cache key and instructions stay on the copy.

func (*OpenAIInferenceStrategy) CountTokens

func (s *OpenAIInferenceStrategy) CountTokens(ctx context.Context, messages []*tacklr.Message, tools []*tacklr.Tool) (int, error)

func (*OpenAIInferenceStrategy) Invoke

func (s *OpenAIInferenceStrategy) Invoke(ctx context.Context, messages []*tacklr.Message, tools []*tacklr.Tool, systemPrompt string) (chan tacklr.LLMResponseChunk, error)

func (*OpenAIInferenceStrategy) MaxContextWindow

func (s *OpenAIInferenceStrategy) MaxContextWindow() (int, error)

func (*OpenAIInferenceStrategy) ModelTelemetryIdentity

func (s *OpenAIInferenceStrategy) ModelTelemetryIdentity() telemetry.ModelIdentity

ModelTelemetryIdentity implements the optional harness hook so model spans get GenAI provider/model attrs without exporting raw config fields.

func (*OpenAIInferenceStrategy) SetPromptCacheKey

func (s *OpenAIInferenceStrategy) SetPromptCacheKey(key string)

SetPromptCacheKey is the harness hook (tacklr cannot import this package).

func (*OpenAIInferenceStrategy) SetSystemPrompt

func (s *OpenAIInferenceStrategy) SetSystemPrompt(prompt string)

func (*OpenAIInferenceStrategy) SupportsMIME

func (s *OpenAIInferenceStrategy) SupportsMIME(mimeType string) bool

SupportsMIME implements tacklr.InferenceStrategy for the selected model id.

func (*OpenAIInferenceStrategy) WithApiKey

func (*OpenAIInferenceStrategy) WithLocalTokenFallback

func (s *OpenAIInferenceStrategy) WithLocalTokenFallback() *OpenAIInferenceStrategy

WithLocalTokenFallback counts tokens with tiktoken when the provider returns 404/400/422 for /responses/input_tokens. Off by default.

func (*OpenAIInferenceStrategy) WithModel

func (*OpenAIInferenceStrategy) WithReasoningLevel

func (s *OpenAIInferenceStrategy) WithReasoningLevel(level string) *OpenAIInferenceStrategy

func (*OpenAIInferenceStrategy) WithReasoningSummary

func (s *OpenAIInferenceStrategy) WithReasoningSummary(summary string) *OpenAIInferenceStrategy

WithReasoningSummary sets reasoning.summary on Responses API requests ("auto", "concise", "detailed"). Empty clears it.

func (*OpenAIInferenceStrategy) WithURL

Jump to

Keyboard shortcuts

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