mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-18 01:31:02 +02:00
Spec clients
This commit is contained in:
parent
c5cd70dacb
commit
93bb2adb9e
9 changed files with 140 additions and 56 deletions
26
trustgraph-base/trustgraph/base/embedings_client.py
Normal file
26
trustgraph-base/trustgraph/base/embedings_client.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
from . request_response_spec import RequestResponse, RequestResponseSpec
|
||||
from .. schema import EmbeddingsReqeust, EmbeddingsResponse
|
||||
|
||||
class EmbeddingsClient(RequestResponse):
|
||||
async def embed(self, text, timeout=30):
|
||||
resp = await self.request(
|
||||
EmbeddingsRequest(
|
||||
text = text
|
||||
),
|
||||
timeout=timeout
|
||||
)
|
||||
return resp.vectors
|
||||
|
||||
class EmbeddingsClientSpec(RequestResponseSpec):
|
||||
def __init__(
|
||||
self, request_name, response_name,
|
||||
):
|
||||
super(EmbeddingsRequestResponseSpec, self).__init__(
|
||||
request_name = request_name,
|
||||
request_schema = EmbeddingsRequest,
|
||||
response_name = response_name,
|
||||
response_schema = EmbeddingsResponse,
|
||||
impl = EmbeddingsClient,
|
||||
)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue