袁聪的第三次提交,API接口完善

This commit is contained in:
2026-09-12 12:20:01 +08:00
parent 0a78a9df76
commit 91f5373cfb
20 changed files with 524 additions and 73 deletions
+7 -3
View File
@@ -1,7 +1,7 @@
import os
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, Protocol
from typing import Any, Protocol, cast
import httpx
from sqlalchemy import select
@@ -148,14 +148,18 @@ class DatabaseModelGateway:
async def generate(self, *, endpoint_code: str, prompt: str, timeout_ms: int) -> str:
endpoint = await self._endpoint(endpoint_code)
adapter = OpenAICompatibleGateway({endpoint.endpoint_code: endpoint})
adapter = OpenAICompatibleGateway(
{endpoint.endpoint_code: cast(EndpointSettings, endpoint)}
)
return await adapter.generate(
endpoint_code=endpoint.endpoint_code, prompt=prompt, timeout_ms=timeout_ms
)
async def embed(self, *, endpoint_code: str, text: str, timeout_ms: int) -> list[float]:
endpoint = await self._endpoint(endpoint_code)
adapter = OpenAICompatibleGateway({endpoint.endpoint_code: endpoint})
adapter = OpenAICompatibleGateway(
{endpoint.endpoint_code: cast(EndpointSettings, endpoint)}
)
return await adapter.embed(
endpoint_code=endpoint.endpoint_code, text=text, timeout_ms=timeout_ms
)