feat: publish sanitized custom.97 source
This commit is contained in:
1022 files changed
+69903
-19207
No files matched your search
@@ -3,6 +3,8 @@ package gemini
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -13,26 +15,43 @@ import (
|
||||
"github.com/QuantumNous/new-api/relaykit/types"
|
||||
)
|
||||
|
||||
var SupportedMimeTypes = map[string]bool{
|
||||
"application/pdf": true,
|
||||
"audio/mpeg": true,
|
||||
"audio/mp3": true,
|
||||
"audio/wav": true,
|
||||
"image/png": true,
|
||||
"image/jpeg": true,
|
||||
"image/jpg": true,
|
||||
"image/webp": true,
|
||||
"image/heic": true,
|
||||
"image/heif": true,
|
||||
"text/plain": true,
|
||||
"video/mov": true,
|
||||
"video/mpeg": true,
|
||||
"video/mp4": true,
|
||||
"video/mpg": true,
|
||||
"video/avi": true,
|
||||
"video/wmv": true,
|
||||
"video/mpegps": true,
|
||||
"video/flv": true,
|
||||
// supportedMimeTypes follows the Blob.mimeType list in the Gemini API
|
||||
// reference (https://ai.google.dev/api/generate-content#Blob). Audio and
|
||||
// video are listed there as audio/* and video/*; IsSupportedMimeType accepts
|
||||
// them by prefix.
|
||||
var supportedMimeTypes = map[string]bool{
|
||||
"image/png": true,
|
||||
"image/jpeg": true,
|
||||
"image/jpg": true,
|
||||
"image/webp": true,
|
||||
"image/heic": true,
|
||||
"image/heif": true,
|
||||
"image/gif": true,
|
||||
"image/avif": true,
|
||||
"text/plain": true,
|
||||
"text/html": true,
|
||||
"text/css": true,
|
||||
"text/javascript": true,
|
||||
"text/x-typescript": true,
|
||||
"text/csv": true,
|
||||
"text/markdown": true,
|
||||
"text/x-python": true,
|
||||
"text/xml": true,
|
||||
"text/rtf": true,
|
||||
"application/x-javascript": true,
|
||||
"application/x-typescript": true,
|
||||
"application/x-python-code": true,
|
||||
"application/json": true,
|
||||
"application/x-ipynb+json": true,
|
||||
"application/rtf": true,
|
||||
"application/pdf": true,
|
||||
}
|
||||
|
||||
// IsSupportedMimeType reports whether Gemini accepts inline data of the MIME
|
||||
// type.
|
||||
func IsSupportedMimeType(mimeType string) bool {
|
||||
mimeType = strings.ToLower(mimeType)
|
||||
return supportedMimeTypes[mimeType] || strings.HasPrefix(mimeType, "audio/") || strings.HasPrefix(mimeType, "video/")
|
||||
}
|
||||
|
||||
var SafetySettingCategories = []string{
|
||||
@@ -272,9 +291,5 @@ func HasFunctionCallContent(call *dto.FunctionCall) bool {
|
||||
}
|
||||
|
||||
func SupportedMimeTypesList() []string {
|
||||
keys := make([]string, 0, len(SupportedMimeTypes))
|
||||
for key := range SupportedMimeTypes {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return keys
|
||||
return append(slices.Sorted(maps.Keys(supportedMimeTypes)), "audio/*", "video/*")
|
||||
}
|
||||
Reference in new issue
Block a user