Skip to content

feat: add ETOS LLM Studio quick import support - #5729

Open
Eric-Terminal wants to merge 1 commit into
QuantumNous:mainfrom
Eric-Terminal:feat/etos-llm-studio-chat-import
Open

feat: add ETOS LLM Studio quick import support#5729
Eric-Terminal wants to merge 1 commit into
QuantumNous:mainfrom
Eric-Terminal:feat/etos-llm-studio-chat-import

Conversation

@Eric-Terminal

@Eric-Terminal Eric-Terminal commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 本 PR 描述已整理为简洁摘要,没有直接粘贴未经整理的 AI 输出。
  • AI-assisted: this change was prepared with AI assistance under the Eric-Terminal account.

📝 变更描述 / Description

新增 ETOS LLM Studio 的聊天快捷导入入口,让管理员在 /console/setting?tab=chats 可以使用内置模板添加:

etosllmstudio://provider/install?v=1&data={etosConfig}

前端打开该模板时会把 {etosConfig} 替换为 Base64 JSON,内容与 Cherry Studio / DeepChat 的导入格式保持一致,包含 id: new-apibaseUrlapiKey。classic 前端同步加入模板,并在侧边栏过滤 etosllmstudio 外部 scheme,避免它被当成内嵌聊天页面展示。

同时将 setting/chat.go 中的 JSON 编解码切换到项目统一的 common.Marshal / common.Unmarshal 包装函数。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

重复提交搜索:

gh pr list --repo QuantumNous/new-api --search "ETOS OR etosllmstudio" --state all --limit 20
gh issue list --repo QuantumNous/new-api --search "ETOS OR etosllmstudio" --state all --limit 20
# 均无结果

本地检查:

git diff --check origin/main..HEAD
# passed
go test ./common ./controller ./middleware ./model ./relay/channel ./relay/channel/advancedcustom ./relay/channel/aws ./relay/channel/claude ./relay/channel/gemini ./relay/channel/minimax ./relay/channel/moonshot ./relay/channel/openai ./relay/common ./relay/helper ./service ./setting/config ./setting/model_setting ./setting/operation_setting
# passed

说明:当前本地环境没有 bun,且前端依赖未安装,因此未运行 frontend build。

Summary by CodeRabbit

  • New Features

    • Added support for the new ETOS LLM Studio chat provider/template.
    • Chat links can now generate the required configuration automatically for this provider.
  • Bug Fixes

    • The sidebar now correctly hides ETOS LLM Studio links from the chat list where applicable.
    • Improved handling of chat link setup so ETOS LLM Studio connections work consistently.

改动文件:setting/chat.go、default chat-links、classic token/settings/sidebar 相关文件。

目的:在 /console/setting?tab=chats 内置 ETOS LLM Studio 导入模板,并让令牌页能生成 etosConfig。

效果:生成 etosllmstudio://provider/install?v=1&data={etosConfig},data 使用 new-api/baseUrl/apiKey 的 Base64 JSON,classic 侧边栏会跳过该外部 scheme。
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds "ETOS LLM Studio" as a new built-in chat provider. The backend registers the provider in the default Chats config and switches JSON marshalling to common.Marshal/common.Unmarshal. Both web UIs gain {etosConfig} placeholder handling that builds a Base64-encoded config payload from the server base URL and API key, with matching sidebar filtering and settings template registration.

Changes

ETOS LLM Studio provider integration

