Skip to content

Conversation

bigyao25
Copy link
Contributor

@bigyao25 bigyao25 commented Aug 20, 2025

Pull Request Description (中文)

本次提交全部为 AWS Bedrock provider 相关修改:

  • 修复了一处因 apiType 变动引起的 BedrockProviderSettingsDetail 显示失效
  • 优化了 AWS Bedrock 模型筛选逻辑,不引入其他API的前提下尽可能启用更多获得授权的模型
  • AWS 凭证输入框显示为密码

Summary by CodeRabbit

  • New Features
    • AWS Bedrock: region is now required; default model updated; improved model discovery with grouping, stricter filtering, and region-aware IDs.
    • Bedrock settings: Access Key Id/Secret Access Key inputs are masked; added verification tooltip; clearer missing-credential error; visible success/failure feedback after verification.
  • Bug Fixes
    • Credential verification state now updates reliably on success and failure.
  • Documentation
    • Added verification tip translations (en, fa, fr, ja, ko, ru, zh-CN, zh-HK, zh-TW).
  • Chores
    • Settings routing now targets apiType “aws-bedrock”.

Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

Provider default model and region handling changed; model fetching now uses region, stricter filtering, grouping, and fallback static models on error. Renderer updates Bedrock apiType key, adds password inputs, tooltip, and verification state handling. New i18n key bedrockVerifyTip added across locales.

Changes

Cohort / File(s) Summary
AWS Bedrock provider logic
src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
Default model switched to anthropic.claude-3-5-sonnet-20240620-v1:0. init now requires region. fetchProviderModels reads region, tightens model filtering (regex, non-empty inferenceTypes), builds IDs with region prefix when not ON_DEMAND, adds group derivation, and returns static defaults on failure with updated error messaging.
Renderer Bedrock settings component
src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
Access Key Id/Secret Key inputs set to password type. Added tooltip near Verify using bedrockVerifyTip. validateCredential now sets checkResult on success/failure consistently. Minor cleanup.
Provider selection switch
src/renderer/src/components/settings/ModelProviderSettings.vue
Condition updated to render Bedrock settings when apiType === 'aws-bedrock' (was 'bedrock').
i18n additions
src/renderer/src/i18n/en-US/settings.json, .../fa-IR/settings.json, .../fr-FR/settings.json, .../ja-JP/settings.json, .../ko-KR/settings.json, .../ru-RU/settings.json, .../zh-CN/settings.json, .../zh-HK/settings.json, .../zh-TW/settings.json
Added bedrockVerifyTip string explaining Claude 3.5 Sonnet verification and permission caveat. Adjusted trailing commas on bedrockLimitTip where needed; no semantic changes to existing strings.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App
  participant BedrockProvider as AWS Bedrock Provider
  participant BedrockAPI as AWS Bedrock API

  Note over App,BedrockProvider: Initialization
  App->>BedrockProvider: init(accessKeyId, secretAccessKey, region)
  alt Missing region/keys
    BedrockProvider-->>App: throw "Access Key Id, Secret Access Key and Region are all needed."
  else Valid config
    BedrockProvider-->>App: init OK
  end

  Note over App,BedrockAPI: Model discovery
  App->>BedrockProvider: fetchProviderModels()
  BedrockProvider->>BedrockAPI: listFoundationModels()
  alt API success
    BedrockAPI-->>BedrockProvider: models[]
    BedrockProvider-->>BedrockProvider: filter(regex on modelId, non-empty inferenceTypes)
    BedrockProvider-->>BedrockProvider: derive group (opus/sonnet/haiku/other)
    BedrockProvider-->>BedrockProvider: build IDs (ON_DEMAND vs region-prefixed)
    BedrockProvider-->>App: models (with group/flags)
  else API error
    BedrockAPI--x BedrockProvider: error
    BedrockProvider-->>App: static default models
  end
Loading
sequenceDiagram
  autonumber
  actor User
  participant Settings as Bedrock Settings UI
  participant Tooltip as Tooltip UI
  participant Provider as AWS Bedrock Provider

  User->>Settings: Enter Access Key/Secret/Region (password inputs)
  User->>Settings: Click Verify
  Settings->>Provider: validateCredential()
  alt isOk
    Provider-->>Settings: { isOk: true }
    Settings-->>User: Verified (checkResult=true)
  else failure/error
    Provider-->>Settings: { isOk: false } or error
    Settings-->>User: Verification failed (checkResult=false)
    User-->>Tooltip: Hover "?"
    Tooltip-->>User: bedrockVerifyTip message
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

