Skip to content

适配新版 LLM 配置结构#147

Merged
2727781955 merged 2 commits into
devfrom
feature/llm-config-refactor
Jun 7, 2026
Merged

适配新版 LLM 配置结构#147
2727781955 merged 2 commits into
devfrom
feature/llm-config-refactor

Conversation

@2727781955
Copy link
Copy Markdown
Collaborator

背景

Java 端已切换到新版 LLM 配置结构,Python RAG 端需要同步适配 provider-model-preset 设计,否则会出现用户配置读取异常、provider_type 无法路由、API Key 解密失败等问题。

关联 issue:Closes #146

主要改动

  • 调整 LLM 配置 ORM、Pydantic 模型和 Alembic migration,新增 llm_provider_modelllm_system_preset,并同步瘦身后的 llm_system_provider 与新结构 llm_user_config
  • Python 运行时改为按 user_id + capability + is_default + is_active 读取 llm_user_config 生效配置,移除无能力维度的默认配置读取语义。
  • 配置读取链路切换到 api_base_url,不再访问旧字段 custom_api_base_urlprioritytimeout_msmax_retriesstream_enabledextra_config 等。
  • API Key 加解密对齐 Java:AES-256-GCM,64 位 hex secret 解码为 32 字节。
  • 增加 provider_type 映射:aliyun -> qwenclaude -> anthropic
  • 更新内部 LLM 配置接口返回字段,避免继续暴露旧契约字段。
  • 同步 scripts/db/init.sqlscripts/db/schema.sql、schema/ops 文档和相关单元/集成测试。
  • .gitignore 增加本地 docker-compose.override.yml 忽略规则。

验证

已执行:

.venv/bin/python -m pytest tests/unit -q
.venv/bin/python -m pytest tests/unit/core/llm tests/unit/core/splitter/test_user_embedding_resolution.py tests/unit/core/markdown_parser/test_provider_resolution.py -q
.venv/bin/python -m compileall -q src migrations/versions/0013_20260606_llm_config_refactor.py
.venv/bin/python scripts/check_docs_sync.py --staged
git diff --check

说明:tests/integration/services/test_config_reader_integration.py 已按新 schema 更新,但本地 MySQL 凭据拒绝连接,未能实际跑通该集成测试。

@2727781955 2727781955 merged commit 6531e5e into dev Jun 7, 2026
2 checks passed
@jixua jixua deleted the feature/llm-config-refactor branch June 8, 2026 03:13
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.

Python 端未适配新版 LLM 配置结构导致用户模型配置读取异常

1 participant