Skip to content

修复前端工程依赖冲突 & 新增本地开发docker-compose-dev模式#3311

Closed
zhaieryuan wants to merge 3 commits into
QuantumNous:mainfrom
zhaieryuan:main
Closed

修复前端工程依赖冲突 & 新增本地开发docker-compose-dev模式#3311
zhaieryuan wants to merge 3 commits into
QuantumNous:mainfrom
zhaieryuan:main

Conversation

@zhaieryuan
Copy link
Copy Markdown

@zhaieryuan zhaieryuan commented Mar 18, 2026

1、修复前端工程依赖冲突
2、 新增本地开发docker-compose-dev模式
3、提交一些架构梳理的学习文档

Summary by CodeRabbit

  • Documentation

    • Added comprehensive project documentation covering system architecture, development guidelines, integration instructions, debugging workflows, and local environment setup.
  • Chores

    • Updated frontend dependencies with new UI component libraries for enhanced interface capabilities.
    • Added development Docker configuration with PostgreSQL and Redis services for streamlined local setup.

zhaieryuan added 3 commits March 18, 2026 15:39
问题根源

  1. vite-plugin-semi 插件与 pnpm 的 symlink 结构不兼容,插件内部使用 ~@douyinfe/semi-theme-default/scss/index.scss 路径无法被 pnpm 正确解析
  2. @douyinfe/semi-ui 的 package.json exports 字段没有包含 ./dist/css/semi.css 路径,导致传统 CSS 导入失败
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 18, 2026

Walkthrough

This PR adds comprehensive Chinese documentation for the new-api project (project overview, architecture, development and debugging guides), introduces a Docker Compose development environment with PostgreSQL 17 and Redis 8.0, updates the Vite configuration to use Semi UI's SCSS directly, and adds UI-related frontend dependencies.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md, docs/learn_docs/01-项目概述.md, docs/learn_docs/02-架构详解.md, docs/learn_docs/03-二次开发指南.md, docs/learn_docs/04-本地开发Debug指南.md, docs/learn_docs/README.md
Added comprehensive documentation covering development commands, tech stack, Relay System architecture, project overview, detailed system architecture with Mermaid diagrams, secondary development extension guidelines, local debugging setup, and documentation index with reading routes.
Infrastructure Configuration
docker-compose-dev.yml
New Docker Compose configuration defining isolated development environment with PostgreSQL 17, Redis 8.0, persistent volumes, health checks, and documentation for optional UI components.
Frontend Dependencies
web/package.json
Added five new dependencies: @douyinfe/semi-illustrations, @douyinfe/semi-theme-default, antd, highlight.js, and prop-types for UI theming and syntax highlighting.
Frontend Configuration
web/vite.config.js
Removed vite-plugin-semi integration and added direct Semi UI SCSS theme configuration with alias path resolution and preprocessor options for modern SCSS compilation.
Frontend Entry Point
web/src/index.jsx
Removed global Semi UI CSS import and applied minor formatting adjustments to dependency arrays and JSX structure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • creamlike1024
  • Calcium-Ion

Poem

📚 Fresh docs hop into place with care,
Semi themes and Docker's healthy air,
A bunny's guide to paths unknown,
Architecture tales now widely shown! 🐰✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main changes: fixing frontend dependency conflicts and adding docker-compose-dev mode, matching the core PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use OpenGrep to find security vulnerabilities and bugs across 17+ programming languages.

OpenGrep is compatible with Semgrep configurations. Add an opengrep.yml or semgrep.yml configuration file to your project to enable OpenGrep analysis.

Copy link
Copy Markdown
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: 12

🧹 Nitpick comments (1)
docs/learn_docs/01-项目概述.md (1)

77-77: Polish wording for smoother Chinese expression.

