feat(ai): add per-list keywords to guide AI classification - #3
Conversation
Closes GEMILUXVII#2 - Add `keywords` field to List model (comma-separated, optional) - Provide each list's keywords to the AI in classify prompts (zh/en) and instruct the model to prioritize user-defined keyword matches - Support keywords in lists APIs, stats, export and import - Add keywords input to create/edit list dialogs (i18n zh/en)
Reviewer's GuideAdds an optional per-List keywords field end to end: persisted and validated through APIs and backups, displayed and prioritized in bilingual AI classification prompts, and editable through localized create/edit List dialogs with propagation across the sidebar and Stars page. Sequence diagram for keyword-guided AI classificationsequenceDiagram
participant Client
participant ClassifyAPI
participant Database
participant AIProvider
Client->>ClassifyAPI: POST /api/ai/classify
ClassifyAPI->>Database: findMany Lists with keywords
Database-->>ClassifyAPI: List records
ClassifyAPI->>ClassifyAPI: split keywords by comma, ideographic comma, delimiter, or newline
ClassifyAPI->>AIProvider: buildPromptZh or buildPromptEn with listInfos
AIProvider-->>ClassifyAPI: classification using keyword precedence
ClassifyAPI-->>Client: classification result
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
用ai造的,我自己试用一段时间 |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/create-list-dialog.tsx" line_range="74-79" />
<code_context>
<div className="grid gap-2">
- <Label htmlFor="name">名称</Label>
+ <Label htmlFor="name">{t("name")}</Label>
<Input
id="name"
value={name}
onChange={(e) => setName(e.target.value)}
- placeholder="例如:前端工具"
+ placeholder={t("namePlaceholder")}
autoFocus
/>
</div>
<div className="grid gap-2">
</code_context>
<issue_to_address>
**issue (bug_risk):** The keyword inputs have no client-side 200-character limit, so entering more than 200 characters causes the create or update API to return 400; the corresponding handlers ignore `response.ok`, still refresh/close the dialog, and present the failed save as successful.
**Triggers:** When a user enters more than 200 characters in the keyword field.
**Suggested fix:** Add `maxLength={200}` to both inputs and check the fetch response before closing the dialog or refreshing state.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and the new keywords are persisted and fed into AI prompts, so incorrect values or precedence rules can cause repositories to be assigned to the wrong lists. Reverting stops the behavior but does not automatically undo existing classifications; those assignments are bounded and can be corrected or re-run.
Blocking findings: src/components/create-list-dialog.tsx:79
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| <Input | ||
| id="keywords" | ||
| value={keywords} | ||
| onChange={(e) => setKeywords(e.target.value)} | ||
| placeholder={t("keywordsPlaceholder")} | ||
| /> |
There was a problem hiding this comment.
issue (bug_risk): The keyword inputs have no client-side 200-character limit, so entering more than 200 characters causes the create or update API to return 400; the corresponding handlers ignore response.ok, still refresh/close the dialog, and present the failed save as successful.
Triggers: When a user enters more than 200 characters in the keyword field.
Suggested fix: Add maxLength={200} to both inputs and check the fetch response before closing the dialog or refreshing state.
68c8f60 to
c5656a9
Compare
Closes #2
功能说明
在新建/编辑 List 时可填写「AI 分类关键词(可选)」,例如给
magiskList 填lsposed, magisk, root。分类时这些关键词会提供给 AI,并明确要求优先按用户关键词匹配——自定义关键词比内置通用映射更可信。适用范围:网页端单个 AI 分类、一键整理、浏览器扩展(扩展走同一个
/api/ai/classify接口,自动生效)。改动
List模型新增keywords字段(逗号分隔字符串,默认空)。项目无 migrations 目录,部署时需同步 schema(npx prisma db push)/api/lists(GET/POST)、/api/lists/[listId](GET/PATCH)、/api/stats支持并返回 keywords(上限 200 字符,空字符串即清空);/api/export、/api/import备份/恢复包含 keywordslist.*i18n 键并补全新键(zh/en);sidebar 与 stars 页面类型/回调透传验证
prisma generate+tsc --noEmit通过next build成功Summary by Sourcery
Add user-configurable List keywords to improve AI classification and preserve them across the application’s List management and backup flows.
New Features:
Enhancements:
Build: