Skip to content

Commit 096141b

Browse files
authored
Merge pull request #1888 from seefs001/feature/gemini-urlcontext
feat: gemini urlContext
2 parents a498da7 + 9e8b999 commit 096141b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

dto/gemini.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ type GeminiChatTool struct {
251251
GoogleSearchRetrieval any `json:"googleSearchRetrieval,omitempty"`
252252
CodeExecution any `json:"codeExecution,omitempty"`
253253
FunctionDeclarations any `json:"functionDeclarations,omitempty"`
254+
URLContext any `json:"urlContext,omitempty"`
254255
}
255256

256257
type GeminiChatGenerationConfig struct {

relay/channel/gemini/relay-gemini.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func CovertGemini2OpenAI(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
245245
functions := make([]dto.FunctionRequest, 0, len(textRequest.Tools))
246246
googleSearch := false
247247
codeExecution := false
248+
urlContext := false
248249
for _, tool := range textRequest.Tools {
249250
if tool.Function.Name == "googleSearch" {
250251
googleSearch = true
@@ -254,6 +255,10 @@ func CovertGemini2OpenAI(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
254255
codeExecution = true
255256
continue
256257
}
258+
if tool.Function.Name == "urlContext" {
259+
urlContext = true
260+
continue
261+
}
257262
if tool.Function.Parameters != nil {
258263

259264
params, ok := tool.Function.Parameters.(map[string]interface{})
@@ -281,6 +286,11 @@ func CovertGemini2OpenAI(c *gin.Context, textRequest dto.GeneralOpenAIRequest, i
281286
GoogleSearch: make(map[string]string),
282287
})
283288
}
289+
if urlContext {
290+
geminiTools = append(geminiTools, dto.GeminiChatTool{
291+
URLContext: make(map[string]string),
292+
})
293+
}
284294
if len(functions) > 0 {
285295
geminiTools = append(geminiTools, dto.GeminiChatTool{
286296
FunctionDeclarations: functions,

0 commit comments

Comments
 (0)