Skip to content

feat: gemini urlContext - #1888

Merged
seefs001 merged 1 commit into
QuantumNous:alphafrom
seefs001:feature/gemini-urlcontext
Sep 27, 2025
Merged

feat: gemini urlContext#1888
seefs001 merged 1 commit into
QuantumNous:alphafrom
seefs001:feature/gemini-urlcontext

Conversation

@seefs001

@seefs001 seefs001 commented Sep 27, 2025

Copy link
Copy Markdown
Collaborator

#1633

Summary by CodeRabbit

  • New Features
    • Added support for a URL Context tool in Gemini, allowing requests to include URLs as context to improve response relevance.
    • Automatically integrates with existing tool handling; no action required if unused.
    • Backwards-compatible: behavior remains unchanged when no URL context is provided.

@coderabbitai

coderabbitai Bot commented Sep 27, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

Adds URLContext support to Gemini tools: a new URLContext field on GeminiChatTool and relay logic to parse urlContext from requests and append the corresponding tool to the Gemini tools list alongside existing GoogleSearch and CodeExecution handling.

Changes

Cohort / File(s) Summary
Gemini DTOs
dto/gemini.go
Added public field URLContext any \json:"urlContext,omitempty"`toGeminiChatTool` to allow optional URL context serialization.
Gemini Relay Tool Handling
relay/channel/gemini/relay-gemini.go
Extended tool parsing to recognize urlContext in textRequest.Tools and append a GeminiChatTool with URLContext set, mirroring existing GoogleSearch and CodeExecution integration paths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Client
  participant Relay as Relay (Gemini)
  participant DTO as GeminiChatTool DTO
  participant Gemini as Gemini API

  Client->>Relay: Send request with tools (googleSearch, codeExecution, urlContext)
  Relay->>Relay: Parse textRequest.Tools
  alt urlContext present
    Relay->>DTO: Construct GeminiChatTool{ URLContext=... }
    Relay->>Relay: Append URLContext tool to tools list
  else no urlContext
    Relay->>Relay: Proceed without URLContext
  end
  Relay->>Gemini: Submit request with tools list (incl. URLContext if set)
  Gemini-->>Relay: Response
  Relay-->>Client: Response forwarded
  note over Relay,Gemini: New conditional path adds URLContext tool alongside existing ones
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled the docs, ears perked with delight,
A new URLContext hops into sight—
Tools in a basket, three carrots abreast,
Gemini’s relay now handles the rest.
Tap-tap my paws: ship it, don’t delay—
More links to chew on today! 🥕

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a498da7 and 9e8b999.

📒 Files selected for processing (2)
  • dto/gemini.go (1 hunks)
  • relay/channel/gemini/relay-gemini.go (3 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@seefs001
seefs001 merged commit 096141b into QuantumNous:alpha Sep 27, 2025
1 check was pending
@coderabbitai coderabbitai Bot mentioned this pull request Sep 29, 2025
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant