openai_compat

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtraContent

type ExtraContent = protocoltypes.ExtraContent

type FunctionCall

type FunctionCall = protocoltypes.FunctionCall

type GoogleExtra

type GoogleExtra = protocoltypes.GoogleExtra

type LLMResponse

type LLMResponse = protocoltypes.LLMResponse

type Message

type Message = protocoltypes.Message

type Option

type Option func(*Provider)

func WithExtraBody

func WithExtraBody(extraBody map[string]any) Option

func WithMaxTokensField

func WithMaxTokensField(maxTokensField string) Option

func WithProviderName

func WithProviderName(providerName string) Option

func WithStreamedChat

func WithStreamedChat() Option

WithStreamedChat makes Chat stream its request and return the answer the stream assembles, for an upstream whose streamed answer is complete where its plain one may not be.

type Provider

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

Provider is Compa's chat client: it shapes Chat Completions requests from the agent's messages, tools and options, and parses the answers, streamed or not, tool calls and reasoning included. It never addresses an upstream itself: its HTTP client's transport hands every request to the provider instance's llmgw-core provider (see coretransport), which owns the endpoint, the credential, the proxy and the vendor's wire.

func NewProvider

func NewProvider(endpoint string, client *http.Client, opts ...Option) *Provider

NewProvider returns the chat client of an instance at endpoint, sending its requests with client, whose transport reaches the instance's core provider.

func (*Provider) Chat

func (p *Provider) Chat(
	ctx context.Context,
	messages []Message,
	tools []ToolDefinition,
	model string,
	options map[string]any,
) (*LLMResponse, error)

func (*Provider) ChatStream

func (p *Provider) ChatStream(
	ctx context.Context,
	messages []Message,
	tools []ToolDefinition,
	model string,
	options map[string]any,
	onChunk func(accumulated string),
) (*LLMResponse, error)

ChatStream implements streaming via OpenAI-compatible SSE (stream: true). onChunk receives the accumulated text so far on each text delta.

func (*Provider) ChatStreamEvents

func (p *Provider) ChatStreamEvents(
	ctx context.Context,
	messages []Message,
	tools []ToolDefinition,
	model string,
	options map[string]any,
	onChunk func(StreamChunk),
) (*LLMResponse, error)

func (*Provider) GetDefaultModel

func (p *Provider) GetDefaultModel() string

GetDefaultModel returns "": every call names its model.

func (*Provider) SetProviderName

func (p *Provider) SetProviderName(providerName string)

func (*Provider) SupportsNativeSearch

func (p *Provider) SupportsNativeSearch() bool

func (*Provider) SupportsThinking

func (p *Provider) SupportsThinking() bool

type ReasoningDetail

type ReasoningDetail = protocoltypes.ReasoningDetail

type StreamChunk

type StreamChunk = protocoltypes.StreamChunk

type ToolCall

type ToolCall = protocoltypes.ToolCall

type ToolDefinition

type ToolDefinition = protocoltypes.ToolDefinition

type ToolFunctionDefinition

type ToolFunctionDefinition = protocoltypes.ToolFunctionDefinition

type UsageInfo

type UsageInfo = protocoltypes.UsageInfo

Jump to

Keyboard shortcuts

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