Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: create_embedding add field model_replica #2779

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions xinference/api/restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion xinference/model/embedding/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just let the model be the model name? Empty looks weird, what's you opinion? @codingl2k1 @amumu96

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cann't get model name in here, only replica name. We need to change create_embedding_model_instance and trans origin_uid into EmbeddingModel

model_replica=self._model_uid,
data=embedding_list,
usage=usage,
)
Expand Down
1 change: 1 addition & 0 deletions xinference/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class EmbeddingData(TypedDict):
class Embedding(TypedDict):
object: Literal["list"]
model: str
model_replica: str
data: List[EmbeddingData]
usage: EmbeddingUsage

Expand Down
Loading