Add engine encode (#1995)

Co-authored-by: Byron Hsu <byronhsu1230@gmail.com>
This commit is contained in:
James Xu
2024-11-11 14:48:17 -05:00
committed by GitHub
parent aaf0a3156e
commit ddeb9d42de
3 changed files with 29 additions and 1 deletions

View File

@@ -874,4 +874,12 @@ class Engine:
else:
return tokenizer_manager.tokenizer
# TODO (ByronHsu): encode
def encode(
self,
prompt: Union[str, List[str], List[Dict], List[List[Dict]]],
):
obj = EmbeddingReqInput(text=prompt)
# get the current event loop
loop = asyncio.get_event_loop()
return loop.run_until_complete(encode_request(obj, None))