refactor(core): 梳理模型配置与审计脱敏服务

This commit is contained in:
2026-05-30 00:47:31 +08:00
parent ccfe5eb667
commit 322c161818
4 changed files with 151 additions and 63 deletions

View File

@@ -3,6 +3,7 @@ from agent_core.llm_provider import (
LLMConfigurationError,
create_embedding_provider,
create_llm_provider,
get_runtime_llm_config,
)
@@ -109,3 +110,17 @@ def test_embedding_provider_requires_api_key():
assert "EMBEDDING_API_KEY" in str(exc)
else:
raise AssertionError("expected EmbeddingConfigurationError")
def test_get_runtime_llm_config_uses_environment_and_overrides(monkeypatch):
monkeypatch.setenv("LLM_PROVIDER", "mock")
monkeypatch.setenv("LLM_API_KEY", "sk-env")
monkeypatch.setenv("LLM_BASE_URL", "https://env.example/v1")
monkeypatch.setenv("LLM_MODEL", "env-model")
config = get_runtime_llm_config({"LLM_MODEL": "override-model"})
assert config["LLM_PROVIDER"] == "mock"
assert config["LLM_API_KEY"] == "sk-env"
assert config["LLM_BASE_URL"] == "https://env.example/v1"
assert config["LLM_MODEL"] == "override-model"