|
package schema |
|
|
|
import ( |
|
"context" |
|
"time" |
|
|
|
functions "github.com/mudler/LocalAI/pkg/functions" |
|
) |
|
|
|
|
|
type APIError struct { |
|
Code any `json:"code,omitempty"` |
|
Message string `json:"message"` |
|
Param *string `json:"param,omitempty"` |
|
Type string `json:"type"` |
|
} |
|
|
|
type ErrorResponse struct { |
|
Error *APIError `json:"error,omitempty"` |
|
} |
|
|
|
type OpenAIUsage struct { |
|
PromptTokens int `json:"prompt_tokens"` |
|
CompletionTokens int `json:"completion_tokens"` |
|
TotalTokens int `json:"total_tokens"` |
|
} |
|
|
|
type Item struct { |
|
Embedding []float32 `json:"embedding"` |
|
Index int `json:"index"` |
|
Object string `json:"object,omitempty"` |
|
|
|
|
|
URL string `json:"url,omitempty"` |
|
B64JSON string `json:"b64_json,omitempty"` |
|
} |
|
|
|
type OpenAIResponse struct { |
|
Created int `json:"created,omitempty"` |
|
Object string `json:"object,omitempty"` |
|
ID string `json:"id,omitempty"` |
|
Model string `json:"model,omitempty"` |
|
Choices []Choice `json:"choices,omitempty"` |
|
Data []Item `json:"data,omitempty"` |
|
|
|
Usage OpenAIUsage `json:"usage"` |
|
} |
|
|
|
type Choice struct { |
|
Index int `json:"index"` |
|
FinishReason string `json:"finish_reason"` |
|
Message *Message `json:"message,omitempty"` |
|
Delta *Message `json:"delta,omitempty"` |
|
Text string `json:"text,omitempty"` |
|
} |
|
|
|
type Content struct { |
|
Type string `json:"type" yaml:"type"` |
|
Text string `json:"text" yaml:"text"` |
|
ImageURL ContentURL `json:"image_url" yaml:"image_url"` |
|
} |
|
|
|
type ContentURL struct { |
|
URL string `json:"url" yaml:"url"` |
|
} |
|
|
|
type Message struct { |
|
|
|
Role string `json:"role,omitempty" yaml:"role"` |
|
|
|
|
|
Name string `json:"name,omitempty" yaml:"name"` |
|
|
|
|
|
Content interface{} `json:"content" yaml:"content"` |
|
|
|
StringContent string `json:"string_content,omitempty" yaml:"string_content,omitempty"` |
|
StringImages []string `json:"string_images,omitempty" yaml:"string_images,omitempty"` |
|
|
|
|
|
FunctionCall interface{} `json:"function_call,omitempty" yaml:"function_call,omitempty"` |
|
|
|
ToolCalls []ToolCall `json:"tool_calls,omitempty" yaml:"tool_call,omitempty"` |
|
} |
|
|
|
type ToolCall struct { |
|
Index int `json:"index"` |
|
ID string `json:"id"` |
|
Type string `json:"type"` |
|
FunctionCall FunctionCall `json:"function"` |
|
} |
|
|
|
type FunctionCall struct { |
|
Name string `json:"name,omitempty"` |
|
Arguments string `json:"arguments"` |
|
} |
|
|
|
type OpenAIModel struct { |
|
ID string `json:"id"` |
|
Object string `json:"object"` |
|
} |
|
|
|
type DeleteAssistantResponse struct { |
|
ID string `json:"id"` |
|
Object string `json:"object"` |
|
Deleted bool `json:"deleted"` |
|
} |
|
|
|
|
|
type File struct { |
|
ID string `json:"id"` |
|
Object string `json:"object"` |
|
Bytes int `json:"bytes"` |
|
CreatedAt time.Time `json:"created_at"` |
|
Filename string `json:"filename"` |
|
Purpose string `json:"purpose"` |
|
} |
|
|
|
type ListFiles struct { |
|
Data []File |
|
Object string |
|
} |
|
|
|
type AssistantFileRequest struct { |
|
FileID string `json:"file_id"` |
|
} |
|
|
|
type DeleteAssistantFileResponse struct { |
|
ID string `json:"id"` |
|
Object string `json:"object"` |
|
Deleted bool `json:"deleted"` |
|
} |
|
|
|
type ImageGenerationResponseFormat string |
|
|
|
type ChatCompletionResponseFormatType string |
|
|
|
type ChatCompletionResponseFormat struct { |
|
Type ChatCompletionResponseFormatType `json:"type,omitempty"` |
|
} |
|
|
|
type JsonSchemaRequest struct { |
|
Type string `json:"type"` |
|
JsonSchema JsonSchema `json:"json_schema"` |
|
} |
|
|
|
type JsonSchema struct { |
|
Name string `json:"name"` |
|
Strict bool `json:"strict"` |
|
Schema functions.Item `json:"schema"` |
|
} |
|
|
|
type OpenAIRequest struct { |
|
PredictionOptions |
|
|
|
Context context.Context `json:"-"` |
|
Cancel context.CancelFunc `json:"-"` |
|
|
|
|
|
File string `json:"file" validate:"required"` |
|
|
|
ResponseFormat interface{} `json:"response_format,omitempty"` |
|
|
|
Size string `json:"size"` |
|
|
|
Prompt interface{} `json:"prompt" yaml:"prompt"` |
|
|
|
|
|
Instruction string `json:"instruction" yaml:"instruction"` |
|
Input interface{} `json:"input" yaml:"input"` |
|
|
|
Stop interface{} `json:"stop" yaml:"stop"` |
|
|
|
|
|
Messages []Message `json:"messages" yaml:"messages"` |
|
|
|
|
|
Functions functions.Functions `json:"functions" yaml:"functions"` |
|
FunctionCall interface{} `json:"function_call" yaml:"function_call"` |
|
|
|
Tools []functions.Tool `json:"tools,omitempty" yaml:"tools"` |
|
ToolsChoice interface{} `json:"tool_choice,omitempty" yaml:"tool_choice"` |
|
|
|
Stream bool `json:"stream"` |
|
|
|
|
|
Mode int `json:"mode"` |
|
Step int `json:"step"` |
|
|
|
|
|
Grammar string `json:"grammar" yaml:"grammar"` |
|
|
|
JSONFunctionGrammarObject *functions.JSONFunctionStructure `json:"grammar_json_functions" yaml:"grammar_json_functions"` |
|
|
|
Backend string `json:"backend" yaml:"backend"` |
|
|
|
|
|
ModelBaseName string `json:"model_base_name" yaml:"model_base_name"` |
|
} |
|
|
|
type ModelsDataResponse struct { |
|
Object string `json:"object"` |
|
Data []OpenAIModel `json:"data"` |
|
} |
|
|