Help us shape the future of Go! Take the 2026 Go Developer Survey

openai

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package openai provides a deterministic, stateless mock upstream for several LLM providers. Responses preserve the provider-specific shapes and usage fields consumed by gateway policies.

Index

Constants

View Source
const ChatEchoPath = "/openai/v1/chat-echo"

ChatEchoPath answers with the request's last user message as the assistant's reply, so a scenario controls the response text a gateway policy sees. With "stream": true the reply is sent as OpenAI chat-completion chunks over server-sent events, one word per chunk.

View Source
const ChatEchoProviderPath = "/openai-echo/v1/chat/completions"

ChatEchoProviderPath answers like ChatEchoPath at the chat-completions path an OpenAI-template LLM provider calls, so a provider whose upstream is http://testbench:3008/openai-echo/v1 gets echoed, optionally streamed replies.

View Source
const Port = 3008

Port is the container port used by the testbench.

View Source
const ReadinessPath = "/__readiness"

ReadinessPath is used by provider readiness probes.

View Source
const StreamErrorTrigger = "STREAM_ERROR"

StreamErrorTrigger, anywhere in a streaming request, ends the stream with the provider's error event instead of a clean finish.

View Source
const StreamedReply = "This is a streamed reply from the mock model."

StreamedReply is the assistant text every streamed reply carries, one word per delta.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct{}

Service implements the stateless LLM mock used by the testbench.

func New

func New() *Service

New returns a new Service.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler returns the HTTP handler for the service.

func (*Service) Name

func (s *Service) Name() string

Name returns the service registration name.

func (*Service) Port

func (s *Service) Port() int

Port returns the service's listening port.

func (*Service) Stateful

func (s *Service) Stateful() bool

Stateful reports whether the service keeps request-specific state.

Jump to

Keyboard shortcuts

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