llm

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithExtraHeaders

func WithExtraHeaders(ctx context.Context, headers map[string]string) context.Context

WithExtraHeaders attaches outbound header overlays for provider HTTP calls.

Types

type AnthropicClient

type AnthropicClient struct {
	HTTP    *http.Client
	Secrets secrets.Resolver
}

func NewAnthropicClient

func NewAnthropicClient(sec secrets.Resolver) *AnthropicClient

func (*AnthropicClient) ChatIR

func (c *AnthropicClient) ChatIR(ctx context.Context, provider snapshot.Provider, targetModel string, req ir.ChatRequest) (ir.ChatResult, error)

ChatIR runs chat against Anthropic Messages using IR.

func (*AnthropicClient) Messages

func (c *AnthropicClient) Messages(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte, stream bool) (*http.Response, error)

Messages translates an OpenAI-shaped chat body to Anthropic /v1/messages and returns an OpenAI-shaped chat completion response (JSON or SSE).

func (*AnthropicClient) PassThrough

func (c *AnthropicClient) PassThrough(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte, stream bool) (*http.Response, error)

PassThrough forwards an Anthropic-shaped /v1/messages body to upstream, rewriting only the model field to targetModel.

type AzureOpenAIClient

type AzureOpenAIClient struct {
	HTTP    *http.Client
	Secrets secrets.Resolver
}

AzureOpenAIClient talks to Azure OpenAI using either the classic deployments API or the OpenAI v1-compatible path layout, selected via provider config.

func NewAzureOpenAIClient

func NewAzureOpenAIClient(sec secrets.Resolver) *AzureOpenAIClient

func (*AzureOpenAIClient) AudioSpeech

func (c *AzureOpenAIClient) AudioSpeech(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

func (*AzureOpenAIClient) AudioTranscriptions

func (c *AzureOpenAIClient) AudioTranscriptions(ctx context.Context, provider snapshot.Provider, targetModel, contentType string, body io.Reader) (*http.Response, error)

func (*AzureOpenAIClient) ChatCompletions

func (c *AzureOpenAIClient) ChatCompletions(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte, stream bool) (*http.Response, error)

func (*AzureOpenAIClient) ChatIR

func (c *AzureOpenAIClient) ChatIR(ctx context.Context, provider snapshot.Provider, targetModel string, req ir.ChatRequest) (ir.ChatResult, error)

ChatIR runs chat against Azure OpenAI using OpenAI-shaped IR encode/decode.

func (*AzureOpenAIClient) Embeddings

func (c *AzureOpenAIClient) Embeddings(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

func (*AzureOpenAIClient) Images

func (c *AzureOpenAIClient) Images(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

type BedrockClient

type BedrockClient struct {
	Secrets secrets.Resolver
	// API is optional; when nil, a client is built per request from provider config.
	API BedrockConverseAPI
	// NewAPI builds a Bedrock Runtime client; tests may override.
	NewAPI func(ctx context.Context, provider snapshot.Provider) (BedrockConverseAPI, error)
}

BedrockClient calls Amazon Bedrock Converse / ConverseStream.

func NewBedrockClient

func NewBedrockClient(sec secrets.Resolver) *BedrockClient

NewBedrockClient constructs a Bedrock adapter with a shared secret resolver.

func (*BedrockClient) ChatIR

func (c *BedrockClient) ChatIR(ctx context.Context, provider snapshot.Provider, targetModel string, req ir.ChatRequest) (ir.ChatResult, error)

ChatIR runs chat against Bedrock Converse using IR.

type BedrockConverseAPI

type BedrockConverseAPI interface {
	Converse(ctx context.Context, params *bedrockruntime.ConverseInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.ConverseOutput, error)
	ConverseStream(ctx context.Context, params *bedrockruntime.ConverseStreamInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.ConverseStreamOutput, error)
}

BedrockConverseAPI is the subset of Bedrock Runtime used by BedrockClient.

type ElevenLabsClient

type ElevenLabsClient struct {
	HTTP    *http.Client
	Secrets secrets.Resolver
}

ElevenLabsClient calls ElevenLabs TTS/STT APIs, translating OpenAI audio dialect bodies.

func NewElevenLabsClient

func NewElevenLabsClient(sec secrets.Resolver) *ElevenLabsClient

NewElevenLabsClient constructs an ElevenLabs adapter with a shared secret resolver.

func (*ElevenLabsClient) AudioSpeech

func (c *ElevenLabsClient) AudioSpeech(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

AudioSpeech translates OpenAI /v1/audio/speech JSON to ElevenLabs text-to-speech.

OpenAI body fields: model, input, voice, response_format, speed ElevenLabs: POST /v1/text-to-speech/{voice_id}?output_format=… with {text, model_id}

func (*ElevenLabsClient) AudioTranscriptions

func (c *ElevenLabsClient) AudioTranscriptions(ctx context.Context, provider snapshot.Provider, targetModel, contentType string, body io.Reader) (*http.Response, error)

AudioTranscriptions translates OpenAI multipart transcriptions to ElevenLabs speech-to-text.

OpenAI fields: model, file, language, … ElevenLabs: POST /v1/speech-to-text with model_id + file (+ language_code).

type GeminiClient

type GeminiClient struct {
	HTTP    *http.Client
	Secrets secrets.Resolver
}

func NewGeminiClient

func NewGeminiClient(sec secrets.Resolver) *GeminiClient

func (*GeminiClient) ChatIR

func (c *GeminiClient) ChatIR(ctx context.Context, provider snapshot.Provider, targetModel string, req ir.ChatRequest) (ir.ChatResult, error)

ChatIR runs chat against Gemini generateContent using IR.

func (*GeminiClient) GenerateContent

func (c *GeminiClient) GenerateContent(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte, stream bool) (*http.Response, error)

GenerateContent translates OpenAI chat → Gemini generateContent / streamGenerateContent.

type OpenAIClient

type OpenAIClient struct {
	HTTP    *http.Client
	Secrets secrets.Resolver
}

func NewOpenAIClient

func NewOpenAIClient(sec secrets.Resolver) *OpenAIClient

func (*OpenAIClient) AudioSpeech

func (c *OpenAIClient) AudioSpeech(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

func (*OpenAIClient) AudioTranscriptions

func (c *OpenAIClient) AudioTranscriptions(ctx context.Context, provider snapshot.Provider, targetModel, contentType string, body io.Reader) (*http.Response, error)

func (*OpenAIClient) ChatCompletions

func (c *OpenAIClient) ChatCompletions(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte, stream bool) (*http.Response, error)

func (*OpenAIClient) ChatIR

func (c *OpenAIClient) ChatIR(ctx context.Context, provider snapshot.Provider, targetModel string, req ir.ChatRequest) (ir.ChatResult, error)

ChatIR runs chat against an OpenAI-compatible upstream using IR.

func (*OpenAIClient) Embeddings

func (c *OpenAIClient) Embeddings(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

func (*OpenAIClient) Images

func (c *OpenAIClient) Images(ctx context.Context, provider snapshot.Provider, targetModel string, body []byte) (*http.Response, error)

Jump to

Keyboard shortcuts

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