Documentation
¶
Index ¶
- func Handler(si ServerInterface) http.Handler
- func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler
- func NewCreateChatCompletionRequest(server string, body CreateChatCompletionRequest) (*http.Request, error)
- func NewCreateChatCompletionRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- func NewCreateEmbeddingRequest(server string, body CreateEmbeddingRequest) (*http.Request, error)
- func NewCreateEmbeddingRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)
- type ChatCompletionMessageRole
- type ChatCompletionMessageToolCall
- type ChatCompletionMessageToolCallType
- type ChatCompletionMessageToolCalls
- type ChatCompletionRequestMessage
- type ChatCompletionResponseMessage
- type ChatCompletionTool
- type ChatCompletionToolType
- type Client
- type ClientOption
- type CreateChatCompletionRequest
- type CreateChatCompletionResponse
- type CreateEmbeddingRequest
- type CreateEmbeddingResponse
- type FunctionObject
- type FunctionParameters
- type HttpRequestDoer
- type RequestEditorFn
- type ServerInterface
- type ServerInterfaceWrapper
- type StdHTTPServerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(si ServerInterface) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func HandlerWithOptions ¶
func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler
HandlerWithOptions creates http.Handler with additional options
func NewCreateChatCompletionRequest ¶
func NewCreateChatCompletionRequest(server string, body CreateChatCompletionRequest) (*http.Request, error)
func NewCreateEmbeddingRequest ¶
func NewCreateEmbeddingRequest(server string, body CreateEmbeddingRequest) (*http.Request, error)
Types ¶
type ChatCompletionMessageRole ¶
type ChatCompletionMessageRole string
The role of the messages author.
const ( ChatCompletionRoleAssistant ChatCompletionMessageRole = "assistant" ChatCompletionRoleSystem ChatCompletionMessageRole = "system" ChatCompletionRoleTool ChatCompletionMessageRole = "tool" ChatCompletionRoleUser ChatCompletionMessageRole = "user" )
type ChatCompletionMessageToolCall ¶
type ChatCompletionMessageToolCall = marshalx.Dynamic[struct { // The function that the model called. Function marshalx.Dynamic[struct { // The arguments to call the function with, as generated by the model // in JSON format. Note that the model does not always generate valid JSON, // and may hallucinate parameters not defined by your function schema. // Validate the arguments in your code before calling your function. Arguments string `json:"arguments"` // The name of the function to call. Name string `json:"name"` }] `json:"function"` // The ID of the tool call. Id string `json:"id"` // The type of the tool. Currently, only `function` is supported. Type ChatCompletionMessageToolCallType `json:"type"` }]
type ChatCompletionMessageToolCallType ¶
type ChatCompletionMessageToolCallType string
The type of the tool. Currently, only `function` is supported.
type ChatCompletionMessageToolCalls ¶
type ChatCompletionMessageToolCalls = []ChatCompletionMessageToolCall
The tool calls generated by the model, such as function calls.
type ChatCompletionRequestMessage ¶
type ChatCompletionRequestMessage marshalx.Dynamic[struct { // The contents of the message. Content string `json:"content"` // An optional name for the participant. Provides the model information to differentiate between participants of the same role. Name *string `json:"name,omitempty"` // The role of the messages author. Role ChatCompletionMessageRole `json:"role"` }]
type ChatCompletionResponseMessage ¶
type ChatCompletionResponseMessage = marshalx.Dynamic[struct { // The tool calls generated by the model, such as function calls. ToolCalls *ChatCompletionMessageToolCalls `json:"tool_calls,omitempty"` }]
type ChatCompletionTool ¶
type ChatCompletionTool struct {
Function FunctionObject `json:"function"`
// Type The type of the tool. Currently, only `function` is supported.
Type ChatCompletionToolType `json:"type"`
}
type ChatCompletionToolType ¶
type ChatCompletionToolType string
The type of the tool. Currently, only `function` is supported.
const (
Function ChatCompletionToolType = "function"
)
type Client ¶
type Client struct {
// The endpoint of the server conforming to this interface, with scheme,
// https://api.deepmap.com for example. This can contain a path relative
// to the server, such as https://api.deepmap.com/dev-test, and all the
// paths in the swagger spec will be appended to the server.
Server string
// Doer for performing requests, typically a *http.Client with any
// customized settings, such as certificate chains.
Client HttpRequestDoer
// A list of callbacks for modifying requests which are generated before sending over
// the network.
RequestEditors []RequestEditorFn
}
func NewClient ¶
func NewClient(server string, opts ...ClientOption) (*Client, error)
Creates a new Client, with reasonable defaults
func (*Client) CreateChatCompletion ¶
func (c *Client) CreateChatCompletion(ctx context.Context, body CreateChatCompletionRequest, reqEditors ...RequestEditorFn) (*http.Response, error)
func (*Client) CreateEmbedding ¶
func (c *Client) CreateEmbedding(ctx context.Context, body CreateEmbeddingRequest, reqEditors ...RequestEditorFn) (*http.Response, error)
type ClientOption ¶
ClientOption allows setting custom parameters during construction
func WithHTTPClient ¶
func WithHTTPClient(doer HttpRequestDoer) ClientOption
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.
func WithRequestEditorFn ¶
func WithRequestEditorFn(fn RequestEditorFn) ClientOption
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.
type CreateChatCompletionRequest ¶
type CreateChatCompletionRequest = marshalx.Dynamic[struct { // ID of the model to use. Model string `json:"model"` // A list of messages comprising the conversation so far. Messages []ChatCompletionRequestMessage `json:"messages"` // A list of tools the model may call. Currently, only functions are // supported as a tool. Use this to provide a list of functions the model may // generate JSON inputs for. A max of 128 functions are supported. Tools *[]ChatCompletionTool `json:"tools,omitempty"` }]
type CreateChatCompletionResponse ¶
type CreateChatCompletionResponse = marshalx.Dynamic[struct { // A list of chat completion choices. Can be more than one if `n` is greater than 1. Choices []marshalx.Dynamic[struct { // A chat completion message generated by the model. Message ChatCompletionResponseMessage `json:"message"` }] `json:"choices"` }]
type CreateEmbeddingRequest ¶
type CreateEmbeddingResponse ¶
type FunctionObject ¶
type FunctionObject marshalx.Dynamic[struct { // A description of what the function does, used by the model to choose when and how to call the function. Description *string `json:"description,omitempty"` // Name The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. Name string `json:"name"` // Parameters The parameters the functions accepts, described as a JSON Schema object. // // Omitting `parameters` defines a function with an empty parameter list. Parameters *FunctionParameters `json:"parameters,omitempty"` // Strict Whether to enable strict schema adherence when generating the function call. // If set to true, the model will follow the exact schema defined in the `parameters` // field. Only a subset of JSON Schema is supported when `strict` is `true`. Strict *bool `json:"strict"` }]
type FunctionParameters ¶
FunctionParameters The parameters the functions accepts, described as a JSON Schema object.
Omitting `parameters` defines a function with an empty parameter list.
type HttpRequestDoer ¶
Doer performs HTTP requests.
The standard http.Client implements this interface.
type RequestEditorFn ¶
RequestEditorFn is the function signature for the RequestEditor callback function
type ServerInterface ¶
type ServerInterface interface {
CreateChatCompletion(w http.ResponseWriter, r *http.Request)
CreateEmbedding(w http.ResponseWriter, r *http.Request)
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
// HandlerMiddlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) CreateChatCompletion ¶
func (siw *ServerInterfaceWrapper) CreateChatCompletion(w http.ResponseWriter, r *http.Request)
CreateChatCompletion operation middleware
func (*ServerInterfaceWrapper) CreateEmbedding ¶
func (siw *ServerInterfaceWrapper) CreateEmbedding(w http.ResponseWriter, r *http.Request)
CreateEmbedding operation middleware