Documentation
¶
Overview ¶
Package vmodelclient provides in-process implementations of the client interfaces backed by vmodel registries. They let virtual providers traverse the exact same dispatch path as real upstream providers — no short-circuits, no HTTP overhead.
Index ¶
- type AnthropicClient
- func (c *AnthropicClient) APIStyle() protocol.APIStyle
- func (c *AnthropicClient) BetaMessagesCountTokens(_ context.Context, _ *anthropic.BetaMessageCountTokensParams) (*anthropic.BetaMessageTokensCount, error)
- func (c *AnthropicClient) BetaMessagesNew(ctx context.Context, req *anthropic.BetaMessageNewParams) (*anthropic.BetaMessage, error)
- func (c *AnthropicClient) BetaMessagesNewStreaming(ctx context.Context, req *anthropic.BetaMessageNewParams) *anthropicstream.Stream[anthropic.BetaRawMessageStreamEventUnion]
- func (c *AnthropicClient) Client() *anthropic.Client
- func (c *AnthropicClient) Close() error
- func (c *AnthropicClient) GetProvider() *typ.Provider
- func (c *AnthropicClient) ListModels(_ context.Context) ([]string, error)
- func (c *AnthropicClient) MessagesCountTokens(_ context.Context, _ *anthropic.MessageCountTokensParams) (*anthropic.MessageTokensCount, error)
- func (c *AnthropicClient) MessagesNew(ctx context.Context, req *anthropic.MessageNewParams) (*anthropic.Message, error)
- func (c *AnthropicClient) MessagesNewStreaming(ctx context.Context, req *anthropic.MessageNewParams) *anthropicstream.Stream[anthropic.MessageStreamEventUnion]
- func (c *AnthropicClient) SetRecordSink(_ *obs.Sink)
- type OpenAIClient
- func (c *OpenAIClient) APIStyle() protocol.APIStyle
- func (c *OpenAIClient) ChatCompletionsNew(ctx context.Context, req openai.ChatCompletionNewParams) (*openai.ChatCompletion, error)
- func (c *OpenAIClient) ChatCompletionsNewStreaming(ctx context.Context, req openai.ChatCompletionNewParams) *openaistream.Stream[openai.ChatCompletionChunk]
- func (c *OpenAIClient) Client() *openai.Client
- func (c *OpenAIClient) Close() error
- func (c *OpenAIClient) EmbeddingsNew(_ context.Context, _ openai.EmbeddingNewParams) (*openai.CreateEmbeddingResponse, error)
- func (c *OpenAIClient) GetProvider() *typ.Provider
- func (c *OpenAIClient) ImagesGenerate(_ context.Context, _ openai.ImageGenerateParams) (*openai.ImagesResponse, error)
- func (c *OpenAIClient) ListModels(_ context.Context) ([]string, error)
- func (c *OpenAIClient) ResponsesNew(_ context.Context, _ responses.ResponseNewParams) (*responses.Response, error)
- func (c *OpenAIClient) ResponsesNewStreaming(_ context.Context, _ responses.ResponseNewParams) *openaistream.Stream[responses.ResponseStreamEventUnion]
- func (c *OpenAIClient) SetRecordSink(_ *obs.Sink)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicClient ¶
type AnthropicClient struct {
// contains filtered or unexported fields
}
AnthropicClient implements client.AnthropicClientInterface using the in-process vmodel Anthropic registry. No HTTP, no auth.
func NewAnthropicClient ¶
func NewAnthropicClient(reg *anthropicvm.Registry, provider *typ.Provider) *AnthropicClient
NewAnthropicClient creates an in-process Anthropic vmodel client backed by reg.
func (*AnthropicClient) APIStyle ¶
func (c *AnthropicClient) APIStyle() protocol.APIStyle
func (*AnthropicClient) BetaMessagesCountTokens ¶
func (c *AnthropicClient) BetaMessagesCountTokens(_ context.Context, _ *anthropic.BetaMessageCountTokensParams) (*anthropic.BetaMessageTokensCount, error)
func (*AnthropicClient) BetaMessagesNew ¶
func (c *AnthropicClient) BetaMessagesNew(ctx context.Context, req *anthropic.BetaMessageNewParams) (*anthropic.BetaMessage, error)
BetaMessagesNew calls the vmodel synchronously and returns an *anthropic.BetaMessage built via JSON round-trip.
func (*AnthropicClient) BetaMessagesNewStreaming ¶
func (c *AnthropicClient) BetaMessagesNewStreaming(ctx context.Context, req *anthropic.BetaMessageNewParams) *anthropicstream.Stream[anthropic.BetaRawMessageStreamEventUnion]
BetaMessagesNewStreaming wraps vm.HandleAnthropicStream with a channel-based decoder so the caller gets a standard anthropicstream.Stream.
func (*AnthropicClient) Client ¶
func (c *AnthropicClient) Client() *anthropic.Client
func (*AnthropicClient) Close ¶
func (c *AnthropicClient) Close() error
func (*AnthropicClient) GetProvider ¶
func (c *AnthropicClient) GetProvider() *typ.Provider
func (*AnthropicClient) ListModels ¶
func (c *AnthropicClient) ListModels(_ context.Context) ([]string, error)
func (*AnthropicClient) MessagesCountTokens ¶
func (c *AnthropicClient) MessagesCountTokens(_ context.Context, _ *anthropic.MessageCountTokensParams) (*anthropic.MessageTokensCount, error)
func (*AnthropicClient) MessagesNew ¶
func (c *AnthropicClient) MessagesNew(ctx context.Context, req *anthropic.MessageNewParams) (*anthropic.Message, error)
MessagesNew handles v1 (non-beta) Anthropic messages by lifting the params to beta, delegating to BetaMessagesNew, then converting the BetaMessage result to a Message (both share the same wire shape for the fields vmodel produces).
func (*AnthropicClient) MessagesNewStreaming ¶
func (c *AnthropicClient) MessagesNewStreaming(ctx context.Context, req *anthropic.MessageNewParams) *anthropicstream.Stream[anthropic.MessageStreamEventUnion]
MessagesNewStreaming handles v1 streaming by lifting params to beta and reusing the beta decoder. MessageStreamEventUnion and BetaRawMessageStreamEventUnion share the same SSE wire format, so the same decoder drives both stream types.
func (*AnthropicClient) SetRecordSink ¶
func (c *AnthropicClient) SetRecordSink(_ *obs.Sink)
type OpenAIClient ¶
type OpenAIClient struct {
// contains filtered or unexported fields
}
OpenAIClient implements client.OpenAIClientInterface using the in-process vmodel OpenAI registry. No HTTP, no auth — just direct function calls.
func NewOpenAIClient ¶
func NewOpenAIClient(reg *openaivm.Registry, provider *typ.Provider) *OpenAIClient
NewOpenAIClient creates an in-process OpenAI vmodel client backed by reg.
func (*OpenAIClient) APIStyle ¶
func (c *OpenAIClient) APIStyle() protocol.APIStyle
func (*OpenAIClient) ChatCompletionsNew ¶
func (c *OpenAIClient) ChatCompletionsNew(ctx context.Context, req openai.ChatCompletionNewParams) (*openai.ChatCompletion, error)
ChatCompletionsNew calls the vmodel synchronously and returns an *openai.ChatCompletion built via JSON round-trip.
func (*OpenAIClient) ChatCompletionsNewStreaming ¶
func (c *OpenAIClient) ChatCompletionsNewStreaming(ctx context.Context, req openai.ChatCompletionNewParams) *openaistream.Stream[openai.ChatCompletionChunk]
ChatCompletionsNewStreaming wraps vm.HandleOpenAIChatStream with a channel-based decoder so the caller gets a standard ssestream.Stream.
func (*OpenAIClient) Client ¶
func (c *OpenAIClient) Client() *openai.Client
func (*OpenAIClient) Close ¶
func (c *OpenAIClient) Close() error
func (*OpenAIClient) EmbeddingsNew ¶
func (c *OpenAIClient) EmbeddingsNew(_ context.Context, _ openai.EmbeddingNewParams) (*openai.CreateEmbeddingResponse, error)
func (*OpenAIClient) GetProvider ¶
func (c *OpenAIClient) GetProvider() *typ.Provider
func (*OpenAIClient) ImagesGenerate ¶
func (c *OpenAIClient) ImagesGenerate(_ context.Context, _ openai.ImageGenerateParams) (*openai.ImagesResponse, error)
func (*OpenAIClient) ListModels ¶
func (c *OpenAIClient) ListModels(_ context.Context) ([]string, error)
func (*OpenAIClient) ResponsesNew ¶
func (c *OpenAIClient) ResponsesNew(_ context.Context, _ responses.ResponseNewParams) (*responses.Response, error)
func (*OpenAIClient) ResponsesNewStreaming ¶
func (c *OpenAIClient) ResponsesNewStreaming(_ context.Context, _ responses.ResponseNewParams) *openaistream.Stream[responses.ResponseStreamEventUnion]
func (*OpenAIClient) SetRecordSink ¶
func (c *OpenAIClient) SetRecordSink(_ *obs.Sink)