袁聪的第三次提交,API接口完善
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user