providers

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package providers defines provider adapters for parsing responses and pricing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnthropicProvider

type AnthropicProvider struct{}

func (AnthropicProvider) EstimateCost

func (AnthropicProvider) EstimateCost(model string, inputTokens, outputTokens int) float64

func (AnthropicProvider) Name

func (AnthropicProvider) Name() string

func (AnthropicProvider) ParseResponse

func (AnthropicProvider) ParseResponse(statusCode int, _ http.Header, body []byte) (*TraceData, error)

func (AnthropicProvider) ParseStreamChunk

func (AnthropicProvider) ParseStreamChunk(chunk []byte) (*StreamChunkData, error)

type OpenAIProvider

type OpenAIProvider struct{}

func (OpenAIProvider) EstimateCost

func (OpenAIProvider) EstimateCost(model string, inputTokens, outputTokens int) float64

func (OpenAIProvider) Name

func (OpenAIProvider) Name() string

func (OpenAIProvider) ParseResponse

func (OpenAIProvider) ParseResponse(statusCode int, _ http.Header, body []byte) (*TraceData, error)

func (OpenAIProvider) ParseStreamChunk

func (OpenAIProvider) ParseStreamChunk(chunk []byte) (*StreamChunkData, error)

type Provider

type Provider interface {
	Name() string
	ParseResponse(statusCode int, headers http.Header, body []byte) (*TraceData, error)
	ParseStreamChunk(chunk []byte) (*StreamChunkData, error)
	EstimateCost(model string, inputTokens, outputTokens int) float64
}

type Registry

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

func DefaultRegistry

func DefaultRegistry() *Registry

func NewRegistry

func NewRegistry(providers ...Provider) *Registry

func (*Registry) Get

func (r *Registry) Get(name string) (Provider, bool)

func (*Registry) Names

func (r *Registry) Names() []string

type StreamChunkData

type StreamChunkData struct {
	Model       string
	DeltaTokens int
}

type TraceData

type TraceData struct {
	StatusCode   int
	Model        string
	InputTokens  int
	OutputTokens int
	TotalTokens  int
}

Jump to

Keyboard shortcuts

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