feat(provider): 添加厂商预设与模型发现接口

This commit is contained in:
2026-08-30 10:43:55 +08:00
parent 11cb384115
commit f7d864bc4d
5 changed files with 112 additions and 3 deletions
+22
View File
@@ -134,6 +134,28 @@ def test_openai_compatible_preserves_tool_call_context() -> None:
assert turn.text == "done"
def test_openai_compatible_fetches_and_maps_model_list() -> None:
def handler(request: httpx.Request) -> httpx.Response:
assert request.method == "GET"
assert request.url.path == "/v1/models"
assert request.headers["Authorization"] == "Bearer secret-test-key"
return httpx.Response(
200,
json={"data": [{"id": "model-b"}, {"id": "model-a"}]},
)
provider = OpenAICompatibleProvider(
base_url="https://provider.test/v1",
credential_id="provider-test",
credentials=StaticCredentials(),
transport=httpx.MockTransport(handler),
)
models = run(provider.list_models())
assert [item.model for item in models] == ["model-b", "model-a"]
def test_ollama_maps_models_and_completion() -> None:
def handler(request: httpx.Request) -> httpx.Response:
if request.url.path == "/api/tags":