建议将“灵活的计费策略”调整为“灵活地制定计费策略”,语义更顺。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/01-项目概述.md` at line 77, 将文档中标题行 "2. **成本可控** - 灵活的计费策略和限流"
中的短语“灵活的计费策略”替换为更通顺的表述“灵活地制定计费策略”,保持其余文本不变(即最终为 "2. **成本可控** -
灵活地制定计费策略和限流"),以改善中文表达流畅性。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Around line 27-29: The README contains an invalid go test invocation using a
file path ("go test ./relay/channel/api_request_test.go -v"); replace it with a
package-level invocation and an optional test filter — e.g., run the package
(./relay/channel) and add -run with the test name or regex (or use ./... for
recursion) so use "go test ./relay/channel -v -run <TestName>" instead of
specifying the individual test file; update the CLAUDE.md entry to show the
corrected command.

In `@docker-compose-dev.yml`:
- Around line 24-27: The compose file currently sets weak, hardcoded DB creds
(POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB) and leaves Redis unauthenticated
while exposing public host ports; replace these with secure defaults and
reference external environment variables instead (e.g. POSTGRES_PASSWORD,
POSTGRES_USER, POSTGRES_DB loaded from a .env or CI secrets) and avoid
hardcoding "123456"; enable a REDIS_PASSWORD/requirepass and read it from env
rather than empty literal; and stop binding sensitive services to all interfaces
by removing public host port bindings or bind them to localhost (127.0.0.1) for
development to prevent accidental public exposure.
- Around line 25-35: The healthcheck uses pg_isready -U newapi but the container
sets POSTGRES_USER: root, causing failed readiness checks; update the
healthcheck command (the test value that runs pg_isready -U ...) to use the
actual POSTGRES_USER (root) or change POSTGRES_USER to match the healthcheck
(newapi) so they match; ensure the username passed to pg_isready and the
POSTGRES_USER/POSTGRES_DB values (POSTGRES_USER, POSTGRES_DB, and the
healthcheck test) are consistent.

In `@docs/learn_docs/02-架构详解.md`:
- Around line 109-113: The sequence diagram uses duplicate participant ID "R"
(lines showing participant R as Router and participant R as Relay) which breaks
Mermaid rendering; update the participant declarations so each has a unique ID
(e.g., use different IDs like Router (Rtr) and Relay (Rly) or similar) and
ensure all references in the diagram that use the old "R" ID are updated to the
new IDs; check other duplicates noted (lines 129-137) and apply the same fix to
participant M, Ctrl, S, Relay entries so every participant ID is unique.

In `@docs/learn_docs/03-二次开发指南.md`:
- Around line 111-133: The sample adaptor has type and API-use errors: in
ConvertOpenAIRequest adjust MyProviderRequest.Prompt to accept the same type as
dto.GeneralOpenAIRequest.Messages (e.g., []dto.Message or serialize messages to
string) and assign request.Messages correctly (refer to MyProviderRequest and
request.Messages); in DoResponse stop using c.ShouldBindJSON and instead read
and decode the upstream response body (use io.ReadAll(resp.Body) or
json.NewDecoder(resp.Body).Decode(&myResp)) to populate MyProviderResponse and
extract Usage; replace the ambiguous common.ErrorWrapper usage with explicit
error creation/return or import/mention the correct error helper so DoResponse
returns proper (*types.NewAPIError) or nil on success (refer to DoResponse,
MyProviderResponse, and common.ErrorWrapper).
- Around line 622-625: The snippet uses hardcoded English strings instead of
i18n and the zh.json entries are incorrect; update the JSX in the shown Form
example (the <h1>, <Input label="Name"> and <Button onClick={handleSubmit}>) to
call t('…') with Chinese keys (e.g., t('我的功能'), t('姓名'), t('提交')), and fix the
zh.json example so its keys are Chinese source strings with Chinese values
(e.g., "我的功能": "我的功能", "提交": "提交"); optionally add a corresponding en.json
showing those same Chinese keys mapped to English values to clarify the pattern.

In `@docs/learn_docs/04-本地开发Debug指南.md`:
- Around line 62-63: Replace the hardcoded absolute path used in the docs (e.g.,
the `cd /Users/zhai/my_project/go_lang_workspaces/new-api` example) with a
portable placeholder such as `<project_root>` or `$PROJECT_ROOT` and instruct
users to `cd` into their local project directory (or use a relative path like
`./`) before running `docker-compose -f docker-compose-dev.yml up -d`; update
all occurrences of the absolute path (the repeated `cd` lines at the other noted
locations) to use the same placeholder and add a brief note telling readers to
substitute their own path.
- Around line 68-73: The Markdown table header (| 服务 | 说明 | 端口 | 用途 |) has four
columns but the rows for **postgres**, **redis**, **redis-commander**, and
**pgadmin4** only supply three cells each (e.g., the row starting with
"**postgres**" lists name, port, and description), causing malformed tables;
update each row to provide four pipe-separated cells matching the header
(Service name, a brief 说明, the 端口 value, and the 用途) for the rows containing
**postgres**, **redis**, **redis-commander**, and **pgadmin4**, and apply the
same fix to the similar table at the later block referenced (the rows around
125-129).
- Around line 620-623: The wrk invocation uses an invalid flag `-t4s`; update
the `wrk` command (the line starting with "wrk -t4s -c10
http://localhost:3000/v1/models") to use the correct flag separation by
specifying threads and duration separately (e.g., replace `-t4s` with `-t4 -d4s`
or `-t4 -d <duration>`), so the command becomes `wrk -t4 -c10 -d4s
http://localhost:3000/v1/models` (ensure the thread flag `-t` and duration flag
`-d` are used correctly).

