2024-02-17 16:15:31 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
type ResponseFormat struct {
|
2024-09-21 14:35:24 +00:00
|
|
|
Type string `json:"type,omitempty"`
|
|
|
|
JsonSchema *JSONSchema `json:"json_schema,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type JSONSchema struct {
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
Schema map[string]interface{} `json:"schema,omitempty"`
|
|
|
|
Strict *bool `json:"strict,omitempty"`
|
2024-02-17 16:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type GeneralOpenAIRequest struct {
|
|
|
|
Messages []Message `json:"messages,omitempty"`
|
2024-03-30 02:43:26 +00:00
|
|
|
Model string `json:"model,omitempty"`
|
|
|
|
FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
|
2024-02-17 16:15:31 +00:00
|
|
|
MaxTokens int `json:"max_tokens,omitempty"`
|
|
|
|
N int `json:"n,omitempty"`
|
|
|
|
PresencePenalty float64 `json:"presence_penalty,omitempty"`
|
|
|
|
ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
|
|
|
|
Seed float64 `json:"seed,omitempty"`
|
2024-07-14 09:57:16 +00:00
|
|
|
Stop any `json:"stop,omitempty"`
|
2024-03-30 02:43:26 +00:00
|
|
|
Stream bool `json:"stream,omitempty"`
|
|
|
|
Temperature float64 `json:"temperature,omitempty"`
|
|
|
|
TopP float64 `json:"top_p,omitempty"`
|
|
|
|
TopK int `json:"top_k,omitempty"`
|
|
|
|
Tools []Tool `json:"tools,omitempty"`
|
2024-02-17 16:15:31 +00:00
|
|
|
ToolChoice any `json:"tool_choice,omitempty"`
|
2024-03-30 02:43:26 +00:00
|
|
|
FunctionCall any `json:"function_call,omitempty"`
|
|
|
|
Functions any `json:"functions,omitempty"`
|
2024-02-17 16:15:31 +00:00
|
|
|
User string `json:"user,omitempty"`
|
2024-03-30 02:43:26 +00:00
|
|
|
Prompt any `json:"prompt,omitempty"`
|
|
|
|
Input any `json:"input,omitempty"`
|
2024-03-31 14:23:42 +00:00
|
|
|
EncodingFormat string `json:"encoding_format,omitempty"`
|
|
|
|
Dimensions int `json:"dimensions,omitempty"`
|
2024-03-30 02:43:26 +00:00
|
|
|
Instruction string `json:"instruction,omitempty"`
|
|
|
|
Size string `json:"size,omitempty"`
|
2024-08-06 15:44:37 +00:00
|
|
|
NumCtx int `json:"num_ctx,omitempty"`
|
2024-02-17 16:15:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r GeneralOpenAIRequest) ParseInput() []string {
|
|
|
|
if r.Input == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var input []string
|
|
|
|
switch r.Input.(type) {
|
|
|
|
case string:
|
|
|
|
input = []string{r.Input.(string)}
|
|
|
|
case []any:
|
|
|
|
input = make([]string, 0, len(r.Input.([]any)))
|
|
|
|
for _, item := range r.Input.([]any) {
|
|
|
|
if str, ok := item.(string); ok {
|
|
|
|
input = append(input, str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return input
|
|
|
|
}
|