feat: support gemini ai model (#1173)

This commit is contained in:
韩贤涛
2024-08-09 09:55:40 +08:00
committed by GitHub
parent 564f8c770a
commit 04a9104062
5 changed files with 706 additions and 4 deletions

View File

@@ -161,3 +161,22 @@ type embedding struct {
Index int `json:"index"`
Embedding []float64 `json:"embedding"`
}
func (r embeddingsRequest) 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
}