132 lines
3.4 KiB
Go
132 lines
3.4 KiB
Go
package ali
|
|
|
|
import "one-api/dto"
|
|
|
|
type AliMessage struct {
|
|
Content string `json:"content"`
|
|
Role string `json:"role"`
|
|
}
|
|
|
|
type AliInput struct {
|
|
Prompt string `json:"prompt,omitempty"`
|
|
//History []AliMessage `json:"history,omitempty"`
|
|
Messages []AliMessage `json:"messages"`
|
|
}
|
|
|
|
type AliParameters struct {
|
|
TopP float64 `json:"top_p,omitempty"`
|
|
TopK int `json:"top_k,omitempty"`
|
|
Seed uint64 `json:"seed,omitempty"`
|
|
EnableSearch bool `json:"enable_search,omitempty"`
|
|
IncrementalOutput bool `json:"incremental_output,omitempty"`
|
|
}
|
|
|
|
type AliChatRequest struct {
|
|
Model string `json:"model"`
|
|
Input AliInput `json:"input,omitempty"`
|
|
Parameters AliParameters `json:"parameters,omitempty"`
|
|
}
|
|
|
|
type AliEmbeddingRequest struct {
|
|
Model string `json:"model"`
|
|
Input struct {
|
|
Texts []string `json:"texts"`
|
|
} `json:"input"`
|
|
Parameters *struct {
|
|
TextType string `json:"text_type,omitempty"`
|
|
} `json:"parameters,omitempty"`
|
|
}
|
|
|
|
type AliEmbedding struct {
|
|
Embedding []float64 `json:"embedding"`
|
|
TextIndex int `json:"text_index"`
|
|
}
|
|
|
|
type AliEmbeddingResponse struct {
|
|
Output struct {
|
|
Embeddings []AliEmbedding `json:"embeddings"`
|
|
} `json:"output"`
|
|
Usage AliUsage `json:"usage"`
|
|
AliError
|
|
}
|
|
|
|
type AliError struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
RequestId string `json:"request_id"`
|
|
}
|
|
|
|
type AliUsage struct {
|
|
InputTokens int `json:"input_tokens"`
|
|
OutputTokens int `json:"output_tokens"`
|
|
TotalTokens int `json:"total_tokens"`
|
|
}
|
|
|
|
type TaskResult struct {
|
|
B64Image string `json:"b64_image,omitempty"`
|
|
Url string `json:"url,omitempty"`
|
|
Code string `json:"code,omitempty"`
|
|
Message string `json:"message,omitempty"`
|
|
}
|
|
|
|
type AliOutput struct {
|
|
TaskId string `json:"task_id,omitempty"`
|
|
TaskStatus string `json:"task_status,omitempty"`
|
|
Text string `json:"text"`
|
|
FinishReason string `json:"finish_reason"`
|
|
Message string `json:"message,omitempty"`
|
|
Code string `json:"code,omitempty"`
|
|
Results []TaskResult `json:"results,omitempty"`
|
|
}
|
|
|
|
type AliResponse struct {
|
|
Output AliOutput `json:"output"`
|
|
Usage AliUsage `json:"usage"`
|
|
AliError
|
|
}
|
|
|
|
type AliImageRequest struct {
|
|
Model string `json:"model"`
|
|
Input any `json:"input"`
|
|
Parameters any `json:"parameters,omitempty"`
|
|
ResponseFormat string `json:"response_format,omitempty"`
|
|
}
|
|
|
|
type AliImageParameters struct {
|
|
Size string `json:"size,omitempty"`
|
|
N int `json:"n,omitempty"`
|
|
Steps string `json:"steps,omitempty"`
|
|
Scale string `json:"scale,omitempty"`
|
|
Watermark *bool `json:"watermark,omitempty"`
|
|
}
|
|
|
|
type AliImageInput struct {
|
|
Prompt string `json:"prompt"`
|
|
NegativePrompt string `json:"negative_prompt,omitempty"`
|
|
}
|
|
|
|
type AliRerankParameters struct {
|
|
TopN *int `json:"top_n,omitempty"`
|
|
ReturnDocuments *bool `json:"return_documents,omitempty"`
|
|
}
|
|
|
|
type AliRerankInput struct {
|
|
Query string `json:"query"`
|
|
Documents []any `json:"documents"`
|
|
}
|
|
|
|
type AliRerankRequest struct {
|
|
Model string `json:"model"`
|
|
Input AliRerankInput `json:"input"`
|
|
Parameters AliRerankParameters `json:"parameters,omitempty"`
|
|
}
|
|
|
|
type AliRerankResponse struct {
|
|
Output struct {
|
|
Results []dto.RerankResponseResult `json:"results"`
|
|
} `json:"output"`
|
|
Usage AliUsage `json:"usage"`
|
|
RequestId string `json:"request_id"`
|
|
AliError
|
|
}
|