Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e54bb12a
authored
Dec 12, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 兼容OpenAI格式下设置gemini模型联网搜索 #615
parent
ee03e71e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
relay/channel/gemini/dto.go
+1
-0
relay/channel/gemini/relay-gemini.go
+16
-5
No files found.
relay/channel/gemini/dto.go
View file @
e54bb12a
...
...
@@ -34,6 +34,7 @@ type GeminiChatSafetySettings struct {
}
type
GeminiChatTools
struct
{
GoogleSearch
any
`json:"googleSearch,omitempty"`
FunctionDeclarations
any
`json:"functionDeclarations,omitempty"`
}
...
...
relay/channel/gemini/relay-gemini.go
View file @
e54bb12a
...
...
@@ -45,13 +45,25 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest) *GeminiChatReques
}
if
textRequest
.
Tools
!=
nil
{
functions
:=
make
([]
dto
.
FunctionCall
,
0
,
len
(
textRequest
.
Tools
))
googleSearch
:=
false
for
_
,
tool
:=
range
textRequest
.
Tools
{
if
tool
.
Function
.
Name
==
"googleSearch"
{
googleSearch
=
true
continue
}
functions
=
append
(
functions
,
tool
.
Function
)
}
geminiRequest
.
Tools
=
[]
GeminiChatTools
{
{
FunctionDeclarations
:
functions
,
},
if
len
(
functions
)
>
0
{
geminiRequest
.
Tools
=
[]
GeminiChatTools
{
{
FunctionDeclarations
:
functions
,
},
}
}
if
googleSearch
{
geminiRequest
.
Tools
=
append
(
geminiRequest
.
Tools
,
GeminiChatTools
{
GoogleSearch
:
make
(
map
[
string
]
string
),
})
}
}
else
if
textRequest
.
Functions
!=
nil
{
geminiRequest
.
Tools
=
[]
GeminiChatTools
{
...
...
@@ -134,7 +146,6 @@ func CovertGemini2OpenAI(textRequest dto.GeneralOpenAIRequest) *GeminiChatReques
shouldAddDummyModelMessage
=
false
}
}
return
&
geminiRequest
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment