Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented May 8, 2025

Add Dynamic Retrieval option to Search Grounding feature

This PR implements the Dynamic Retrieval option for the Search Grounding feature in Gemini models as requested in issue #386.

Changes

  • Added new state variables in settings store: dynamicRetrievalMode and dynamicRetrievalThreshold
  • Updated the API endpoint in vercel.ts to handle dynamic retrieval configuration
  • Added UI controls in the model provider settings to configure dynamic retrieval options
  • Added translations for all 15 language files

Details

  • Dynamic Retrieval allows configuring how the model decides when to use search for grounding responses
  • Added mode selection (Dynamic/Unspecified) and threshold adjustment slider
  • Only available for Gemini models that support Search Grounding, excluding 8B variants

Testing

  • Verified all code changes pass lint and format checks
  • UI controls are properly displayed and functional when Search Grounding is enabled

Link to Devin run: https://app.devin.ai/sessions/873659d0ee2d440992fcf067ebd4d6b0
Requested by: ニケちゃん / nikechan

Summary by CodeRabbit

  • 新機能
    • Google AIサービスの設定に「動的検索」機能を追加し、しきい値スライダーで検索の実行タイミングを調整可能になりました。
  • 改善
    • Google Geminiモデルの選択肢を拡充しました。
  • 翻訳
    • 「動的検索」機能に関する日本語ローカライズを追加しました。

Co-Authored-By: ニケちゃん / nikechan <o3nike.teg.14@gmail.com>
@vercel
Copy link

vercel bot commented May 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
aituber-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2025 10:27am

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@coderabbitai
Copy link

coderabbitai bot commented May 8, 2025

"""

Walkthrough

この変更は、Google Geminiモデルの検索グラウンディング機能に「動的検索(Dynamic Retrieval)」オプションを追加し、しきい値を調整できるUIスライダー、設定ストアの状態管理、APIハンドラでのパラメータ受け渡し、関連する定数・ローカライズを含みます。

Changes

ファイル/グループ 変更内容の概要
locales/ja/translation.json 「動的検索」関連の日本語ローカライズエントリを3件追加
src/components/settings/modelProvider.tsx Google Geminiモデルの検索グラウンディング有効時に「動的検索」スライダーUIを追加し、しきい値の状態管理を導入
src/features/stores/settings.ts 設定ストアに dynamicRetrievalThreshold プロパティを追加し、初期値を0.3に設定。定数のインポート元を修正
src/pages/api/ai/vercel.ts リクエストボディから dynamicRetrievalThreshold を受け取り、該当モデル時にAIサービスのオプションへ動的検索設定を渡すよう変更
src/features/constants/aiModels.ts Google Geminiモデルリストを拡張し、googleSearchGroundingModels 定数を新規追加
src/features/chat/vercelAIChat.ts settingsStore のインポートパスを相対パスに修正し、未使用のインポートを削除
src/components/Live2DComponent.tsx Reactのインポート方法を変更し、関数の戻り値型を明示的に JSX.Element に指定
src/components/live2DViewer.tsx Live2DComponent の動的インポート時にデフォルトエクスポートを明示的に取得するよう修正
tsconfig.json TypeScriptの除外ディレクトリに "website" を追加

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant SettingsStore
    participant API
    participant AIService

    User->>UI: 動的検索しきい値スライダーを調整
    UI->>SettingsStore: dynamicRetrievalThreshold を更新
    User->>UI: モデルと検索グラウンディングを選択し送信
    UI->>API: リクエスト (dynamicRetrievalThreshold含む)
    API->>AIService: モデル・検索グラウンディング・しきい値を含むオプションで呼び出し
    AIService-->>API: 結果返却
    API-->>UI: 結果返却
Loading

Possibly related PRs

  • Geminiの検索機能実装、他 #284: 検索グラウンディング機能の「useSearchGrounding」トグル追加とローカライズ対応を含み、動的しきい値機能とは異なるが、同一機能群の拡張として関連性が高いです。

Suggested labels

devin
"""

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 524625a and e50eb65.

📒 Files selected for processing (4)
  • src/components/Live2DComponent.tsx (2 hunks)
  • src/components/live2DViewer.tsx (1 hunks)
  • src/components/settings/modelProvider.tsx (4 hunks)
  • tsconfig.json (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • src/components/Live2DComponent.tsx
  • tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/components/settings/modelProvider.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
src/components/live2DViewer.tsx (1)

11-12: デフォルトエクスポートを適切に処理するための改善

動的インポートの処理が改善されています。以前はモジュールオブジェクト全体が次のハンドラに渡されていましたが、現在は明示的に mod.default を抽出してからハンドラに渡すようになっています。これにより、Live2DComponent.tsx の変更と整合性が保たれ、TypeScriptの型安全性が向上します。


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 8, 2025

Deploying aituber-kit-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e50eb65
Status: ✅  Deploy successful!
Preview URL: https://d7ffbae8.aituber-kit-4s1.pages.dev
Branch Preview URL: https://devin-1746731343-074859-add.aituber-kit-4s1.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (7)
website/document/zh/guide/ai/model-provider.md (1)

231-244: OpenRouterサービスのドキュメントが追加されていますが、言語の不一致があります

OpenRouterサービスのセクションが追加されていますが、240行目に日本語のテキスト「を参照してください」が含まれています。これは中国語ドキュメントなので、このテキストも中国語に翻訳するべきです。

- [OpenRouter Models](https://openrouter.ai/models)を参照してください。
+ 请参考 [OpenRouter Models](https://openrouter.ai/models)。
.cursor/rules/add-new-llm-provider.mdc (6)

6-6: 不要なバックスラッシュ文字を削除してください。

このバックスラッシュ文字(\)は孤立しており、特に目的が見当たりません。文書のフォーマットを整えるために削除することをお勧めします。

-\

65-67: ルーティング方式の判断方法について具体的な指示を追加してください。

プロジェクトがPages RouterとApp Routerのどちらを使用しているかを判断する方法について、より具体的な指示があれば開発者にとって役立ちます。例えば、プロジェクトのディレクトリ構造やpackage.jsonの依存関係から判断する方法などを追加することを検討してください。

- プロジェクトのルーティング方式(Pages Router または App Router)によって対象ファイルが異なります。
+ プロジェクトのルーティング方式(Pages Router または App Router)によって対象ファイルが異なります。ルート直下に `src/pages` ディレクトリが存在し、その中にAPIエンドポイントが定義されている場合はPages Router、`app` ディレクトリ内にAPI関連のディレクトリがある場合はApp Routerを使用しています。

13-14: Dynamic Retrievalのような既存プロバイダへの機能追加についても言及することを検討してください。

このドキュメントは新しいLLMプロバイダの追加に焦点を当てていますが、PR内容にあるDynamic Retrievalのような既存プロバイダへの新機能追加についても言及すると、より包括的なガイドになります。

このドキュメントは、AITuberKitに新しいLLM(Large Language Model)サービスプロバイダを追加する際の標準的な手順と、変更が必要な主要ファイルをまとめたものです。

+また、このガイドは既存のプロバイダに新しい機能(例:GeminiモデルのDynamic Retrieval機能など)を追加する場合にも参考になります。その場合は、新プロバイダの追加ではなく、既存の設定や状態管理に新しいパラメータを追加し、それに対応するUIコンポーネントとAPIエンドポイントの処理を更新することになります。

47-48: APIキー命名規則の具体例を追加するとより分かりやすくなります。

APIKeysインターフェースとpersist内でのキー名の違いについて言及されていますが、具体的な例を追加するとより理解しやすくなります。

- **注意点**: 既存のコードでは、`APIKeys` インターフェースのキー名 (例: `openai`) と `persist` 内のキー名 (例: `openaiKey`) が異なる場合があります。既存の命名規則に従ってください。
+ **注意点**: 既存のコードでは、`APIKeys` インターフェースのキー名 (例: `openai`, `anthropic`) と `persist` 内のキー名 (例: `openaiKey`, `anthropicKey`) が異なる場合があります。通常は、インターフェース内のキー名に「Key」を付けた形式になります。例えば、新しいプロバイダ「newProvider」を追加する場合、`APIKeys` インターフェースには `newProvider?: string;` を、`persist` 内には `newProviderKey: ""` を追加します。既存の命名規則に従ってください。

84-87: テスト部分により具体的な例を追加すると有用です。

テストの追加・更新に関する説明が簡潔すぎるため、より詳細な手順や例を提供することを検討してください。

### 5. テスト
- (任意) [`src/__tests__/features/chat/aiChatFactory.test.ts`](mdc:src/__tests__/features/chat/aiChatFactory.test.ts) (または関連するテストファイル):
    - 新しく追加したLLMサービスプロバイダに対するテストケースを追加・更新します。
+    - 具体的には以下のようなテストを追加することが望ましいです:
+        - 新プロバイダのAPIキーと設定が正しく保存・読み込みされることを確認するテスト
+        - チャットファクトリが新プロバイダのクライアントを正しく初期化できることを確認するテスト
+        - 新プロバイダを使用したチャット応答が正しく処理されることを確認するテスト(モックを使用)
+    - 既存のテストケースを参考に、同様のパターンで実装してください。
+    - モックデータを使用する場合は、`src/__mocks__/` ディレクトリに適切なモックファイルを追加することも検討してください。

11-14: 多言語対応のドキュメントも検討してください。

このドキュメントは日本語のみで書かれていますが、国際的な貢献者のためにも英語版も提供することを検討してください。特に、オープンソースプロジェクトでは、多言語のドキュメントがより多くの貢献者を惹きつける助けになります。

英語版タイトル例:

# Steps for Adding a New LLM Service Provider

注: 完全な翻訳は不要ですが、将来的に英語版の追加を検討することをお勧めします。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 7b53f11 and bfb067c.

⛔ Files ignored due to path filters (4)
  • package-lock.json is excluded by !**/package-lock.json
  • public/images/ai-logos/openrouter.svg is excluded by !**/*.svg
  • public/images/ai-logos/xai.svg is excluded by !**/*.svg
  • website/document/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (24)
  • .cursor/rules/add-new-llm-provider.mdc (1 hunks)
  • .env.example (2 hunks)
  • locales/ja/translation.json (2 hunks)
  • package.json (2 hunks)
  • src/__tests__/features/chat/aiChatFactory.test.ts (1 hunks)
  • src/components/settings/modelProvider.tsx (6 hunks)
  • src/features/chat/aiChatFactory.ts (1 hunks)
  • src/features/constants/aiModels.ts (3 hunks)
  • src/features/constants/settings.ts (3 hunks)
  • src/features/stores/settings.ts (5 hunks)
  • src/pages/api/services/vercelAi.ts (3 hunks)
  • website/document/en/guide/ai/common.md (1 hunks)
  • website/document/en/guide/ai/model-provider.md (3 hunks)
  • website/document/en/guide/environment-variables.md (1 hunks)
  • website/document/en/guide/introduction.md (1 hunks)
  • website/document/guide/ai/common.md (2 hunks)
  • website/document/guide/ai/model-provider.md (3 hunks)
  • website/document/guide/environment-variables.md (3 hunks)
  • website/document/guide/introduction.md (1 hunks)
  • website/document/package.json (1 hunks)
  • website/document/zh/guide/ai/common.md (2 hunks)
  • website/document/zh/guide/ai/model-provider.md (3 hunks)
  • website/document/zh/guide/environment-variables.md (3 hunks)
  • website/document/zh/guide/introduction.md (1 hunks)
✅ Files skipped from review due to trivial changes (16)
  • website/document/package.json
  • website/document/guide/introduction.md
  • website/document/en/guide/ai/common.md
  • src/features/chat/aiChatFactory.ts
  • website/document/zh/guide/introduction.md
  • website/document/zh/guide/ai/common.md
  • website/document/guide/ai/model-provider.md
  • website/document/guide/ai/common.md
  • package.json
  • website/document/en/guide/introduction.md
  • website/document/en/guide/environment-variables.md
  • src/pages/api/services/vercelAi.ts
  • src/features/constants/settings.ts
  • website/document/guide/environment-variables.md
  • website/document/en/guide/ai/model-provider.md
  • .env.example
🚧 Files skipped from review as they are similar to previous changes (3)
  • locales/ja/translation.json
  • src/components/settings/modelProvider.tsx
  • src/features/stores/settings.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
src/__tests__/features/chat/aiChatFactory.test.ts (1)

64-65: 新しいAIサービスが正しく追加されています

xAIとOpenRouterがaiServices配列に適切に追加されており、テストが正しく機能するようになっています。この変更により、新しいAIサービスがVercel AI SDKを使用することを確認するテストカバレッジが確保されています。

Also applies to: 71-71

website/document/zh/guide/environment-variables.md (3)

108-109: AIサービス一覧が正しく更新されています

xAIとOpenRouterが選択可能なAIサービスのリストに追加されており、ドキュメントが適切に更新されています。


145-146: xAI API Keyの環境変数ドキュメントが追加されています

xAIサービスのAPI Key環境変数が適切に追加されており、ユーザーが適切に設定できるようになっています。


166-167: OpenRouter API Keyの環境変数ドキュメントが追加されています

OpenRouterサービスのAPI Key環境変数が適切に追加されており、ユーザーが適切に設定できるようになっています。

src/features/constants/aiModels.ts (4)

29-37: xAIのモデル一覧が適切に追加されています

xAIサービスのための各種Grokモデルバリアントが適切にリストアップされています。すべての利用可能なGrokモデルが含まれており、ユーザーが選択できるようになっています。


118-118: xAIのデフォルトモデルが適切に設定されています

grok-3がxAIサービスのデフォルトモデルとして正しく設定されています。


125-125: OpenRouterのデフォルトモデルが適切に設定されています

anthropic/claude-3.5-sonnetがOpenRouterサービスのデフォルトモデルとして設定されています。ユーザーが独自のモデルを選択できるようにUI上で適切に表示されるか確認してください。


71-71:

Details

✅ Verification successful

OpenRouterのモデル配列が空で定義されています

OpenRouterのモデル配列が空で定義されていますが、これは意図的でしょうか?OpenRouterは多くのモデルをサポートしているので、事前定義されたモデルリストがあるか、または動的に取得するロジックがあるか確認してください。

以下のスクリプトを実行して、OpenRouterのモデルがコード内の他の場所で定義または動的に取得されているかを確認できます:


🏁 Script executed:

#!/bin/bash
# OpenRouterのモデルが他の場所で定義または取得されているか検索

echo "OpenRouter関連のコードを検索中..."
rg -g "*.ts" -g "*.tsx" "openrouter" --type=ts --type=tsx

Length of output: 253


🏁 Script executed:

#!/bin/bash
echo "全リポジトリでopenrouterを検索中..."
rg -n -i openrouter

Length of output: 7127


OpenRouterのモデル配列は意図的に空です

src/features/constants/aiModels.tsopenrouter: [] としているのは、OpenRouter のモデル一覧をコード内で事前定義せず、ユーザーが設定画面で直接モデル識別子を入力する設計とするためです。
デフォルトで利用するモデルは同ファイル下部の defaultModels.openrouter'anthropic/claude-3.5-sonnet')で指定されています。

— もし事前にモデル一覧を取得・表示したい場合は、OpenRouter の API(https://openrouter.ai/models)から動的に取得するロジックを追加してください。

website/document/zh/guide/ai/model-provider.md (2)

15-15: サポートされているAIサービスリストが更新されています

xAIとOpenRouterが中国語ドキュメントのAIサービスリストに適切に追加されています。

Also applies to: 22-22


104-123: xAIサービスのドキュメントが適切に追加されています

xAIサービスのための詳細なセクションが適切に追加され、API Key設定、サポートされているモデル、およびAPI Keyの取得方法に関する情報が含まれています。

@tegnike
Copy link
Owner

tegnike commented May 15, 2025

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented May 15, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@devin-ai-integration
Copy link
Contributor Author

Devin is currently unreachable - the session may have died.

@tegnike tegnike merged commit a85c1c0 into develop May 15, 2025
6 checks passed
@tegnike tegnike deleted the devin/1746731343.074859-add-dynamic-retrieval-option branch May 15, 2025 10:30
terisuke pushed a commit to terisuke/aituber-kit that referenced this pull request Dec 5, 2025
…dd-dynamic-retrieval-option

Add Dynamic Retrieval option to Search Grounding feature
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.

2 participants