|
@@ -21,6 +21,22 @@ type Adaptor struct {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (a *Adaptor) ConvertGeminiRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeminiChatRequest) (any, error) {
|
|
func (a *Adaptor) ConvertGeminiRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeminiChatRequest) (any, error) {
|
|
|
|
|
+ if len(request.Contents) > 0 {
|
|
|
|
|
+ for i, content := range request.Contents {
|
|
|
|
|
+ if i == 0 {
|
|
|
|
|
+ if request.Contents[0].Role == "" {
|
|
|
|
|
+ request.Contents[0].Role = "user"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for _, part := range content.Parts {
|
|
|
|
|
+ if part.FileData != nil {
|
|
|
|
|
+ if part.FileData.MimeType == "" && strings.Contains(part.FileData.FileUri, "www.youtube.com") {
|
|
|
|
|
+ part.FileData.MimeType = "video/webm"
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return request, nil
|
|
return request, nil
|
|
|
}
|
|
}
|
|
|
|
|
|