In `@docs/learn_docs/README.md`:
- Around line 203-205: The release dates in the version-history table entries
for versions 1.0.0, 1.1.0, and 1.1.1 are incorrect (currently "2025-03-18");
update those three date strings to the PR creation date "2026-03-18" in
README.md so the rows for 1.0.0, 1.1.0, and 1.1.1 reflect the correct timeline.

In `@web/src/index.jsx`:
- Around line 48-49: The locale lookup uses exact keys and fails for regional
variants like "zh-CN" or "en-US"; update the mapping logic around i18n.language
so it matches prefixes instead of exact values (e.g., check
i18n.language.startsWith('zh') to select zh_CN and .startsWith('en') to select
en_GB) while preserving the existing fallback to zh_CN; modify the anonymous
selector function that currently returns ({ zh: zh_CN, en: en_GB
})[i18n.language] || zh_CN to perform prefix checks against i18n.language and
return the appropriate locale object (zh_CN or en_GB).

In `@web/vite.config.js`:
- Around line 36-37: Replace the invalid Sass directive and the unsupported
compiler API: change additionalData to use the `@use` form (e.g., use
"@douyinfe/semi-theme-default/scss/variables.scss" with an "as *" clause)
instead of `@import` ... as *, and remove or replace api: 'modern-compiler' with
the legacy/dart option supported by Vite 5.2.0 (or simply omit the api field);
alternatively upgrade to Vite 5.4.0+ and add the sass-embedded package if you
want to keep api: 'modern-compiler'. Ensure you update the entries that
reference api and additionalData in the vite config.

---

