Skip to content

feat: init models management#330

Merged
looplj merged 1 commit into
unstablefrom
development
Dec 21, 2025
Merged

feat: init models management#330
looplj merged 1 commit into
unstablefrom
development

Conversation

@looplj

@looplj looplj commented Dec 21, 2025

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @looplj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a brand new, full-fledged AI model management system. It provides a dedicated section in the application's frontend where users can define and configure various AI models, detailing their capabilities, costs, and usage limits. The system also allows for flexible association of these models with existing channels, supporting different matching strategies including regular expressions. This feature is backed by a new GraphQL API and database schema, ensuring robust and scalable model configuration.

Highlights

  • New Model Management Feature: Introduced a comprehensive AI model management system, allowing users to create, edit, delete, and configure AI models through a dedicated interface.
  • Backend API and Database Schema: Implemented a new Model entity in the backend using the ent framework, complete with its own GraphQL schema, resolvers, and CRUD operations. This includes fields for developer, model ID, type, name, icon, group, model card details, settings, status, and remarks.
  • Frontend UI Components: Developed new React components for the model management UI, including a data table with sorting, filtering, and pagination, as well as dialogs for creating, editing, deleting, changing status, and managing model-channel associations.
  • Model-Channel Association Logic: Added functionality to associate models with channels using various rules (channel-model, channel-regex, global regex), with a real-time preview of affected channels.
  • Dependency Updates and Utilities: Updated the @lobehub/icons dependency to version ^3.0.0 and enhanced AutoCompleteSelect and AutoComplete components with a portalContainer prop to resolve scrolling issues within dialogs. A new utility function extractNumberIDAsNumber was also added.
  • Internationalization and Testing: Included new translation files for the model management feature in both English and Chinese, and added Playwright E2E tests to ensure the functionality of model CRUD operations, filtering, status toggling, and deletion.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a comprehensive feature for managing AI models. The changes include a new 'Models' page in the frontend with a data table, create/edit/delete/association dialogs, and the necessary context and data fetching logic. On the backend, a new Model entity is added to the database schema, along with business logic and GraphQL APIs to support the frontend functionality. The overall implementation is well-structured and follows modern development practices. I've identified a few areas for improvement, mainly concerning type safety in the frontend, removal of some unused code, and a potential issue with permission scopes in the backend privacy policy that should be reviewed for correctness.

const fetchConnections = async () => {
try {
const associations: ModelAssociationInput[] = debouncedAssociations
.filter((assoc: any) => {

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.

high

The assoc parameter is typed as any. This should be avoided. You can use a more specific type, for example AssociationFormData['associations'][number], to maintain type safety. This also applies to the .map call on line 180.

Comment on lines +69 to +76
scopes.APIKeyScopeQueryRule(scopes.ScopeReadChannels),
scopes.OwnerRule(), // owner 用户可以访问所有渠道
scopes.UserReadScopeRule(scopes.ScopeReadChannels), // 需要 Models 读取权限
},
Mutation: scopes.MutationPolicy{
scopes.OwnerRule(), // owner 用户可以修改所有渠道
scopes.UserWriteScopeRule(scopes.ScopeWriteChannels), // 需要 Models 写入权限
},

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.

high

The privacy policy for the Model entity seems to be using permission scopes related to channels (scopes.ScopeReadChannels, scopes.ScopeWriteChannels). The comments in Chinese suggest that model-specific permissions were intended ("需要 Models 读取权限" means "needs Models read permission"). This could lead to incorrect authorization logic where users with channel permissions can manage models, which might not be the desired behavior. Please verify if this is intentional or if model-specific scopes should be created and used.

Comment on lines +31 to +33
function isDeveloperIcon(icon: string) {
return Object.values(DEVELOPER_ICONS).includes(icon)
}

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.

medium

The function isDeveloperIcon is defined but never used. It should be removed to clean up the code and improve maintainability.

const [developerSearchValue, setDeveloperSearchValue] = useState<string>('')
const [modelIdInput, setModelIdInput] = useState<string>('')
const [modelIdSearchValue, setModelIdSearchValue] = useState<string>('')
const [_selectedModelCard, setSelectedModelCard] = useState<ModelCard>({})

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.

medium

The state variable _selectedModelCard is declared and its setter setSelectedModelCard is used, but the value _selectedModelCard itself is never read. If it's not needed, it should be removed to avoid confusion and dead code.

const iconOptions = useMemo(() => {
return (
Object.entries(toc)
// @ts-ignore

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.

medium

The use of @ts-ignore here and in other places (e.g., models-columns.tsx) to handle types from @lobehub/icons should be avoided. It seems the type of toc is not specific enough. Please consider adding a local type definition for the icon objects or using a type assertion like as { group: string; id: string } to ensure type safety and improve code quality.

Comment on lines +658 to +662
const formatTokens = (num?: number) => {
if (!num) return ''
if (num >= 1000) return `${(num / 1000).toFixed(0)}K`
return num.toString()
}

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.

medium

The formatTokens helper function is duplicated in this component (here and around line 689). It would be better to define it once at the component level to avoid code duplication and re-creation on every render.

return (
<div className='flex items-center justify-center'>
{IconComponent ? (
//@ts-ignore

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.

medium

The use of @ts-ignore here indicates a potential typing issue with the IconComponent. This should be avoided to ensure type safety. Please consider providing proper types for the icons from @lobehub/icons or using a type assertion if the type is known.

@@ -0,0 +1,29 @@
import { record } from 'zod'

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.

medium

The import import { record } from 'zod' is not used in this file and should be removed.

@looplj looplj merged commit 06bd01b into unstable Dec 21, 2025
2 checks passed
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