Documentation
¶
Index ¶
- type BlockingInterception
- func (i *BlockingInterception) ID() uuid.UUID
- func (i *BlockingInterception) Model() string
- func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Request) (outErr error)
- func (s *BlockingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier)
- func (s *BlockingInterception) Streaming() bool
- func (s *BlockingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue
- type ChatCompletionNewParamsWrapper
- type StreamingInterception
- func (i *StreamingInterception) ID() uuid.UUID
- func (i *StreamingInterception) Model() string
- func (i *StreamingInterception) ProcessRequest(w http.ResponseWriter, r *http.Request) (outErr error)
- func (i *StreamingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier)
- func (i *StreamingInterception) Streaming() bool
- func (s *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockingInterception ¶
type BlockingInterception struct {
// contains filtered or unexported fields
}
func NewBlockingInterceptor ¶
func NewBlockingInterceptor(id uuid.UUID, req *ChatCompletionNewParamsWrapper, cfg config.OpenAI, tracer trace.Tracer) *BlockingInterception
func (*BlockingInterception) ProcessRequest ¶
func (i *BlockingInterception) ProcessRequest(w http.ResponseWriter, r *http.Request) (outErr error)
func (*BlockingInterception) Setup ¶
func (s *BlockingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier)
func (*BlockingInterception) Streaming ¶
func (s *BlockingInterception) Streaming() bool
func (*BlockingInterception) TraceAttributes ¶
func (s *BlockingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue
type ChatCompletionNewParamsWrapper ¶
type ChatCompletionNewParamsWrapper struct {
openai.ChatCompletionNewParams `json:""`
Stream bool `json:"stream,omitempty"`
}
ChatCompletionNewParamsWrapper exists because the "stream" param is not included in openai.ChatCompletionNewParams.
func (ChatCompletionNewParamsWrapper) MarshalJSON ¶
func (c ChatCompletionNewParamsWrapper) MarshalJSON() ([]byte, error)
func (*ChatCompletionNewParamsWrapper) UnmarshalJSON ¶
func (c *ChatCompletionNewParamsWrapper) UnmarshalJSON(raw []byte) error
type StreamingInterception ¶
type StreamingInterception struct {
// contains filtered or unexported fields
}
func NewStreamingInterceptor ¶
func NewStreamingInterceptor(id uuid.UUID, req *ChatCompletionNewParamsWrapper, cfg config.OpenAI, tracer trace.Tracer) *StreamingInterception
func (*StreamingInterception) ProcessRequest ¶
func (i *StreamingInterception) ProcessRequest(w http.ResponseWriter, r *http.Request) (outErr error)
ProcessRequest handles a request to /v1/chat/completions. See https://platform.openai.com/docs/api-reference/chat-streaming/streaming.
It will inject any tools which have been provided by the mcp.ServerProxier.
When a response from the server includes an event indicating that a tool must be invoked, a conditional flow takes place:
a) if the tool is not injected (i.e. defined by the client), relay the event unmodified b) if the tool is injected, it will be invoked by the mcp.ServerProxier in the remote MCP server, and its results relayed to the SERVER. The response from the server will be handled synchronously, and this loop can continue until all injected tool invocations are completed and the response is relayed to the client.
func (*StreamingInterception) Setup ¶
func (i *StreamingInterception) Setup(logger slog.Logger, recorder recorder.Recorder, mcpProxy mcp.ServerProxier)
func (*StreamingInterception) Streaming ¶
func (i *StreamingInterception) Streaming() bool
func (*StreamingInterception) TraceAttributes ¶
func (s *StreamingInterception) TraceAttributes(r *http.Request) []attribute.KeyValue