mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-07 03:00:27 +00:00
add async support for lli embedding
This commit is contained in:
parent
b7d2c7b2b3
commit
1887138e47
2 changed files with 23 additions and 3 deletions
|
|
@ -50,4 +50,19 @@ class LLIEmbedding(BaseEmbeddingModel):
|
|||
return results
|
||||
|
||||
|
||||
async def _async_call(self, **kwargs) -> ModelResponse:
|
||||
"""
|
||||
:param kwargs:
|
||||
:return:
|
||||
"""
|
||||
results = ModelResponse()
|
||||
try:
|
||||
response = self.model.aget_text_embedding_batch(**self.data)
|
||||
results.raw = response
|
||||
results.status = True
|
||||
except Exception as e:
|
||||
results.details = e
|
||||
results.status = False
|
||||
return results
|
||||
|
||||
|
||||
|
|
@ -17,8 +17,13 @@ class TestLLIEmbedding(unittest.TestCase):
|
|||
embs = self.emb.call(text=text)
|
||||
|
||||
def test_batch_embedding(self):
|
||||
text = ["您吃了吗?",
|
||||
texts = ["您吃了吗?",
|
||||
"吃了吗您?"]
|
||||
embs = self.emb.call(text=text)
|
||||
embs = self.emb.call(text=texts)
|
||||
|
||||
|
||||
async def test_async_embedding(self):
|
||||
texts = ["您吃了吗?",
|
||||
"吃了吗您?"]
|
||||
# 调用异步函数并等待其结果
|
||||
embs = await self.emb.async_call(texts)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue