Skip to content

Commit 2ac6434

Browse files
committed
fix: add ANTHROPIC/AZURE cases to validator + remove unused original_message param
- clients/anthropic/chat_models.py: add VendorType.ANTHROPIC and VendorType.AZURE cases to setup_api_flavor_and_version validator so the class can be constructed with all supported vendor types without raising - clients/normalized/chat_models.py: remove the now-unused original_message parameter from _generate_chunk and update both call sites in _uipath_stream and _uipath_astream
1 parent 0de9716 commit 2ac6434

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/uipath_langchain_client/src/uipath_langchain_client/clients/anthropic/chat_models.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,17 @@ class UiPathChatAnthropic(UiPathBaseChatModel, ChatAnthropic):
4545
def setup_api_flavor_and_version(self) -> Self:
4646
self.api_config.vendor_type = self.vendor_type
4747
match self.vendor_type:
48+
case VendorType.ANTHROPIC:
49+
self.api_config.api_flavor = ApiFlavor.CHAT_COMPLETIONS
50+
case VendorType.AZURE:
51+
self.api_config.api_flavor = ApiFlavor.CHAT_COMPLETIONS
4852
case VendorType.VERTEXAI:
4953
self.api_config.api_flavor = ApiFlavor.ANTHROPIC_CLAUDE
5054
self.api_config.api_version = "v1beta1"
5155
case VendorType.AWSBEDROCK:
5256
self.api_config.api_flavor = ApiFlavor.INVOKE
5357
case _:
54-
raise ValueError(
55-
"anthropic and azure vendors are currently not supported by UiPath"
56-
)
58+
raise ValueError(f"Unsupported vendor_type: {self.vendor_type}")
5759
return self
5860

5961
# Override fields to avoid typing issues and fix stuff

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,7 @@ async def _uipath_agenerate(
328328
response = await self.uipath_arequest(request_body=request_body, raise_status_error=True)
329329
return self._postprocess_response(response.json())
330330

331-
def _generate_chunk(
332-
self, original_message: str, json_data: dict[str, Any]
333-
) -> ChatGenerationChunk:
331+
def _generate_chunk(self, json_data: dict[str, Any]) -> ChatGenerationChunk:
334332
generation_info = {
335333
"id": json_data.get("id"),
336334
"created": json_data.get("created", ""),
@@ -406,7 +404,7 @@ def _uipath_stream(
406404
continue
407405
if "id" in json_data and not json_data["id"]:
408406
continue
409-
yield self._generate_chunk(chunk, json_data)
407+
yield self._generate_chunk(json_data)
410408

411409
async def _uipath_astream(
412410
self,
@@ -429,4 +427,4 @@ async def _uipath_astream(
429427
continue
430428
if "id" in json_data and not json_data["id"]:
431429
continue
432-
yield self._generate_chunk(chunk, json_data)
430+
yield self._generate_chunk(json_data)

0 commit comments

Comments
 (0)