Nitpick comments:
In `@docs/learn_docs/01-项目概述.md`:
- Line 77: 将文档中标题行 "2. **成本可控** - 灵活的计费策略和限流"
中的短语“灵活的计费策略”替换为更通顺的表述“灵活地制定计费策略”,保持其余文本不变(即最终为 "2. **成本可控** -
灵活地制定计费策略和限流"),以改善中文表达流畅性。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e9a97f4c-41a9-4f13-8216-7187b1e8cba9

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed2ea6 and c6be507.

📒 Files selected for processing (10)
  • CLAUDE.md
  • docker-compose-dev.yml
  • docs/learn_docs/01-项目概述.md
  • docs/learn_docs/02-架构详解.md
  • docs/learn_docs/03-二次开发指南.md
  • docs/learn_docs/04-本地开发Debug指南.md
  • docs/learn_docs/README.md
  • web/package.json
  • web/src/index.jsx
  • web/vite.config.js

Comment thread CLAUDE.md
Comment on lines +27 to +29
# Run specific test file
go test ./relay/channel/api_request_test.go -v
```
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.

⚠️ Potential issue | 🟠 Major

Fix invalid go test invocation for a single file.

Line 28 uses a file path as the package argument, which is not a valid go test package pattern. Use a package target plus -run filter instead.

🧪 Proposed fix
-# Run specific test file
-go test ./relay/channel/api_request_test.go -v
+# Run tests in specific package (optionally add -run <TestName>)
+go test ./relay/channel -v
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Run specific test file
go test ./relay/channel/api_request_test.go -v
```
# Run tests in specific package (optionally add -run <TestName>)
go test ./relay/channel -v
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 27 - 29, The README contains an invalid go test
invocation using a file path ("go test ./relay/channel/api_request_test.go -v");
replace it with a package-level invocation and an optional test filter — e.g.,
run the package (./relay/channel) and add -run with the test name or regex (or
use ./... for recursion) so use "go test ./relay/channel -v -run <TestName>"
instead of specifying the individual test file; update the CLAUDE.md entry to
show the corrected command.

Comment thread docker-compose-dev.yml
Comment on lines +24 to +27
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: 123456
POSTGRES_DB: new-api
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.

⚠️ Potential issue | 🟠 Major

Avoid weak/default credentials in the shared dev compose file.

Line 26 uses a trivial DB password and Line 46 allows empty Redis password while binding public host ports. This is easy to misuse outside isolated local environments.

🔐 Proposed hardening for local defaults
     environment:
       POSTGRES_USER: root
-      POSTGRES_PASSWORD: 123456
+      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?set in .env}
       POSTGRES_DB: new-api
       POSTGRES_INITDB_ARGS: "-E UTF8"
       TZ: Asia/Shanghai
@@
     environment:
-      - ALLOW_EMPTY_PASSWORD=yes
+      - ALLOW_EMPTY_PASSWORD=no
+      - REDIS_PASSWORD=${REDIS_PASSWORD:?set in .env}

Also applies to: 45-48

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker-compose-dev.yml` around lines 24 - 27, The compose file currently sets
weak, hardcoded DB creds (POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB) and
leaves Redis unauthenticated while exposing public host ports; replace these
with secure defaults and reference external environment variables instead (e.g.
POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DB loaded from a .env or CI secrets)
and avoid hardcoding "123456"; enable a REDIS_PASSWORD/requirepass and read it
from env rather than empty literal; and stop binding sensitive services to all
interfaces by removing public host port bindings or bind them to localhost
(127.0.0.1) for development to prevent accidental public exposure.

Comment thread docker-compose-dev.yml
Comment on lines +25 to +35
POSTGRES_USER: root
POSTGRES_PASSWORD: 123456
POSTGRES_DB: new-api
POSTGRES_INITDB_ARGS: "-E UTF8"
TZ: Asia/Shanghai
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U newapi"]
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.

⚠️ Potential issue | 🔴 Critical

Fix PostgreSQL healthcheck credential mismatch.

Line 35 checks pg_isready -U newapi, but Line 25 sets POSTGRES_USER: root. This will keep the container unhealthy.

🐛 Proposed fix
     healthcheck:
-      test: ["CMD-SHELL", "pg_isready -U newapi"]
+      test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
       interval: 5s
       timeout: 5s
       retries: 5
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
POSTGRES_USER: root
POSTGRES_PASSWORD: 123456
POSTGRES_DB: new-api
POSTGRES_INITDB_ARGS: "-E UTF8"
TZ: Asia/Shanghai
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U newapi"]
POSTGRES_USER: root
POSTGRES_PASSWORD: 123456
POSTGRES_DB: new-api
POSTGRES_INITDB_ARGS: "-E UTF8"
TZ: Asia/Shanghai
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker-compose-dev.yml` around lines 25 - 35, The healthcheck uses pg_isready
-U newapi but the container sets POSTGRES_USER: root, causing failed readiness
checks; update the healthcheck command (the test value that runs pg_isready -U
...) to use the actual POSTGRES_USER (root) or change POSTGRES_USER to match the
healthcheck (newapi) so they match; ensure the username passed to pg_isready and
the POSTGRES_USER/POSTGRES_DB values (POSTGRES_USER, POSTGRES_DB, and the
healthcheck test) are consistent.

