feat: add structured custom model editor - #5
Open
awoaCrim wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Pi Switch 之前只能维护较少的模型字段,复杂模型配置仍需要直接编辑 Pi 的
models.json。这不仅操作成本高,也容易在导入、替换或编辑模型时丢失 Pi 新版本及服务商扩展字段。本 PR 增加结构化自定义模型编辑器,并在持久化、Wails 传输和前端状态三个层面补齐未知字段保留、默认模型同步与并发修改保护。
改动
contextWindow、maxTokens改为正整数校验。实现说明
ModelInfo/Config负责持久化语义。ModelTransport/ConfigTransport负责前端传输。json.RawMessage保存,并以原始 JSON 文本通过extraFieldsJson/compatExtraFieldsJson传输,避免 JavaScriptNumber改写大整数。extraFields、revision、replaceDocument、originalId等未知字段不会再与 Pi Switch 的传输元数据冲突。selected仅作为前端导入选择状态,不写入 Pi 配置。ReplaceModels返回后端实际持久化后的模型和新列表 revision,保证连续编辑使用最新快照。zaiToolStream、supportsThinkingTokenBudget、supportsAdditionalTools、supportsExplicitPromptCacheMode。测试
已通过以下完整非缓存门禁:
go clean -testcachego test -count=1 ./...go vet ./...cd frontend && npm test(19 项通过)cd frontend && npm run buildgit diff --checkwails build -platform windows/amd64 -m -nosyncgomod -skipbindingsWindows 构建产物:
build/bin/PiSwitch.exef05056669c4da22a470b46336a7f2f8e8e8d6f2f21ed51a358372326fcc16ea8范围说明
docs/pr-workflow.md是本地流程研究文档,未包含在本 PR 中。