openaicompat

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package openaicompat implements the OpenAI Chat Completions-compatible wire protocol behind AgentSlot's provider-neutral ModelExecutor contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModule

func NewModule(config Config) (agentslot.Module, error)

NewModule contributes one real Executor and its UI-facing catalog. The provider wire adapter remains explicit; importing this package changes no Assembly.

Types

type Config

type Config struct {
	ProviderKey   string
	BaseURL       string
	CredentialRef credential.Ref
	// CredentialResolver is accepted only by New for direct construction.
	// NewModule resolves CredentialRef through credential.resolver instead.
	CredentialResolver credential.Resolver
	Models             []Model
	HTTPClient         *http.Client
	MaxAttempts        int
	RetryBackoff       time.Duration
	RequestTimeout     time.Duration
	MaxEventBytes      int
	MaxOutputBytes     int
	// MaxAttachmentBytes bounds each artifact opened for a provider request.
	// Zero uses the adapter default. The Store may enforce a lower limit.
	MaxAttachmentBytes int64
	ArtifactStore      artifact.ArtifactStore
}

type Executor

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

func New

func New(config Config) (*Executor, error)

func (*Executor) CountTokens deprecated

func (e *Executor) CountTokens(ctx context.Context, request model.ModelRequest) (int, error)

CountTokens preserves the concrete Executor API used before token counting became an independently replaceable Slot. Runtime composition must resolve model.TokenCounterSlot instead of relying on this convenience method.

Deprecated: construct TokenCounter with NewTokenCounter or resolve model.TokenCounterSlot from an Assembly.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, request model.ModelRequest, recorder model.AttemptRecorder) (model.ModelStream, error)

func (*Executor) Inspect

func (e *Executor) Inspect(ctx context.Context, config model.Config) (model.ExecutionCapabilities, error)

func (*Executor) Models

func (e *Executor) Models(ctx context.Context) ([]model.Descriptor, error)

type Model

type Model struct {
	ID           string
	Title        string
	Capabilities model.ExecutionCapabilities
}

type TokenCounter added in v0.1.0

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

TokenCounter owns planning-time measurement for the exact wire projection produced by this adapter. It is deliberately exposed separately from Executor so applications can replace counting without replacing execution.

func NewTokenCounter added in v0.1.0

func NewTokenCounter(config Config) (*TokenCounter, error)

NewTokenCounter constructs the counter paired with this provider adapter.

func (*TokenCounter) CountTokens added in v0.1.0

func (c *TokenCounter) CountTokens(ctx context.Context, request model.ModelRequest) (int, error)

Jump to

Keyboard shortcuts

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