Comment on lines +109 to +113
participant R as Router
participant M as Middleware
participant Ctrl as Controller
participant S as Service
participant R as Relay
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.

⚠️ Potential issue | 🟠 Major

Use unique Mermaid participant IDs in the sequence diagram.

Line 109 and Line 113 both use participant ID R. Mermaid sequence participants must have unique IDs; this can break rendering.

🧩 Proposed fix
-    participant R as Router
+    participant Router as Router
@@
-    participant R as Relay
+    participant Relay as Relay
@@
-    C->>R: POST /v1/chat/completions
-    R->>M: CORS 检查
+    C->>Router: POST /v1/chat/completions
+    Router->>M: CORS 检查
@@
-    S->>R: RelayHelper(c, info)
-    R->>R: 格式转换
-    R->>R: 请求构建
-    R->>P: HTTP 请求
-    P-->>R: 响应
-    R->>R: 响应转换
-    R->>S: Token 计数
-    R-->>C: 响应数据
+    S->>Relay: RelayHelper(c, info)
+    Relay->>Relay: 格式转换
+    Relay->>Relay: 请求构建
+    Relay->>P: HTTP 请求
+    P-->>Relay: 响应
+    Relay->>Relay: 响应转换
+    Relay->>S: Token 计数
+    Relay-->>C: 响应数据

Also applies to: 129-137

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/02-架构详解.md` around lines 109 - 113, The sequence diagram uses
duplicate participant ID "R" (lines showing participant R as Router and
participant R as Relay) which breaks Mermaid rendering; update the participant
declarations so each has a unique ID (e.g., use different IDs like Router (Rtr)
and Relay (Rly) or similar) and ensure all references in the diagram that use
the old "R" ID are updated to the new IDs; check other duplicates noted (lines
129-137) and apply the same fix to participant M, Ctrl, S, Relay entries so
every participant ID is unique.

Comment on lines +111 to +133
func (a *Adaptor) ConvertOpenAIRequest(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest) (any, error) {
// 将 OpenAI 格式转换为本提供商格式
myRequest := MyProviderRequest{
Model: info.UpstreamModelName,
Prompt: request.Messages, // 简化示例
Stream: info.IsStream,
}
return myRequest, nil
}

func (a *Adaptor) DoRequest(c *gin.Context, info *relaycommon.RelayInfo, requestBody io.Reader) (any, error) {
return channel.DoApiRequest(a, c, info, requestBody)
}

func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, info *relaycommon.RelayInfo) (usage any, err *types.NewAPIError) {
// 处理响应、提取使用信息
var myResp MyProviderResponse
if err := c.ShouldBindJSON(&myResp); err != nil {
return nil, common.ErrorWrapper(err)
}
// 返回使用量供计费
return myResp.Usage, nil
}
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify real project patterns for adaptor contracts and response decoding.
# Expected: existing adaptors should show safe parsing/error-handling conventions.
rg -n "type GeneralOpenAIRequest struct|Messages" dto --type go -C3
rg -n "func \\(.*\\) DoResponse\\(.*\\)" relay/channel --type go -C2
rg -n "ShouldBindJSON\\(|json\\.NewDecoder\\(resp\\.Body\\)|io\\.ReadAll\\(resp\\.Body\\)" relay/channel --type go -C2
rg -n "ErrorWrapper\\(" relay --type go -C2

Repository: QuantumNous/new-api

Length of output: 50375


Documentation example contains type mismatches and incorrect API patterns that will mislead developers implementing custom adaptors.

The adaptor code sample at this location has several issues:

  • Line 115: Prompt is typed as string, but request.Messages is []Message (from dto.GeneralOpenAIRequest). Assignment will fail to compile.
  • Line 128: The response handling uses c.ShouldBindJSON(&myResp), which reads from the request context, not the upstream response. Actual implementations in the codebase consistently use io.ReadAll(resp.Body) followed by json.Unmarshal or json.NewDecoder to parse the provider's response.
  • Line 129: common.ErrorWrapper is referenced without showing the required import or context, making the example incomplete.

Rewrite the example to show the actual production patterns: correct field types, proper response body parsing, and explicit error handling. This prevents developers from copying broken code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/03-二次开发指南.md` around lines 111 - 133, The sample adaptor has
type and API-use errors: in ConvertOpenAIRequest adjust MyProviderRequest.Prompt
to accept the same type as dto.GeneralOpenAIRequest.Messages (e.g.,
[]dto.Message or serialize messages to string) and assign request.Messages
correctly (refer to MyProviderRequest and request.Messages); in DoResponse stop
using c.ShouldBindJSON and instead read and decode the upstream response body
(use io.ReadAll(resp.Body) or json.NewDecoder(resp.Body).Decode(&myResp)) to
populate MyProviderResponse and extract Usage; replace the ambiguous
common.ErrorWrapper usage with explicit error creation/return or import/mention
the correct error helper so DoResponse returns proper (*types.NewAPIError) or
nil on success (refer to DoResponse, MyProviderResponse, and
common.ErrorWrapper).