A rabbit taps the Bedrock door—tap tap—
Regions in paw, I mind the map.
Models sorted: sonnet, haiku, opus queue,
If clouds say no, defaults hop through.
A whispering tooltip by the key,
“Verify gently,” it sings to me. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

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

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@bigyao25 bigyao25 changed the title Feature/add aws bedrock provider feat: add aws bedrock provider Aug 20, 2025
@bigyao25 bigyao25 marked this pull request as ready for review August 20, 2025 10:32
Copy link
Contributor

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts (3)

554-561: Bug: completions payload sends unformatted messages

The payload currently uses the raw messages parameter instead of the formatted messages expected by the Bedrock Anthropic Messages API. This will break non-text content, tool call scaffolding, and system prompt handling.

Apply this diff:

-      const payload = {
-        anthropic_version: 'bedrock-2023-05-31',
-        max_tokens: maxTokens,
-        temperature,
-        system: formattedMessages.system,
-        messages
-      }
+      const payload = {
+        anthropic_version: 'bedrock-2023-05-31',
+        max_tokens: maxTokens ?? 1024,
+        temperature,
+        system: formattedMessages.system,
+        messages: formattedMessages.messages
+      }

657-671: Bug: thinking/tools added after command creation are not sent

thinking and tools are appended to payload after the InvokeModelWithResponseStreamCommand is constructed, so they never reach the API.

Apply this diff to include thinking, system, and tools before creating the command:

