Skip to content

i18N Support for llm provider and ai model description - #171

Merged
iFurySt merged 2 commits into
AmoyLab:mainfrom
boston008:i18n-support-llm-provider-ai-models
Jun 30, 2025
Merged

iFurySt merged 2 commits into
AmoyLab:mainfrom
boston008:i18n-support-llm-provider-ai-models

Conversation

@boston008

@boston008 boston008 commented Jun 27, 2025 •

Copy link
Copy Markdown
Contributor

i18N Support for llm provider and ai model description

#170

Summary by Sourcery

Add internationalization support for LLM provider and model descriptions and integrate them in the settings UI with fallback logic

New Features:

  • Introduce getI18nDescription, getProviderDescription, and getModelDescription utilities for fetching translated texts

Enhancements:

  • Implement fallback lookup for model descriptions by provider-specific then generic keys

Documentation:

  • Add locale entries in translation JSON files for provider and model descriptions

i18N Support for llm provider and ai model description
@sourcery-ai

sourcery-ai Bot commented Jun 27, 2025 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This PR adds i18n support for LLM provider and model descriptions by introducing a generic description lookup utility, creating provider- and model-specific helper functions with fallback logic, integrating those into the settings UI, and updating translation files with the new keys.

Sequence diagram for provider/model description i18n lookup

sequenceDiagram
    participant UI as LLMSettings UI
    participant Adapter as llm-providers-adapter
    participant i18n as i18next
    UI->>Adapter: getProviderDescription(providerId, fallback, lng)
    Adapter->>i18n: t('llm.providerDescriptions.{providerId}', {lng})
    i18n-->>Adapter: translation or key
    Adapter-->>UI: translated or fallback
    UI->>Adapter: getModelDescription(providerId, modelId, fallback, lng)
    Adapter->>i18n: t('llm.modelDescriptions.{providerId}.{modelId}', {lng})
    i18n-->>Adapter: translation or key
    Adapter->>i18n: t('llm.modelDescriptions.{modelId}', {lng}) (if needed)
    i18n-->>Adapter: translation or key
    Adapter-->>UI: translated or fallback
Loading

Class diagram for i18n description utilities

classDiagram
    class llm_providers_adapter {
        +getProviderDescription(providerId: string, fallback: string, lng?: string): string
        +getModelDescription(providerId: string, modelId: string, fallback: string, lng?: string): string
        getI18nDescription(key: string, fallback: string, lng?: string): string
    }
Loading

File-Level Changes

Change Details Files
Add generic and specialized i18n description functions
  • Implement getI18nDescription with error handling and fallback
  • Create getProviderDescription for provider-specific keys
  • Create getModelDescription with provider-first lookup and fallback
web/src/config/llm-providers-adapter.ts
Use i18n helpers in the LLM settings UI
  • Replace raw provider.description with getProviderDescription call
  • Replace raw model.description with i18n model description lookup
web/src/pages/llm/llm-settings.tsx
Update translation files with new description keys
  • Add llm.providerDescriptions entries in English and Chinese
  • Add llm.modelDescriptions entries in English and Chinese
web/src/i18n/locales/en/translation.json
web/src/i18n/locales/zh/translation.json

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @boston008 - I've reviewed your changes - here's some feedback:

  • In llm-settings.tsx you’re calling getI18nModelDescription but the exported helper is named getModelDescription—please update the call/import to match.
  • The getI18nDescription helper currently catches all errors silently; consider narrowing the catch to i18next-specific errors or adding a debug log to avoid masking other issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In llm-settings.tsx you’re calling getI18nModelDescription but the exported helper is named getModelDescription—please update the call/import to match.
- The getI18nDescription helper currently catches all errors silently; consider narrowing the catch to i18next-specific errors or adding a debug log to avoid masking other issues.

## Individual Comments

### Comment 1
<location> `web/src/pages/llm/llm-settings.tsx:636` </location>
<code_context>
                   <h1 className="text-xl font-bold">{selectedProvider.name}</h1>
                   <p className="text-sm text-muted-foreground">
-                    {selectedProvider.description}
+                    {getProviderDescription(
+                      selectedProvider.id,
+                      selectedProvider.description || selectedProvider.name
</code_context>

<issue_to_address>
getProviderDescription is used, but getI18nModelDescription is used elsewhere.

Consider aligning the naming of i18n helper functions for consistency across the codebase.

Suggested implementation:

```typescript
import { BUILTIN_PROVIDERS, getProviderDefaultConfig, getDefaultBaseURL, buildEndpointURL, getProviderDescription as getI18nProviderDescription, getModelDescription as getI18nModelDescription } from '@/config/llm-providers-adapter';

```

```typescript
                    {getI18nProviderDescription(
                      selectedProvider.id,
                      selectedProvider.description || selectedProvider.name
                    )}

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread web/src/pages/llm/llm-settings.tsx Resolved
updated to use getI18nProviderDescription

@iFurySt iFurySt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Great improvement, thanks a lot.

@iFurySt
iFurySt merged commit e8be39d into AmoyLab:main Jun 30, 2025
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