Comment on lines +68 to +73
| 服务 | 说明 | 端口 | 用途 |
|-------|------|-------|-------|
| **postgres** | 5432 | PostgreSQL 数据库 |
| **redis** | 6379 | Redis 缓存 |
| **redis-commander** | 8081 | Redis 可视化管理(可选)|
| **pgadmin4** | 5050 | PostgreSQL 可视化管理(可选)|
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.

⚠️ Potential issue | 🟡 Minor

Fix malformed Markdown tables.

The row column counts don’t match their headers, so these tables won’t render correctly.

Also applies to: 125-129

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/04-本地开发Debug指南.md` around lines 68 - 73, The Markdown table
header (| 服务 | 说明 | 端口 | 用途 |) has four columns but the rows for **postgres**,
**redis**, **redis-commander**, and **pgadmin4** only supply three cells each
(e.g., the row starting with "**postgres**" lists name, port, and description),
causing malformed tables; update each row to provide four pipe-separated cells
matching the header (Service name, a brief 说明, the 端口 value, and the 用途) for the
rows containing **postgres**, **redis**, **redis-commander**, and **pgadmin4**,
and apply the same fix to the similar table at the later block referenced (the
rows around 125-129).

Comment on lines +620 to +623
wrk -t4s -c10 http://localhost:3000/v1/models

# 使用 ab (Apache Benchark)
ab -n 1000 -c 10 http://localhost:3000/api/status
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.

⚠️ Potential issue | 🟠 Major

Correct invalid wrk command syntax.

Line 620 uses -t4s, which is not a valid wrk flag format.

⚙️ Proposed fix
-# 使用 wrk 进行并发测试
-wrk -t4s -c10 http://localhost:3000/v1/models
+# 使用 wrk 进行并发测试(示例:4 线程,10 连接,30 秒)
+wrk -t4 -c10 -d30s http://localhost:3000/v1/models
 
-# 使用 ab (Apache Benchark)
+# 使用 ab (Apache Benchmark)
 ab -n 1000 -c 10 http://localhost:3000/api/status
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/04-本地开发Debug指南.md` around lines 620 - 623, The wrk invocation
uses an invalid flag `-t4s`; update the `wrk` command (the line starting with
"wrk -t4s -c10 http://localhost:3000/v1/models") to use the correct flag
separation by specifying threads and duration separately (e.g., replace `-t4s`
with `-t4 -d4s` or `-t4 -d <duration>`), so the command becomes `wrk -t4 -c10
-d4s http://localhost:3000/v1/models` (ensure the thread flag `-t` and duration
flag `-d` are used correctly).

Comment thread docs/learn_docs/README.md
Comment on lines +203 to +205
| 1.0.0 | 2025-03-18 | 初始版本,包含项目概述、架构详解、二次开发指南 |
| 1.1.0 | 2025-03-18 | 新增本地开发Debug指南 |
| 1.1.1 | 2025-03-18 | 优化 docker-compose-dev.yml 配置 |
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.

⚠️ Potential issue | 🟡 Minor

Update version-history dates to match this PR timeline.

Line 203–205 currently use 2025-03-18, but this PR was created on 2026-03-18. Please correct the release dates to avoid historical confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/learn_docs/README.md` around lines 203 - 205, The release dates in the
version-history table entries for versions 1.0.0, 1.1.0, and 1.1.1 are incorrect
(currently "2025-03-18"); update those three date strings to the PR creation
date "2026-03-18" in README.md so the rows for 1.0.0, 1.1.0, and 1.1.1 reflect
the correct timeline.

Comment thread web/src/index.jsx
Comment on lines +48 to +49
() => ({ zh: zh_CN, en: en_GB })[i18n.language] || zh_CN,
[i18n.language],
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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify how i18next language codes are configured/resolved in this repo.
# Expected: either normalized 'zh'/'en' codes OR handling for regional variants.
rg -n "supportedLngs|fallbackLng|nonExplicitSupportedLngs|load:|cleanCode|lowerCaseLng|resolvedLanguage|changeLanguage\\(" web/src --type js --type jsx --type ts --type tsx

Repository: QuantumNous/new-api

Length of output: 90


🏁 Script executed:

#!/bin/bash
# Verify how i18next language codes are configured/resolved
# Correct file types for rg: use -t ts -t js (not jsx/tsx as separate types)
rg -n "supportedLngs|fallbackLng|nonExplicitSupportedLngs|cleanCode|lowerCaseLng|resolvedLanguage|changeLanguage" web/src -t ts -t js

Repository: QuantumNous/new-api

Length of output: 1041


🏁 Script executed:

cat -n web/src/index.jsx | sed -n '40,60p'

Repository: QuantumNous/new-api

Length of output: 773


🏁 Script executed:

fd -type f -name "*i18n*" web/src | head -20

Repository: QuantumNous/new-api

Length of output: 233


🏁 Script executed:

cat -n web/src/i18n/i18n.js

Repository: QuantumNous/new-api

Length of output: 2191


🏁 Script executed:

rg -n "supportedLanguages" web/src -t ts -t js -A 3 -B 3

Repository: QuantumNous/new-api

Length of output: 1477


🏁 Script executed:

cat -n web/src/i18n/language.js

Repository: QuantumNous/new-api

Length of output: 1979


🏁 Script executed:

rg -n "from '@semi-design/semi-ui/locale'" web/src -t ts -t js -A 2

Repository: QuantumNous/new-api

Length of output: 45


🏁 Script executed:

rg -n "i18n.language|changeLanguage|i18n.language" web/src/context -t ts -t js -B 3 -A 3

Repository: QuantumNous/new-api

Length of output: 1223


🏁 Script executed:

rg -n "import.*zh_CN|import.*en_GB" web/src -t ts -t js -B 2 -A 2

Repository: QuantumNous/new-api

Length of output: 446


🏁 Script executed:

rg -n "zh_CN|en_GB|zh_TW" web/src -t ts -t js

Repository: QuantumNous/new-api

Length of output: 321


Handle regional language variants in Semi UI locale mapping.

The mapping at line 48 uses exact keys 'zh' and 'en', but i18next normalizes detected language to values like 'zh-CN', 'zh-TW', and 'en' based on supportedLngs. When i18n.language is 'zh-CN' or 'zh-TW', the lookup returns undefined and falls back to zh_CN—which happens to work for 'zh-CN' but is fragile. For consistency and to handle regional variants (e.g., 'en-US'), use language prefix matching:

Suggested fix
  const semiLocale = React.useMemo(() => {
-   () => ({ zh: zh_CN, en: en_GB })[i18n.language] || zh_CN,
-   [i18n.language],
+   const lang = (i18n.language || 'zh').toLowerCase().split('-')[0];
+   return lang === 'en' ? en_GB : zh_CN;
+ }, [i18n.language]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/index.jsx` around lines 48 - 49, The locale lookup uses exact keys
and fails for regional variants like "zh-CN" or "en-US"; update the mapping
logic around i18n.language so it matches prefixes instead of exact values (e.g.,
check i18n.language.startsWith('zh') to select zh_CN and .startsWith('en') to
select en_GB) while preserving the existing fallback to zh_CN; modify the
anonymous selector function that currently returns ({ zh: zh_CN, en: en_GB
})[i18n.language] || zh_CN to perform prefix checks against i18n.language and
return the appropriate locale object (zh_CN or en_GB).