Layer / File(s) Summary
Backend provider registration and JSON marshalling
setting/chat.go
Adds ETOS LLM Studio entry (etosllmstudio://provider/install?v=1&data={etosConfig}) to default Chats slice; replaces encoding/json import with common, and updates UpdateChatsByJsonString/Chats2JsonString to use common.Unmarshal/common.Marshal.
{etosConfig} placeholder resolution and API key detection
web/default/src/features/chat/lib/chat-links.ts, web/classic/src/hooks/tokens/useTokensData.jsx
chatLinkRequiresApiKey adds {etosConfig} to the credential-requiring token set. resolveChatUrl and onOpenLink each add a branch that constructs a payload (id: 'new-api', baseUrl, apiKey: sk-{key}), Base64-encodes it, and replaces the {etosConfig} token in the URL.
Sidebar filter and settings template
web/classic/src/components/layout/SiderBar.jsx, web/classic/src/pages/Setting/Chat/SettingsChats.jsx
Sidebar extends the skip-condition list to ignore etosllmstudio links when building chatItems. BUILTIN_TEMPLATES gains the ETOS LLM Studio entry with its install URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • QuantumNous/new-api#1541: Also extends setting/chat.go's Chats provider mappings with a new provider entry and matching sidebar/template wiring.
  • QuantumNous/new-api#4668: Follows the same pattern of adding a new {...Config} placeholder (DeepChat's {deepchatConfig}) through resolveChatUrl, chatLinkRequiresApiKey, and token hook onOpenLink.

Poem

🐇 Hop hop, a new studio appears,
{etosConfig} encoded without fears,
Base64 payload, a key inside,
The sidebar skips it with elegant stride,
One more provider joins the warren wide! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding ETOS LLM Studio quick import support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
web/default/src/features/chat/lib/chat-links.ts (1)

163-201: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: consolidate the duplicated new-api payload branches.

{cherryConfig}, {deepchatConfig}, and {etosConfig} now build byte-identical payloads ({ id: 'new-api', baseUrl, apiKey }) and only differ by token name. Consider a small token→builder map to avoid further copy-paste as providers are added.

♻️ Sketch
-  if (url.includes('{cherryConfig}')) {
-    const payload = { id: 'new-api', baseUrl: safeServerAddress, apiKey: safeApiKey }
-    const encoded = encodeURIComponent(toBase64(JSON.stringify(payload)))
-    return replaceToken(url, '{cherryConfig}', encoded)
-  }
-  ...
-  if (url.includes('{etosConfig}')) { ... }
+  const newApiTokens = ['{cherryConfig}', '{deepchatConfig}', '{etosConfig}']
+  for (const token of newApiTokens) {
+    if (url.includes(token)) {
+      const payload = { id: 'new-api', baseUrl: safeServerAddress, apiKey: safeApiKey }
+      const encoded = encodeURIComponent(toBase64(JSON.stringify(payload)))
+      return replaceToken(url, token, encoded)
+    }
+  }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/features/chat/lib/chat-links.ts` around lines 163 - 201, The
{cherryConfig}, {deepchatConfig}, and {etosConfig} branches in chat-links.ts are
duplicating the same new-api payload logic. Refactor the URL-token handling in
the relevant function to use a small token-to-payload builder map or shared
helper so the identical { id: 'new-api', baseUrl, apiKey } construction lives in
one place, while still keeping the distinct token names and the existing
{aionuiConfig} payload unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@web/default/src/features/chat/lib/chat-links.ts`:
- Around line 163-201: The {cherryConfig}, {deepchatConfig}, and {etosConfig}
branches in chat-links.ts are duplicating the same new-api payload logic.
Refactor the URL-token handling in the relevant function to use a small
token-to-payload builder map or shared helper so the identical { id: 'new-api',
baseUrl, apiKey } construction lives in one place, while still keeping the
distinct token names and the existing {aionuiConfig} payload unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc9f2a1d-45ec-44b8-b81a-ac7d511ac4a2

📥 Commits

Reviewing files that changed from the base of the PR and between b191f47 and 44e2c2b.

📒 Files selected for processing (5)
  • setting/chat.go
  • web/classic/src/components/layout/SiderBar.jsx
  • web/classic/src/hooks/tokens/useTokensData.jsx
  • web/classic/src/pages/Setting/Chat/SettingsChats.jsx
  • web/default/src/features/chat/lib/chat-links.ts

@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
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