From 8fa9ad4c769ece0c611734e250298eb1f6a3b488 Mon Sep 17 00:00:00 2001 From: zhoudelong <1727964916@qq.com> Date: Wed, 22 Jan 2025 18:23:36 +0800 Subject: [PATCH 1/2] UPDATE: create_embedding add field model_replica --- xinference/api/restful_api.py | 1 + xinference/model/embedding/core.py | 3 ++- xinference/types.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xinference/api/restful_api.py b/xinference/api/restful_api.py index e718f842a9..70e11d5a43 100644 --- a/xinference/api/restful_api.py +++ b/xinference/api/restful_api.py @@ -1331,6 +1331,7 @@ async def create_embedding(self, request: Request) -> Response: try: embedding = await model.create_embedding(body.input, **kwargs) + embedding["model"] = model_uid # type: ignore return Response(embedding, media_type="application/json") except Exception as e: e = await self._get_model_last_error(model.uid, e) diff --git a/xinference/model/embedding/core.py b/xinference/model/embedding/core.py index acf3447350..6a4aad7b5c 100644 --- a/xinference/model/embedding/core.py +++ b/xinference/model/embedding/core.py @@ -693,7 +693,8 @@ def base64_to_image(base64_str: str) -> Image.Image: if not is_bge_m3_flag_model and not kwargs.get("return_sparse") else "dict" ), - model=self._model_uid, + model="", + model_replica=self._model_uid, data=embedding_list, usage=usage, ) diff --git a/xinference/types.py b/xinference/types.py index 1e8ca71a02..e002988083 100644 --- a/xinference/types.py +++ b/xinference/types.py @@ -78,6 +78,7 @@ class EmbeddingData(TypedDict): class Embedding(TypedDict): object: Literal["list"] model: str + model_replica: str data: List[EmbeddingData] usage: EmbeddingUsage From db226def2e1780f4ba2fc7d29417317dd3495ccb Mon Sep 17 00:00:00 2001 From: codingl2k1 Date: Wed, 22 Jan 2025 14:15:47 +0100 Subject: [PATCH 2/2] Fix lint --- xinference/api/restful_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xinference/api/restful_api.py b/xinference/api/restful_api.py index 70e11d5a43..b17a25c129 100644 --- a/xinference/api/restful_api.py +++ b/xinference/api/restful_api.py @@ -1331,7 +1331,7 @@ async def create_embedding(self, request: Request) -> Response: try: embedding = await model.create_embedding(body.input, **kwargs) - embedding["model"] = model_uid # type: ignore + embedding["model"] = model_uid # type: ignore return Response(embedding, media_type="application/json") except Exception as e: e = await self._get_model_last_error(model.uid, e)