Skip to content

Commit 4867fe7

Browse files
authored
[langchain_community.llms.xinference]: fix error in xinference.py (#29216)
- [ ] **PR title**: [langchain_community.llms.xinference]: fix error in xinference.py - [ ] **PR message**: - The old code raised an ValidationError: pydantic_core._pydantic_core.ValidationError: 1 validation error for Xinference when import Xinference from xinference.py. This issue has been resolved by adjusting it's type and default value. File "/media/vdc/python/lib/python3.10/site-packages/pydantic/main.py", line 212, in __init__ validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self) pydantic_core._pydantic_core.ValidationError: 1 validation error for Xinference client Field required [type=missing, input_value={'server_url': 'http://10...t4', 'model_kwargs': {}}, input_type=dict] For further information visit https://errors.pydantic.dev/2.9/v/missing - [ ] **tests**: from langchain_community.llms import Xinference llm = Xinference( server_url="http://0.0.0.0:9997", # replace your xinference server url model_uid={model_uid} # replace model_uid with the model UID return from launching the model )
1 parent bea5798 commit 4867fe7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libs/community/langchain_community/llms/xinference.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Xinference(LLM):
8181
8282
""" # noqa: E501
8383

84-
client: Any
84+
client: Optional[Any] = None
8585
server_url: Optional[str]
8686
"""URL of the xinference server"""
8787
model_uid: Optional[str]
@@ -156,6 +156,8 @@ def _call(
156156
Returns:
157157
The generated string by the model.
158158
"""
159+
if self.client is None:
160+
raise ValueError("Client is not initialized!")
159161
model = self.client.get_model(self.model_uid)
160162

161163
generate_config: "LlamaCppGenerateConfig" = kwargs.get("generate_config", {})

0 commit comments

Comments
 (0)