Documentation
¶
Overview ¶
openai package provides middleware for partial compatibility with the OpenAI REST API
Index ¶
- func ChatMiddleware() gin.HandlerFunc
- func CompletionsMiddleware() gin.HandlerFunc
- func EmbeddingsMiddleware() gin.HandlerFunc
- func ListMiddleware() gin.HandlerFunc
- func RetrieveMiddleware() gin.HandlerFunc
- type BaseWriter
- type ChatCompletion
- type ChatCompletionChunk
- type ChatCompletionRequest
- type ChatWriter
- type Choice
- type ChunkChoice
- type CompleteChunkChoice
- type CompleteWriter
- type Completion
- type CompletionChunk
- type CompletionRequest
- type EmbedRequest
- type EmbedWriter
- type Embedding
- type EmbeddingList
- type EmbeddingUsage
- type Error
- type ErrorResponse
- type JsonSchema
- type ListCompletion
- type ListWriter
- type Message
- type Model
- type ResponseFormat
- type RetrieveWriter
- type StreamOptions
- type ToolCall
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChatMiddleware ¶ added in v0.2.0
func ChatMiddleware() gin.HandlerFunc
func CompletionsMiddleware ¶ added in v0.2.0
func CompletionsMiddleware() gin.HandlerFunc
func EmbeddingsMiddleware ¶ added in v0.2.6
func EmbeddingsMiddleware() gin.HandlerFunc
func ListMiddleware ¶ added in v0.2.0
func ListMiddleware() gin.HandlerFunc
func RetrieveMiddleware ¶ added in v0.2.0
func RetrieveMiddleware() gin.HandlerFunc
Types ¶
type BaseWriter ¶ added in v0.2.0
type BaseWriter struct {
gin.ResponseWriter
}
type ChatCompletion ¶
type ChatCompletionChunk ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct { Model string `json:"model"` Messages []Message `json:"messages"` Stream bool `json:"stream"` StreamOptions *StreamOptions `json:"stream_options"` MaxTokens *int `json:"max_tokens"` Seed *int `json:"seed"` Stop any `json:"stop"` Temperature *float64 `json:"temperature"` FrequencyPenalty *float64 `json:"frequency_penalty"` PresencePenalty *float64 `json:"presence_penalty"` TopP *float64 `json:"top_p"` ResponseFormat *ResponseFormat `json:"response_format"` Tools []api.Tool `json:"tools"` }
type ChatWriter ¶ added in v0.2.0
type ChatWriter struct { BaseWriter // contains filtered or unexported fields }
type ChunkChoice ¶
type CompleteChunkChoice ¶ added in v0.2.0
type CompleteWriter ¶ added in v0.2.0
type CompleteWriter struct { BaseWriter // contains filtered or unexported fields }
type Completion ¶ added in v0.2.0
type CompletionChunk ¶ added in v0.2.0
type CompletionRequest ¶ added in v0.2.0
type CompletionRequest struct { Model string `json:"model"` Prompt string `json:"prompt"` FrequencyPenalty float32 `json:"frequency_penalty"` MaxTokens *int `json:"max_tokens"` PresencePenalty float32 `json:"presence_penalty"` Seed *int `json:"seed"` Stop any `json:"stop"` Stream bool `json:"stream"` StreamOptions *StreamOptions `json:"stream_options"` Temperature *float32 `json:"temperature"` TopP float32 `json:"top_p"` Suffix string `json:"suffix"` }
TODO (https://github.com/ollama/ollama/issues/5259): support []string, []int and [][]int
type EmbedRequest ¶ added in v0.2.6
type EmbedWriter ¶ added in v0.2.6
type EmbedWriter struct { BaseWriter // contains filtered or unexported fields }
type EmbeddingList ¶ added in v0.2.6
type EmbeddingList struct { Object string `json:"object"` Data []Embedding `json:"data"` Model string `json:"model"` Usage EmbeddingUsage `json:"usage,omitempty"` }
type EmbeddingUsage ¶ added in v0.3.3
type ErrorResponse ¶
type ErrorResponse struct {
Error Error `json:"error"`
}
func NewError ¶
func NewError(code int, message string) ErrorResponse
type JsonSchema ¶ added in v0.5.0
type JsonSchema struct {
Schema json.RawMessage `json:"schema"`
}
type ListCompletion ¶ added in v0.2.0
type ListWriter ¶ added in v0.2.0
type ListWriter struct {
BaseWriter
}
type ResponseFormat ¶
type ResponseFormat struct { Type string `json:"type"` JsonSchema *JsonSchema `json:"json_schema,omitempty"` }
type RetrieveWriter ¶ added in v0.2.0
type RetrieveWriter struct { BaseWriter // contains filtered or unexported fields }
type StreamOptions ¶ added in v0.5.2
type StreamOptions struct {
IncludeUsage bool `json:"include_usage"`
}
Click to show internal directories.
Click to hide internal directories.