| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package dto
- type EmbeddingOptions struct {
- Seed int `json:"seed,omitempty"`
- Temperature *float64 `json:"temperature,omitempty"`
- TopK int `json:"top_k,omitempty"`
- TopP *float64 `json:"top_p,omitempty"`
- FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
- PresencePenalty *float64 `json:"presence_penalty,omitempty"`
- NumPredict int `json:"num_predict,omitempty"`
- NumCtx int `json:"num_ctx,omitempty"`
- }
- type EmbeddingRequest struct {
- Model string `json:"model"`
- Input any `json:"input"`
- EncodingFormat string `json:"encoding_format,omitempty"`
- Dimensions int `json:"dimensions,omitempty"`
- User string `json:"user,omitempty"`
- Seed float64 `json:"seed,omitempty"`
- Temperature *float64 `json:"temperature,omitempty"`
- TopP float64 `json:"top_p,omitempty"`
- FrequencyPenalty float64 `json:"frequency_penalty,omitempty"`
- PresencePenalty float64 `json:"presence_penalty,omitempty"`
- }
- func (r EmbeddingRequest) 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
- }
- type EmbeddingResponseItem struct {
- Object string `json:"object"`
- Index int `json:"index"`
- Embedding []float64 `json:"embedding"`
- }
- type EmbeddingResponse struct {
- Object string `json:"object"`
- Data []EmbeddingResponseItem `json:"data"`
- Model string `json:"model"`
- Usage `json:"usage"`
- }
|