Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalChatRequest ¶
func MarshalChatRequest(req llm.ChatRequest) ([]byte, error)
MarshalChatRequest converts llm.ChatRequest to OpenAI-format JSON bytes.
func MarshalResponsesRequest ¶
func MarshalResponsesRequest(req llm.ChatRequest) ([]byte, error)
MarshalResponsesRequest converts llm.ChatRequest to native OpenAI Responses API JSON bytes.
func ParseChatResponse ¶
func ParseChatResponse(body []byte) (*llm.ChatResponse, error)
ParseChatResponse parses OpenAI-format JSON into llm.ChatResponse.
func ParseSSEChunk ¶
func ParseSSEChunk(dataPayload string) (llm.StreamChunk, bool, error)
ParseSSEChunk parses a single SSE data line into an llm.StreamChunk. Returns (chunk, done, error). done=true on [DONE] sentinel.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge adapts llm.ChatRequest/ChatResponse to flow through an http.Handler proxy.
func (*Bridge) Chat ¶
func (b *Bridge) Chat(ctx context.Context, req llm.ChatRequest) (*llm.ChatResponse, error)
Chat sends a non-streaming request through the proxy pipeline.
func (*Bridge) ChatStream ¶
func (b *Bridge) ChatStream(ctx context.Context, req llm.ChatRequest, callback llm.StreamCallback) error
ChatStream sends a streaming request through the proxy pipeline.
func (*Bridge) SetMetricsRecorder ¶
func (b *Bridge) SetMetricsRecorder(recorder runtimeMetricsRecorder)
SetMetricsRecorder wires a lightweight counter recorder for normalization/runtime events.
type ProxyError ¶
ProxyError wraps an HTTP status code from the proxy handler so callers can distinguish client errors (4xx, non-retryable) from server errors (5xx, retryable).
func (*ProxyError) Error ¶
func (e *ProxyError) Error() string
func (*ProxyError) IsClientError ¶
func (e *ProxyError) IsClientError() bool
IsClientError returns true for 4xx status codes (request is invalid, retrying won't help).
func (*ProxyError) IsNoProvider ¶
func (e *ProxyError) IsNoProvider() bool
IsNoProvider returns true when no provider is available for the requested model. Retrying won't help — the user needs to configure/enable a provider.
func (*ProxyError) IsOverloaded ¶
func (e *ProxyError) IsOverloaded() bool
IsOverloaded returns true for explicit overload statuses and common overload markers in proxy/upstream error bodies (e.g. wrapped upstream 5xx).