Documentation
¶
Index ¶
- func PassThroughSSEStream(r io.Reader, w io.Writer) error
- func RewriteSSEStream(r io.Reader, w io.Writer, model string) error
- func RewriteSSEStreamWithCallback(r io.Reader, w io.Writer, model string, ...) error
- func TransformSSELine(in []byte) (out []byte, done bool, err error)
- type ChatCompletionChoice
- type ChatCompletionRequest
- type ChatCompletionResponse
- type ChatMessage
- type DeviceAuth
- type DeviceAuthError
- type DeviceAuthStore
- type HTTPClient
- type Option
- type SSETransformer
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PassThroughSSEStream ¶
PassThroughSSEStream copies upstream SSE events directly to the downstream writer without any transformation.
func RewriteSSEStream ¶
RewriteSSEStream reads an upstream SSE stream and writes a transformed SSE stream to w. It expects lines in the form 'data: <json>\n' and blank lines separating events. The provided model is used when emitting OpenAI chunks. The function emits transformed lines preserving SSE framing and a terminal 'data: [DONE]\n\n'.
func RewriteSSEStreamWithCallback ¶
func RewriteSSEStreamWithCallback(r io.Reader, w io.Writer, model string, onEvent func(raw []byte, out []byte, done bool)) error
RewriteSSEStreamWithCallback aggregates multi-line data: blocks per SSE event, transforms each event, writes it out, and invokes onEvent for debug if set.
func TransformSSELine ¶
TransformSSELine transforms a single SSE data payload line. - If payload is "[DONE]", returns done=true. - If payload is an OpenAI chat chunk (object == chat.completion.chunk), pass through unchanged. - Otherwise, interpret as Codex event and convert via SSETransformer.
Types ¶
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
Index int `json:"index"`
Message ChatMessage `json:"message"`
FinishReason string `json:"finish_reason"`
}
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []ChatMessage `json:"messages"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
N *int `json:"n,omitempty"`
Stream *bool `json:"stream,omitempty"`
User *string `json:"user,omitempty"`
OtherParams map[string]interface{} `json:"-"`
}
func (*ChatCompletionRequest) UnmarshalJSON ¶
func (r *ChatCompletionRequest) UnmarshalJSON(data []byte) error
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []ChatCompletionChoice `json:"choices"`
}
type ChatMessage ¶
type DeviceAuth ¶
type DeviceAuth struct {
// contains filtered or unexported fields
}
func (*DeviceAuth) Start ¶
func (a *DeviceAuth) Start(ctx context.Context) (deviceAuthStatus, error)
func (*DeviceAuth) Status ¶
func (a *DeviceAuth) Status() (deviceAuthStatus, error)
type DeviceAuthError ¶
type DeviceAuthError struct {
// contains filtered or unexported fields
}
func (*DeviceAuthError) Error ¶
func (e *DeviceAuthError) Error() string
type DeviceAuthStore ¶
type HTTPClient ¶
HTTPClient is an interface for making HTTP requests
func NewHTTPClient ¶
func NewHTTPClient() HTTPClient
NewHTTPClient creates a new HTTP client for regular environments
type Option ¶
type Option func(*Server)
func WithDeviceAuth ¶
func WithDeviceAuth(store DeviceAuthStore) Option
type SSETransformer ¶
type SSETransformer struct {
// contains filtered or unexported fields
}
func NewSSETransformer ¶
func NewSSETransformer(model string) *SSETransformer