Documentation
¶
Index ¶
- func ConvertParametersToSchema(params any) (shared.FunctionParameters, bool, error)
- type Client
- func (c *Client) Close()
- func (c *Client) CreateBatchEmbedding(ctx context.Context, texts []string) (*base.BatchEmbeddingResult, error)
- func (c *Client) CreateChatCompletionStream(ctx context.Context, messages []chat.Message, requestTools []tools.Tool) (chat.MessageStream, error)
- func (c *Client) CreateEmbedding(ctx context.Context, text string) (*base.EmbeddingResult, error)
- func (c *Client) CreateResponseStream(ctx context.Context, messages []chat.Message, requestTools []tools.Tool) (chat.MessageStream, error)
- func (c *Client) Rerank(ctx context.Context, query string, documents []types.Document, criteria string) ([]float64, error)
- type ResponseStreamAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertParametersToSchema ¶
func ConvertParametersToSchema(params any) (shared.FunctionParameters, bool, error)
ConvertParametersToSchema converts parameters to OpenAI Schema format and reports whether the resulting schema is compatible with OpenAI strict mode.
The same normalization pipeline runs in both cases — strict-incompatible schemas (e.g. Notion MCP tools that declare schema-form additionalProperties) still need fully-populated `required` arrays for the Chat Completions API, which has no per-tool strict flag. The strict flag is only consumed by the Responses API caller.
Types ¶
type Client ¶
Client represents an OpenAI client wrapper. It implements the provider.Provider interface.
func NewClient ¶
func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Provider, opts ...options.Opt) (*Client, error)
NewClient creates a new OpenAI client from the provided configuration
func (*Client) Close ¶ added in v1.36.0
func (c *Client) Close()
Close releases resources held by the client, including any pooled WebSocket connections. It is safe to call Close multiple times.
func (*Client) CreateBatchEmbedding ¶
func (c *Client) CreateBatchEmbedding(ctx context.Context, texts []string) (*base.BatchEmbeddingResult, error)
CreateBatchEmbedding generates embedding vectors for multiple texts.
OpenAI supports up to 2048 inputs per request
func (*Client) CreateChatCompletionStream ¶
func (c *Client) CreateChatCompletionStream( ctx context.Context, messages []chat.Message, requestTools []tools.Tool, ) (chat.MessageStream, error)
CreateChatCompletionStream creates a streaming chat completion request It returns a stream that can be iterated over to get completion chunks
func (*Client) CreateEmbedding ¶
CreateEmbedding generates an embedding vector for the given text
func (*Client) CreateResponseStream ¶
type ResponseStreamAdapter ¶
type ResponseStreamAdapter struct {
// contains filtered or unexported fields
}
ResponseStreamAdapter adapts the OpenAI responses stream to our interface. It works with any responseEventStream implementation (SSE or WebSocket).
func (*ResponseStreamAdapter) Close ¶
func (a *ResponseStreamAdapter) Close()
Close closes the stream
func (*ResponseStreamAdapter) Recv ¶
func (a *ResponseStreamAdapter) Recv() (chat.MessageStreamResponse, error)
Recv gets the next completion chunk