Skip to content

Commit 1ae8f0b

Browse files
committed
fix: bugs #5 and #8 (embeddings model name + error handling)
Bug #5 — UiPathFireworksEmbeddings: self.model returned wrong model name Without an explicit field override, Pydantic kept two separate fields: FireworksEmbeddings.model (default 'nomic-ai/nomic-embed-text-v1.5') and UiPathBaseLLMClient.model_name (populated by the caller via alias 'model'). self.model therefore always resolved to the stale FireworksEmbeddings default, silently ignoring whatever model name the caller passed. Fix: add model: str = Field(default='', alias='model_name') — the same override pattern used by every other embedding class — to collapse the two fields into one. Replace self.model with self.model_name in all four embed methods. Bug #8 — UiPathEmbeddings: silent HTTP error swallowing + missing model field Two issues in embed_documents / aembed_documents: 1. uipath_request / uipath_arequest were called without raise_status_error=True, so HTTP 4xx/5xx responses were silently accepted. The subsequent response.json()['data'] access would then raise a confusing KeyError or AttributeError rather than a clear HTTP error. 2. The request body only contained {'input': texts}. The normalized API requires a 'model' field for routing, matching the pattern already used by the normalized chat model (_default_params includes 'model'). Fix: pass raise_status_error=True and add 'model': self.model_name to the request body in both the sync and async paths.
1 parent dc78050 commit 1ae8f0b

2 files changed

Lines changed: 22 additions & 5 deletions

File tree

packages/uipath_langchain_client/src/uipath_langchain_client/clients/fireworks/embeddings.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Self
22

3-
from pydantic import model_validator
3+
from pydantic import Field, model_validator
44

55
from uipath_langchain_client.base_client import UiPathBaseEmbeddings
66
from uipath_langchain_client.settings import (
@@ -31,6 +31,14 @@ class UiPathFireworksEmbeddings(UiPathBaseEmbeddings, FireworksEmbeddings):
3131
freeze_base_url=True,
3232
)
3333

34+
# Override FireworksEmbeddings.model so that Pydantic merges it with
35+
# UiPathBaseLLMClient.model_name (alias="model") into a single field.
36+
# Without this, two separate fields coexist: FireworksEmbeddings.model
37+
# (default "nomic-ai/nomic-embed-text-v1.5") and model_name, causing
38+
# self.model to always return the stale FireworksEmbeddings default
39+
# instead of the model name supplied by the caller.
40+
model: str = Field(default="", alias="model_name")
41+
3442
@model_validator(mode="after")
3543
def setup_uipath_client(self) -> Self:
3644
self.client = OpenAI(
@@ -48,7 +56,8 @@ def setup_uipath_client(self) -> Self:
4856
def embed_documents(self, texts: list[str]) -> list[list[float]]:
4957
"""Embed search docs."""
5058
return [
51-
i.embedding for i in self.client.embeddings.create(input=texts, model=self.model).data
59+
i.embedding
60+
for i in self.client.embeddings.create(input=texts, model=self.model_name).data
5261
]
5362

5463
def embed_query(self, text: str) -> list[float]:
@@ -59,7 +68,9 @@ async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
5968
"""Embed search docs asynchronously."""
6069
return [
6170
i.embedding
62-
for i in (await self.async_client.embeddings.create(input=texts, model=self.model)).data
71+
for i in (
72+
await self.async_client.embeddings.create(input=texts, model=self.model_name)
73+
).data
6374
]
6475

6576
async def aembed_query(self, text: str) -> list[float]:

packages/uipath_langchain_client/src/uipath_langchain_client/clients/normalized/embeddings.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ class UiPathEmbeddings(UiPathBaseEmbeddings, Embeddings):
1818
)
1919

2020
def embed_documents(self, texts: list[str]) -> list[list[float]]:
21-
response = self.uipath_request(request_body={"input": texts})
21+
response = self.uipath_request(
22+
request_body={"input": texts, "model": self.model_name},
23+
raise_status_error=True,
24+
)
2225
return [r["embedding"] for r in response.json()["data"]]
2326

2427
def embed_query(self, text: str) -> list[float]:
2528
return self.embed_documents([text])[0]
2629

2730
async def aembed_documents(self, texts: list[str]) -> list[list[float]]:
28-
response = await self.uipath_arequest(request_body={"input": texts})
31+
response = await self.uipath_arequest(
32+
request_body={"input": texts, "model": self.model_name},
33+
raise_status_error=True,
34+
)
2935
return [r["embedding"] for r in response.json()["data"]]
3036

3137
async def aembed_query(self, text: str) -> list[float]:

0 commit comments

Comments
 (0)