Comment thread web/vite.config.js
Comment on lines +36 to +37
api: 'modern-compiler',
additionalData: `@import "@douyinfe/semi-theme-default/scss/variables.scss" as *;`,
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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

In Dart Sass syntax, is @import "path" as *; valid? If not, what is the correct directive for namespace flattening (@use ... as *)?

💡 Result:

No, @import "path" as *; is not valid syntax in Dart Sass. The @import rule does not support an as clause for namespacing or flattening. It loads stylesheets into the global namespace without namespacing. The correct directive for namespace flattening is @use "path" as *;. This loads the module's members (variables, mixins, functions) directly into the current file's namespace without requiring a prefix, while still providing module system benefits like avoiding global pollution and duplicate loading. Official documentation recommends this only for trusted stylesheets (e.g., your own) to avoid name conflicts.

Citations:


🌐 Web query:

With Vite 5.2.0, is css.preprocessorOptions.scss.api = "modern-compiler" supported, and what Sass version is required?

💡 Result:

No, css.preprocessorOptions.scss.api = "modern-compiler" is not supported in Vite 5.2.0. This option was added in Vite 5.4.0 via PRs #17728 (modern API) and #17754 (modern-compiler and sass-embedded support), targeted for milestone 5.4. Vite 5.2.0 predates this feature. For the modern-compiler API, sass-embedded is required (not the standard sass package), as it provides the native Dart executable for better performance with the Compiler API (initAsyncCompiler). Vite lists sass-embedded ^1.70.0 as an optional peer dependency. The standard sass package supports "modern" (compileStringAsync) but not "modern-compiler".

Citations:


🏁 Script executed:

cat web/package.json | grep -A 2 -B 2 '"vite"'

Repository: QuantumNous/new-api

Length of output: 259


Fix invalid Sass directive and incompatible preprocessor API for Vite 5.2.0.

Line 37 uses @import ... as *;, which is invalid Sass syntax. The as clause is only valid with @use, not @import. Additionally, line 36 specifies api: 'modern-compiler', which requires Vite 5.4.0+ and sass-embedded package; your project uses Vite 5.2.0 where this API is not supported.

🎨 Proposed fix
       scss: {
-        api: 'modern-compiler',
-        additionalData: `@import "@douyinfe/semi-theme-default/scss/variables.scss" as *;`,
+        additionalData: `@use "@douyinfe/semi-theme-default/scss/variables.scss" as *;`,
       },

Alternatively, upgrade Vite to 5.4.0+ and add sass-embedded for modern-compiler support.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/vite.config.js` around lines 36 - 37, Replace the invalid Sass directive
and the unsupported compiler API: change additionalData to use the `@use` form
(e.g., use "@douyinfe/semi-theme-default/scss/variables.scss" with an "as *"
clause) instead of `@import` ... as *, and remove or replace api:
'modern-compiler' with the legacy/dart option supported by Vite 5.2.0 (or simply
omit the api field); alternatively upgrade to Vite 5.4.0+ and add the
sass-embedded package if you want to keep api: 'modern-compiler'. Ensure you
update the entries that reference api and additionalData in the vite config.

@seefs001
Copy link
Copy Markdown
Collaborator

不考虑合并此类PR

@seefs001 seefs001 closed this Mar 18, 2026
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