mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-28 16:07:46 +00:00
fix: return 1D embedding if create_embedding receive a string input (#670)
* return single dimension embedding for string input of create_embedding * Update base.py * fix * fix * fix * fix --------- Co-authored-by: Xu <v-xuminrui@microsoft.com>
This commit is contained in:
@@ -273,7 +273,7 @@ class APIBackend(ABC):
|
||||
logger.log_object({"system": system_prompt, "user": user_prompt, "resp": resp}, tag="debug_llm")
|
||||
return resp
|
||||
|
||||
def create_embedding(self, input_content: str | list[str], *args, **kwargs) -> list[list[float]]: # type: ignore[no-untyped-def]
|
||||
def create_embedding(self, input_content: str | list[str], *args, **kwargs) -> list[float] | list[list[float]]: # type: ignore[no-untyped-def]
|
||||
input_content_list = [input_content] if isinstance(input_content, str) else input_content
|
||||
resp = self._try_create_chat_completion_or_embedding( # type: ignore[misc]
|
||||
input_content_list=input_content_list,
|
||||
@@ -281,6 +281,8 @@ class APIBackend(ABC):
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
if isinstance(input_content, str):
|
||||
return resp[0] # type: ignore[return-value]
|
||||
return resp # type: ignore[return-value]
|
||||
|
||||
def build_messages_and_calculate_token(
|
||||
|
||||
Reference in New Issue
Block a user