-      const payload = {
+      const payload: any = {
         anthropic_version: 'bedrock-2023-05-31',
         max_tokens: maxTokens || 1024,
         temperature: temperature || 0.7,
-        // system: formattedMessagesObject.system,
         messages: formattedMessagesObject.messages,
-        thinking: undefined as any,
-        tools: undefined as any
+        // system is supported by Bedrock Anthropic; include if available
+        system: formattedMessagesObject.system
       }
-      const command = new InvokeModelWithResponseStreamCommand({
-        contentType: 'application/json',
-        body: JSON.stringify(payload),
-        modelId
-      })
 
       // 启用Claude 3.7模型的思考功能
       if (modelId.includes('claude-3-7')) {
-        payload.thinking = { budget_tokens: 1024, type: 'enabled' }
+        payload.thinking = { budget_tokens: 1024, type: 'enabled' }
       }
 
       // 添加工具参数
       if (anthropicTools && anthropicTools.length > 0) {
-        // @ts-ignore - 类型不匹配,但格式是正确的
-        payload.tools = anthropicTools
+        payload.tools = anthropicTools as any
       }
+      const command = new InvokeModelWithResponseStreamCommand({
+        contentType: 'application/json',
+        body: JSON.stringify(payload),
+        modelId
+      })

Also applies to: 673-687


637-642: Remove verbose logs that can leak PII

Dumping full formattedMessagesObject (and modelConfig) risks logging user prompts, tool arguments, and base64 image data. This violates the guideline to avoid logging sensitive information.

Apply this diff to drop the logs (or gate behind a DEBUG env):

-    console.log('modelConfig', modelConfig, modelId)
+    // DEBUG: console.log('modelConfig.id', modelId)
     try {
       // 格式化消息
       const formattedMessagesObject = this.formatMessages(messages)
-      console.log('formattedMessagesObject', JSON.stringify(formattedMessagesObject))
+      // DEBUG: console.log('formattedMessages prepared')

If you prefer gating:

  • Wrap any debug logging with if (process.env.LOG_LEVEL === 'DEBUG') and redact content (e.g., lengths, counts) instead of raw payloads.
src/renderer/src/components/settings/ModelProviderSettings.vue (1)

141-145: Back-compat: also accept legacy apiType 'bedrock'

If user configs persisted 'bedrock' previously, the specialized Bedrock settings panel would no longer render. Keep backward compatibility by matching both values.

Apply this diff:

-      <BedrockProviderSettingsDetail
-        v-else-if="activeProvider.apiType === 'aws-bedrock'"
+      <BedrockProviderSettingsDetail
+        v-else-if="activeProvider.apiType === 'aws-bedrock' || activeProvider.apiType === 'bedrock'"
         :key="`bedrock-${activeProvider.id}`"
         :provider="activeProvider as AWS_BEDROCK_PROVIDER"
         class="flex-1"
       />
src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue (1)

6-17: Localize labels and use correct placeholders for AWS fields; also disable browser autofill for secrets

  • Hardcoded labels (“AWS Access Key Id”, “AWS Secret Access Key”, “AWS Region”) violate the i18n guideline.
  • Placeholders use urlPlaceholder, which is misleading for access keys/region.
  • For password inputs, disable autofill/spellcheck.

Apply this diff in the selected ranges:

-          <Label :for="`${provider.id}-accessKeyId`" class="flex-1 cursor-pointer"
-            >AWS Access Key Id</Label
-          >
+          <Label :for="`${provider.id}-accessKeyId`" class="flex-1 cursor-pointer">
+            {{ t('settings.provider.awsAccessKeyId') }}
+          </Label>
           <Input
             :id="`${provider.id}-accessKeyId`"
             :model-value="accessKeyId"
             type="password"
-            :placeholder="t('settings.provider.urlPlaceholder')"
+            :placeholder="t('settings.provider.awsAccessKeyIdPlaceholder')"
+            autocomplete="off"
+            spellcheck="false"
+            autocapitalize="off"
             @blur="handleAccessKeyIdChange(String($event.target.value))"
             @keyup.enter="handleAccessKeyIdChange(accessKeyId)"
             @update:model-value="accessKeyId = String($event)"
           />

-          <Label :for="`${provider.id}-secretAccessKey`" class="flex-1 cursor-pointer"
-            >AWS Secret Access Key</Label
-          >
+          <Label :for="`${provider.id}-secretAccessKey`" class="flex-1 cursor-pointer">
+            {{ t('settings.provider.awsSecretAccessKey') }}
+          </Label>
           <Input
             :id="`${provider.id}-secretAccessKey`"
             :model-value="secretAccessKey"
             type="password"
-            :placeholder="t('settings.provider.urlPlaceholder')"
+            :placeholder="t('settings.provider.awsSecretAccessKeyPlaceholder')"
+            autocomplete="off"
+            spellcheck="false"
+            autocapitalize="off"
             @blur="handleSecretAccessKeyChange(String($event.target.value))"
             @keyup.enter="handleSecretAccessKeyChange(secretAccessKey)"
             @update:model-value="secretAccessKey = String($event)"
           />

-          <Label :for="`${provider.id}-region`" class="flex-1 cursor-pointer">AWS Region</Label>
+          <Label :for="`${provider.id}-region`" class="flex-1 cursor-pointer">
+            {{ t('settings.provider.awsRegion') }}
+          </Label>
           <Input
             :id="`${provider.id}-region`"
             :model-value="region"
-            :placeholder="t('settings.provider.urlPlaceholder')"
+            :placeholder="t('settings.provider.awsRegionPlaceholder')"
             @blur="handleRegionChange(String($event.target.value))"
             @keyup.enter="handleRegionChange(region)"
             @update:model-value="region = String($event)"
           />

Follow-up: add the new i18n keys across locales:

  • settings.provider.awsAccessKeyId / awsAccessKeyIdPlaceholder
  • settings.provider.awsSecretAccessKey / awsSecretAccessKeyPlaceholder
  • settings.provider.awsRegion / awsRegionPlaceholder

I can add these keys in all locales if you want me to push a patch.

Also applies to: 20-31, 34-42

🧹 Nitpick comments (16)
src/renderer/src/i18n/zh-TW/settings.json (1)

444-446: Polish zh-TW phrasing: use 權限 and add comma for readability

Minor localization refinement to align with common zh-TW usage and improve readability.

Apply this diff:

-    "bedrockVerifyTip": "DeepChat 使用 Claude 3.5 Sonnet 模型驗證,若您無此模型的呼叫許可權驗證將失敗。這不會影響其他模型的使用。"
+    "bedrockVerifyTip": "DeepChat 使用 Claude 3.5 Sonnet 進行驗證,若您無此模型的呼叫權限,驗證將失敗。這不會影響其他模型的使用。"
src/renderer/src/i18n/ja-JP/settings.json (1)

444-446: Refine ja-JP wording: “起動権限” → “呼び出し権限”; naturalize “のみサポートしています”

These are standard phrasing tweaks for clarity and idiomatic Japanese.

Apply this diff:

-    "bedrockLimitTip": "* Anthropic Claude(Opus、Sonnet、Haikuモデルを含む)のみをサポート",
+    "bedrockLimitTip": "* Anthropic Claude(Opus、Sonnet、Haikuモデルを含む)のみサポートしています",
-    "bedrockVerifyTip": "DeepChatは検証にClaude 3.5 Sonnetを使用しています。起動権限がない場合、検証は失敗します。ただし、他のモデルの使用には影響しません。"
+    "bedrockVerifyTip": "DeepChatは検証にClaude 3.5 Sonnetを使用しています。該当モデルの呼び出し権限がない場合、検証は失敗します。他のモデルの使用には影響しません。"
src/renderer/src/i18n/zh-CN/settings.json (1)

444-446: Add a comma for zh-CN readability

Small punctuation fix to avoid a run-on sentence.

Apply this diff:

-    "bedrockVerifyTip": "DeepChat 使用 Claude 3.5 Sonnet 模型验证,若您无此模型的调用权限验证将失败。这不会影响其他模型的使用。"
+    "bedrockVerifyTip": "DeepChat 使用 Claude 3.5 Sonnet 模型验证,若您无此模型的调用权限,验证将失败。这不会影响其他模型的使用。"
src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts (7)

93-98: Use English and structured logs; avoid mixed-language messages

Console messages here are in Chinese. Please standardize logs to English per code guidelines and prefer structured context.

Apply this diff:

-  console.error('获取AWS Bedrock Anthropic模型列表出错:', error)
+  console.error('Failed to list AWS Bedrock Anthropic models', { error })
-// 如果API请求失败或返回数据解析失败,返回默认模型列表
-console.log('从API获取模型列表失败,使用默认模型配置')
+// Fall back to static model list if API call fails
+console.warn('Falling back to static AWS Bedrock model list due to API failure')

165-166: Unify user-facing errors to English and keep details in logs

The error returned by check() is Chinese. Standardize to English; keep detailed diagnostics in logs to avoid leaking internals to end users.

-        return { isOk: false, errorMsg: '未初始化 AWS Bedrock SDK' }
+        return { isOk: false, errorMsg: 'AWS Bedrock SDK is not initialized' }
@@
-      return { isOk: false, errorMsg: `API 检查失败: ${errorMessage}` }
+      return { isOk: false, errorMsg: `API check failed: ${errorMessage}` }

Also applies to: 195-198


777-797: Translate remaining error logs to English

More Chinese logs remain in the stream parser; standardize to English.

-                  console.error('解析完整JSON失败:', e)
+                  console.error('Failed to parse accumulated JSON', { error: e })
@@
-              console.error('处理累积JSON失败:', e)
+              console.error('Failed to handle accumulated JSON', { error: e })

76-81: Optional: expose real model capabilities from Bedrock metadata

You currently hardcode vision/functionCall/reasoning to false. Bedrock’s ListFoundationModels returns modality metadata you can use to improve UI accuracy (e.g., enabling image/vision features).

-          ?.filter((m) => m.modelId && /^anthropic.claude-[a-z0-9\-]+(:\d+)$/g.test(m.modelId))
+          ?.filter((m) => m.modelId && /^anthropic\.claude-[a-z0-9\-]+(:\d+)$/.test(m.modelId))
@@
-          .map<MODEL_META>((m) => ({
+          .map<MODEL_META>((m) => ({
             id: `${m.inferenceTypesSupported?.includes('ON_DEMAND') ? m.modelId! : `${region.split('-')[0]}.${m.modelId}`}`,
             name: m.modelId?.replace('anthropic.', '') || '<Unknown>',
             providerId: this.provider.id,
             maxTokens: 64_000,
             group: `AWS Bedrock Claude - ${m.modelId?.includes('opus') ? 'opus' : m.modelId?.includes('sonnet') ? 'sonnet' : m.modelId?.includes('haiku') ? 'haiku' : 'other'}`,
             isCustom: false,
             contextLength: 200_000,
-            vision: false,
-            functionCall: false,
-            reasoning: false
+            vision: (m.inputModalities?.includes('IMAGE') ?? false),
+            functionCall: true, // Anthropic Messages API supports tool_use
+            reasoning: m.modelId?.includes('claude-3-7') || m.modelId?.includes('sonnet-4') || false
           }))

Note: If you prefer strictness, derive functionCall/reasoning based on a maintained allowlist instead of heuristics.

Also applies to: 87-90


46-48: Credential validation improved; align message with guidelines

Good to enforce region presence. Consider adding a providerId/context to the error to aid triaging without exposing secrets.


233-245: Optional: default max_tokens to a safe value in generateText

Some Bedrock models require max_tokens. Defaulting avoids API errors when callers omit it.

-        max_tokens: maxTokens,
+        max_tokens: maxTokens ?? 1024,

79-81: Clarify cross-Region inference profile vs base model ID prefixing

AWS official guidance says:

  • Use the plain foundation-model ID (e.g. anthropic.claude-3-5-sonnet-…:0) for on-demand inference in the Region where the model is deployed.
  • Use the prefixed inference-profile ID (e.g. us.anthropic.claude-3-5-sonnet-…:0, eu.anthropic…) only when you need system-defined cross-Region routing; the us./eu. prefix denotes the geographic inference-profile grouping, not provisioned throughput.

Your current mapping (lines 79–81) is:

id: `${m.inferenceTypesSupported?.includes('ON_DEMAND')
       ? m.modelId!
       : `${region.split('-')[0]}.${m.modelId}`}`,

This pattern may work today but is brittle:

  • Inference-profile IDs might not always follow region.split('-')[0] + modelId.
  • Provisioned throughput calls require the model’s provisioned-throughput ARN/ID, not a prefixed base model or inference-profile ID.

Recommendations:
• Keep using m.modelId directly for on-demand, in-region calls.
• For cross-Region inference, call ListInferenceProfiles and select the returned profile ID that matches your model.
• For provisioned throughput, surface and use the provisioned model ARN/ID per the PT docs.

Location to update:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts (lines 79–81)
src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue (5)

45-56: Add loading state to the “Verify” button to prevent duplicate submissions

Currently, verify can be triggered multiple times; no visual feedback is shown.

Apply this diff to the button:

-          <Button
+          <Button
             variant="outline"
             size="xs"
             class="text-xs text-normal rounded-lg"
+            :disabled="isVerifying"
             @click="
               handleVerifyCredential({ credential: { accessKeyId, secretAccessKey, region } })
             "
           >
-            <Icon icon="lucide:check-check" class="w-4 h-4 text-muted-foreground" />{{
+            <Icon
+              v-if="!isVerifying"
+              icon="lucide:check-check"
+              class="w-4 h-4 text-muted-foreground"
+            />
+            <Icon
+              v-else
+              icon="lucide:loader-circle"
+              class="w-4 h-4 text-muted-foreground animate-spin"
+            />
+            {{
               t('settings.provider.verifyKey')
             }}
           </Button>

And update the handler to toggle the loading flag:

// Add near other refs
const isVerifying = ref(false)

// Update handler
const handleVerifyCredential = async (updates: Partial<AWS_BEDROCK_PROVIDER>) => {
  isVerifying.value = true
  try {
    await settingsStore.updateAwsBedrockProviderConfig(props.provider.id, updates)
    await validateCredential()
  } finally {
    isVerifying.value = false
  }
}

57-66: Tooltip addition looks good; add a11y hints for keyboard/screen readers

Nice addition. Minor a11y polish:

  • Make the trigger focusable.
  • Give the icon an accessible label.
-            <Tooltip>
-              <TooltipTrigger>
-                <Icon icon="lucide:help-circle" class="w-4 h-4 text-muted-foreground" />
-              </TooltipTrigger>
+            <Tooltip>
+              <TooltipTrigger tabindex="0">
+                <Icon
+                  icon="lucide:help-circle"
+                  class="w-4 h-4 text-muted-foreground cursor-help"
+                  aria-label="Verification help"
+                  role="img"
+                />
+              </TooltipTrigger>
               <TooltipContent>
                 <p>{{ t('settings.provider.bedrockVerifyTip') }}</p>
               </TooltipContent>
             </Tooltip>

155-157: Avoid in-place sort on store data; handle possibly undefined group

Sorting providerData.models mutates store state in place and may throw if group is undefined. Copy first and guard group.

-    providerModels.value = providerData.models.sort(
-      (a, b) => a.group.localeCompare(b.group) || a.providerId.localeCompare(b.providerId)
-    )
+    providerModels.value = [...providerData.models].sort((a, b) => {
+      const ga = a.group || ''
+      const gb = b.group || ''
+      return ga.localeCompare(gb) || a.providerId.localeCompare(b.providerId)
+    })

215-233: Keep logs/comments in English and unify verify-result handling

  • Good: checkResult is set on all branches; showCheckModelDialog toggled consistently.
  • Please switch non-English logs/comments to English per repo guidelines.
-    if (resp.isOk) {
-      console.log('验证成功')
+    if (resp.isOk) {
+      console.log('Credential verification succeeded')
       checkResult.value = true
       showCheckModelDialog.value = true
-      // 验证成功后刷新当前provider的模型列表
+      // Refresh current provider's model list after successful verification
       await settingsStore.refreshProviderModels(props.provider.id)
     } else {
-      console.log('验证失败', resp.errorMsg)
+      console.warn('Credential verification failed:', resp.errorMsg)
       checkResult.value = false
       showCheckModelDialog.value = true
     }
   } catch (error) {
-    console.error('Failed to validate credential:', error)
+    console.error('Credential validation error:', error)
     checkResult.value = false
     showCheckModelDialog.value = true
   }

258-266: Typo: rename parameter “comfirm” to “confirm”

Pure readability nit; safe change.

-const handleModelEnabledChange = async (
-  model: RENDERER_MODEL_META,
-  enabled: boolean,
-  comfirm: boolean = false
-) => {
-  if (!enabled && comfirm) {
+const handleModelEnabledChange = async (
+  model: RENDERER_MODEL_META,
+  enabled: boolean,
+  confirm: boolean = false
+) => {
+  if (!enabled && confirm) {
     disableModel(model)
   } else {
     await settingsStore.updateModelStatus(props.provider.id, model.id, enabled)
   }
 }
src/renderer/src/i18n/fr-FR/settings.json (1)

444-446: New bedrockVerifyTip: looks good; add AWS field labels/placeholders for full i18n coverage

  • The added bedrockVerifyTip reads well in French and matches the UI usage.
  • Suggest adding dedicated AWS keys used in the component refactor (labels/placeholders), to avoid borrowing generic placeholders:

Proposed additions under "provider":

  • "awsAccessKeyId": "ID de clé d’accès AWS"
  • "awsAccessKeyIdPlaceholder": "Saisissez l’ID de clé d’accès"
  • "awsSecretAccessKey": "Clé d’accès secrète AWS"
  • "awsSecretAccessKeyPlaceholder": "Saisissez la clé d’accès secrète"
  • "awsRegion": "Région AWS"
  • "awsRegionPlaceholder": "Saisissez la région AWS (ex. us-east-1)"

I can mirror these across all locales in this PR to keep it consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5284000 and 7bef364.

📒 Files selected for processing (12)
  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts (3 hunks)
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue (5 hunks)
  • src/renderer/src/components/settings/ModelProviderSettings.vue (1 hunks)
  • src/renderer/src/i18n/en-US/settings.json (1 hunks)
  • src/renderer/src/i18n/fa-IR/settings.json (1 hunks)
  • src/renderer/src/i18n/fr-FR/settings.json (1 hunks)
  • src/renderer/src/i18n/ja-JP/settings.json (1 hunks)
  • src/renderer/src/i18n/ko-KR/settings.json (1 hunks)
  • src/renderer/src/i18n/ru-RU/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-CN/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-HK/settings.json (1 hunks)
  • src/renderer/src/i18n/zh-TW/settings.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (16)
src/renderer/src/**/*

📄 CodeRabbit Inference Engine (.cursor/rules/i18n.mdc)

src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system

Files:

  • src/renderer/src/i18n/zh-HK/settings.json
  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/i18n/en-US/settings.json
  • src/renderer/src/i18n/zh-CN/settings.json
  • src/renderer/src/i18n/fa-IR/settings.json
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
  • src/renderer/src/i18n/fr-FR/settings.json
  • src/renderer/src/i18n/zh-TW/settings.json
  • src/renderer/src/i18n/ru-RU/settings.json
  • src/renderer/src/i18n/ko-KR/settings.json
  • src/renderer/src/i18n/ja-JP/settings.json
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Use English for logs and comments

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/renderer/src/**/*.vue

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/renderer/src/**/*.vue: Use Composition API for all Vue 3 components
Use Tailwind CSS with scoped styles for styling
Organize components by feature in src/renderer/src/
Follow existing component patterns in src/renderer/src/ when creating new UI components
Use Composition API with proper TypeScript typing for new UI components
Implement responsive design with Tailwind CSS for new UI components
Add proper error handling and loading states for new UI components

Use scoped styles to prevent CSS conflicts between components

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/src/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/renderer/src/**/*.{ts,tsx,vue}: Use Pinia for frontend state management
Renderer to Main: Use usePresenter.ts composable for direct presenter method calls

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

渲染进程代码放在 src/renderer

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-best-practices.mdc)

src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/**/*.{ts,tsx,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/**/*.{vue,ts}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

Implement lazy loading for routes and components.

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
src/renderer/**/*.{ts,vue}

📄 CodeRabbit Inference Engine (.cursor/rules/vue-shadcn.mdc)

src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.

Files:

  • src/renderer/src/components/settings/ModelProviderSettings.vue
  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Strict type checking enabled for TypeScript

**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/main/**/*.ts

📄 CodeRabbit Inference Engine (CLAUDE.md)

Main to Renderer: Use EventBus to broadcast events via mainWindow.webContents.send()

Use Electron's built-in APIs for file system and native dialogs

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/main/presenter/**/*.ts

📄 CodeRabbit Inference Engine (CLAUDE.md)

One presenter per functional domain

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/main/presenter/llmProviderPresenter/providers/*.ts

📄 CodeRabbit Inference Engine (CLAUDE.md)

src/main/presenter/llmProviderPresenter/providers/*.ts: Create provider file in src/main/presenter/llmProviderPresenter/providers/ when adding a new LLM provider
Implement coreStream method following standardized event interface in LLM provider files

src/main/presenter/llmProviderPresenter/providers/*.ts: Each file in src/main/presenter/llmProviderPresenter/providers/*.ts should handle interaction with a specific LLM API, including request/response formatting, tool definition conversion, native/non-native tool call management, and standardizing output streams to a common event format.
Provider implementations must use a coreStream method that yields standardized stream events to decouple the main loop from provider-specific details.
The coreStream method in each Provider must perform a single streaming API request per conversation round and must not contain multi-round tool call loop logic.
Provider files should implement helper methods such as formatMessages, convertToProviderTools, parseFunctionCalls, and prepareFunctionCallPrompt as needed for provider-specific logic.
All provider implementations must parse provider-specific data chunks and yield standardized events for text, reasoning, tool calls, usage, errors, stop reasons, and image data.
When a provider does not support native function calling, it must prepare messages using prompt wrapping (e.g., prepareFunctionCallPrompt) before making the API call.
When a provider supports native function calling, MCP tools must be converted to the provider's format (e.g., using convertToProviderTools) and included in the API request.
Provider implementations should aggregate and yield usage events as part of the standardized stream.
Provider implementations should yield image data events in the standardized format when applicable.
Provider implementations should yield reasoning events in the standardized format when applicable.
Provider implementations should yield tool call events (`tool_call_star...

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/development-setup.mdc)

**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/{main,renderer}/**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/electron-best-practices.mdc)

src/{main,renderer}/**/*.ts: Use context isolation for improved security
Implement proper inter-process communication (IPC) patterns
Optimize application startup time with lazy loading
Implement proper error handling and logging for debugging

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
src/main/**/*.{ts,js,tsx,jsx}

📄 CodeRabbit Inference Engine (.cursor/rules/project-structure.mdc)

主进程代码放在 src/main

Files:

  • src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts
🧠 Learnings (3)
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Import Icon component from Iconify/Vue.

Applied to files:

  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
📚 Learning: 2025-07-23T00:45:57.322Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/vue-shadcn.mdc:0-0
Timestamp: 2025-07-23T00:45:57.322Z
Learning: Applies to src/renderer/**/*.{vue} : Use Iconify/Vue for icon implementation.

Applied to files:

  • src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue
📚 Learning: 2025-07-21T01:46:30.354Z
Learnt from: CR
PR: ThinkInAIXYZ/deepchat#0
File: .cursor/rules/i18n.mdc:0-0
Timestamp: 2025-07-21T01:46:30.354Z
Learning: Applies to src/renderer/src/i18n/common.json : Shared translation keys must be placed in 'src/renderer/src/i18n/common.json'

Applied to files:

  • src/renderer/src/i18n/zh-TW/settings.json
🧬 Code Graph Analysis (1)
src/main/presenter/llmProviderPresenter/providers/awsBedrockProvider.ts (1)
src/shared/presenter.d.ts (1)
  • MODEL_META (480-493)
🔇 Additional comments (10)
src/renderer/src/i18n/fa-IR/settings.json (1)

444-446: LGTM: new Bedrock tips added and JSON remains valid

The key names and placement under provider are consistent with other locales. No issues spotted.

src/renderer/src/i18n/en-US/settings.json (1)

444-446: Localization coverage confirmed across all locales
All nine settings.json files (en-US, fa-IR, fr-FR, ja-JP, ko-KR, ru-RU, zh-CN, zh-HK, zh-TW) include bedrockVerifyTip. You can safely apply the en-US phrasing tweaks:

-    "bedrockLimitTip": "* Only Anthropic Claude supported (including Opus, Sonnet, Haiku models)",
+    "bedrockLimitTip": "* Only Anthropic Claude is supported (including Opus, Sonnet, Haiku models)",
-    "bedrockVerifyTip": "DeepChat uses Claude 3.5 Sonnet for verification. If you do not have permission to invoke, the verification will fail. This will not affect the use of other models."
+    "bedrockVerifyTip": "DeepChat uses Claude 3.5 Sonnet for verification. If you do not have permission to invoke this model, verification will fail. This does not affect other models."
src/renderer/src/i18n/ru-RU/settings.json (2)

444-446: LGTM: new Bedrock verification tooltip localized

The new bedrockVerifyTip string and the trailing comma on bedrockLimitTip look correct. Matches the UI change to display a tooltip near the Verify button.


444-446: All locales include bedrockVerifyTip

The bedrockVerifyTip key is present in every settings.json under src/renderer/src/i18n/ (en-US, fa-IR, fr-FR, ja-JP, ko-KR, ru-RU, zh-CN, zh-HK, zh-TW). No missing translations found.

src/renderer/src/i18n/zh-HK/settings.json (2)

444-446: LGTM: adds bedrockVerifyTip and keeps limit tip intact

Localization looks accurate, and the trailing comma change is correct JSON hygiene.


444-446: bedrockVerifyTip key present in all locales
Verified that the bedrockVerifyTip entry is defined in every src/renderer/src/i18n/**/settings.json file. No further action required.

src/renderer/src/components/settings/ModelProviderSettings.vue (1)

141-145: Verify migration for renamed Bedrock provider
Please ensure that any stored provider entries with apiType: 'bedrock' are automatically migrated to apiType: 'aws-bedrock' on load to avoid split behavior. I didn’t find any code handling this rename—can you confirm the migration logic is in place?

src/renderer/src/i18n/ko-KR/settings.json (2)

444-446: LGTM: Korean translation for Bedrock verification tooltip

Text reads naturally, intent matches the UI behavior.


444-446: All locales include bedrockVerifyTip
I’ve confirmed via rg -n --glob 'src/renderer/src/i18n/**/settings.json' '"bedrockVerifyTip"\s*:' that the key appears in every settings.json (zh-HK, fr-FR, zh-TW, ja-JP, ru-RU, fa-IR, en-US, zh-CN, ko-KR). No missing entries—tooltips are consistent across all locales.

src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue (1)

113-113: LGTM: Tooltip imports

Importing Tooltip components from the UI library matches usage in the template.

<Input
:id="`${provider.id}-accessKeyId`"
:model-value="accessKeyId"
type="password"
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Placeholders/labels mismatch and i18n usage verification

  • Using urlPlaceholder for credentials/region is confusing; fixed above.
  • “bedrockLimitTip” is correctly localized. Once you add new AWS i18n keys, verify all locales are present to avoid missing-translation UI glitches.

Run this to validate:

Also applies to: 26-26, 34-35, 69-69


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Check bedrockVerifyTip exists in all locales"
rg -n '"bedrockVerifyTip"' src/renderer/src/i18n -C1

echo "Find hardcoded AWS labels still present in renderer"
rg -nP 'AWS (Access Key Id|Secret Access Key|Region)' src/renderer/src -g '!**/node_modules/**' -C2

echo "Find non-English (CJK) logs/comments in renderer code"
rg -nP '[\p{Han}]' src/renderer/src -g '!**/node_modules/**' -C2

Length of output: 274635


Replace Hardcoded AWS Labels with i18n Keys

  • Confirmed bedrockVerifyTip exists in all locales.
  • In src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue, replace the hardcoded AWS labels/placeholder misuse with dedicated i18n keys:
    • Line 7: change
    <Label …>AWS Access Key Id</Label>
    {{ t('settings.provider.awsAccessKeyId') }}
    • Line 21: change
    <Label …>AWS Secret Access Key</Label>
    {{ t('settings.provider.awsSecretAccessKey') }}
    • Line 34: change
    <Label …>AWS Region</Label>
    {{ t('settings.provider.awsRegion') }}
    • For each <Input> under those labels, replace urlPlaceholder with :placeholder="t('settings.provider.awsAccessKeyIdPlaceholder')" (and likewise for secretAccessKeyPlaceholder / regionPlaceholder).
  • Define the following new keys (and placeholder variants) under settings.provider in every locale’s settings.json to ensure full coverage:
    • awsAccessKeyId
    • awsAccessKeyIdPlaceholder
    • awsSecretAccessKey
    • awsSecretAccessKeyPlaceholder
    • awsRegion
    • awsRegionPlaceholder
  • Remove or translate all remaining non-English (CJK) comments/logs in the renderer code to maintain consistency.
🤖 Prompt for AI Agents
In src/renderer/src/components/settings/BedrockProviderSettingsDetail.vue around
lines 7, 12, 21, 34, replace the hardcoded label text "AWS Access Key Id", "AWS
Secret Access Key" and "AWS Region" with i18n lookups (e.g. use
t('settings.provider.awsAccessKeyId'),
t('settings.provider.awsSecretAccessKey'), t('settings.provider.awsRegion')),
and update each corresponding <Input> to use
:placeholder="t('settings.provider.awsAccessKeyIdPlaceholder')" (and the
secret/region placeholder keys respectively) instead of the current
urlPlaceholder; then add the six new keys (awsAccessKeyId,
awsAccessKeyIdPlaceholder, awsSecretAccessKey, awsSecretAccessKeyPlaceholder,
awsRegion, awsRegionPlaceholder) under settings.provider in every locale's
settings.json, and remove or translate any remaining non-English (CJK)
comments/logs in the renderer code for consistency.

@zerob13 zerob13 merged commit f28e4f2 into ThinkInAIXYZ:dev Aug 21, 2025
2 checks passed
@zerob13
Copy link
Collaborator

zerob13 commented Aug 21, 2025

There are some modifications we need to synchronize with you, but currently, there isn’t a convenient way to reach you. Attempting to push code to your PR branch also doesn’t seem to have updated it, so we’ve opened a new PR to address the issue:
#759
If it’s convenient, feel free to email me at
[email protected], and we can establish a better communication channel. Thank you for your support!

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