添加provider工厂和Ollama支持

- 实现ProviderFactory用于构建不同类型的provider适配器
- 添加EnvironmentCredentialResolver用于解析环境变量中的凭证
- 实现OllamaProvider支持本地模型调用
- 实现OpenAICompatibleProvider支持OpenAI兼容接口
- 在AgentRuntime中添加对ProviderError的处理
- 更新Message结构体添加tool_calls字段
- 实现provider配置的增删改查API端点
- 添加provider注册表的replace方法
- 添加HTTP基础类和工具参数解码功能
- 更新依赖添加httpx库
- 添加相关单元测试验证provider适配器功能
```
This commit is contained in:
2026-08-27 14:16:57 +08:00
parent b71984d951
commit 1741f7b1aa
18 changed files with 794 additions and 20 deletions
+24
View File
@@ -2,6 +2,8 @@ import asyncio
from app.main import health, service_status
from app.routes import get_index_status, list_notes, list_plugins, list_providers, list_skills
from app.routes import create_provider, delete_provider, get_provider, update_provider
from app.contracts import ProviderCreateRequest, ProviderType, ProviderUpdateRequest
def test_health() -> None:
@@ -53,3 +55,25 @@ def test_openapi_contains_documented_frontend_interfaces() -> None:
}
assert expected_paths <= paths.keys()
def test_provider_configuration_lifecycle() -> None:
created = asyncio.run(
create_provider(
ProviderCreateRequest(
provider_type=ProviderType.ollama,
name="Local Ollama",
base_url="http://127.0.0.1:11434",
default_model="qwen3:latest",
)
)
)
fetched = asyncio.run(get_provider(created.provider_id))
disabled = asyncio.run(
update_provider(created.provider_id, ProviderUpdateRequest(enabled=False))
)
deleted = asyncio.run(delete_provider(created.provider_id))
assert fetched.provider_type == ProviderType.ollama
assert disabled.enabled is False
assert deleted.resource_id == created.provider_id