Skip to content

💄 style: Allow Gemini as custom provider #8190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sxjeru
Copy link
Contributor

@sxjeru sxjeru commented Jun 15, 2025

💻 变更类型 | Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • 📝 docs
  • 🔨 chore

🔀 变更说明 | Description of Change

不知道能不能这样改,目前无法在启用客户端请求的情况下正常使用。

根据测试,anthropic 类型的自定义提供商也不支持客户端请求,可能是 lobechat 没有做支持,可以暂时考虑隐藏掉客户端请求开关。

另服务商名称不再必需,为空时自动采用服务商 id 。

📝 补充信息 | Additional Information

Summary by Sourcery

Enable using ID as a fallback name for new AI providers, remove mandatory name validation, and introduce Gemini to the SDK type dropdown.

New Features:

  • Allow using the provider ID as the name when the name field is empty
  • Add Gemini as an option in the SDK type selection

Enhancements:

  • Remove the required validation rule for the provider name field

Copy link

vercel bot commented Jun 15, 2025

@sxjeru is attempting to deploy a commit to the LobeHub Community Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

sourcery-ai bot commented Jun 15, 2025

Reviewer's Guide

Implement name fallback to ID for new AI providers and add Gemini as an SDK type option.

Sequence Diagram for AI Provider Creation with Name Fallback Logic

sequenceDiagram
    actor User
    participant CreateNewProviderForm as Form UI
    participant CreateNewProviderComponent as Component Logic
    participant createNewAiProviderFunc as createNewAiProvider()

    User->>CreateNewProviderForm: Fills provider details (ID, optional Name, SDK Type, etc.)
    User->>CreateNewProviderForm: Submits form
    CreateNewProviderForm->>CreateNewProviderComponent: onSubmit(values)
    CreateNewProviderComponent->>CreateNewProviderComponent: finalName = values.name ? values.name : values.id
    CreateNewProviderComponent->>createNewAiProviderFunc: Call with {..., name: finalName, ...}
    createNewAiProviderFunc-->>CreateNewProviderComponent: Promise (e.g., success)
    alt Creation Successful
        CreateNewProviderComponent->>User: Display success message
        CreateNewProviderComponent->>User: Redirect to provider page
    else Creation Failed
        CreateNewProviderComponent->>User: Display error message
    end
Loading

Class Diagram: Updated Form Configuration and SDKType

classDiagram
    class NameFormFieldConfig {
        +label: string
        +minWidth: number
        +name: string
        %% Former attribute 'rules: [{ required: true }]' was removed, making the field optional in UI validation %%
    }

    class SdkTypeEnum {
        <<enumeration>>
        OPENAI
        ANTHROPIC
        OLLAMA
        GOOGLE %% New value 'google' added for Gemini %%
    }

    class ProviderCreationPayload {
      +id: string
      +name: string %% Value is 'values.name' or 'values.id' if 'values.name' is empty %%
      +sdkType: SdkTypeEnum
      %% Other provider-specific fields %%
    }
    ProviderCreationPayload *-- SdkTypeEnum : uses
Loading

File-Level Changes

Change Details Files
Fallback to using provider ID when name is empty
  • Merge original values with a name fallback to the id
  • Invoke createNewAiProvider with the merged finalValues
  • Remove the required validation rule on the name field
src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx
Include Gemini in SDK type options
  • Add { label: 'Gemini', value: 'google' } to the SDK type dropdown list
src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#8086 Add a Gemini format option to the custom AI service provider settings.

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

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 15, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@lobehubbot
Copy link
Member

👍 @sxjeru

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link
Contributor

gru-agent bot commented Jun 15, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail e455538 🚫 Skipped No files need to be tested {"src/app/[variants]/(main)/settings/provider/features/CreateNewProvider/index.tsx":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@dosubot dosubot bot added the Gemini label Jun 15, 2025
@sxjeru sxjeru changed the title feat: 允许使用 ID 作为名称,如果名称为空,并添加 Gemini 选项到 SDK 类型 💄 style: Allow Gemini as custom provider Jun 15, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @sxjeru - I've reviewed your changes and they look great!


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.

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.86%. Comparing base (88c4362) to head (f79adce).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8190      +/-   ##
==========================================
- Coverage   95.67%   87.86%   -7.81%     
==========================================
  Files          14      836     +822     
  Lines        2522    62355   +59833     
  Branches      445     3937    +3492     
==========================================
+ Hits         2413    54791   +52378     
- Misses        109     7564    +7455     
Flag Coverage Δ
app 87.86% <100.00%> (?)
server 95.67% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sxjeru sxjeru marked this pull request as draft June 17, 2025 15:54
@sxjeru sxjeru marked this pull request as ready for review June 19, 2025 06:52
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@dosubot dosubot bot added the 💄 Design Design an style | 样式问题 label Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💄 Design Design an style | 样式问题 Gemini size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Request] 请求在自定义ai服务商支持gemini格式
2 participants