xorbitsai / inference

Replace OpenAI GPT with another LLM in your app by changing a single line of code. Xinference gives you the freedom to use any LLM you need. With Xinference, you're empowered to run inference with any open-source language models, speech recognition models, and multimodal models, whether in the cloud, on-premises, or even on your laptop.
https://inference.readthedocs.io
Apache License 2.0
5.11k stars 413 forks source link

pydantic_core._pydantic_core.ValidationError #2422

Open windcandle opened 1 week ago

windcandle commented 1 week ago

System Info / 系統信息

ubuntu20.04 CUDA:12.0 python3.10.15

Xinference run ok, I use client call endpiont.

Running Xinference with Docker? / 是否使用 Docker 运行 Xinfernece?

Version info / 版本信息

Xinference:0.15.3

The command used to start Xinference / 用以启动 xinference 的命令

Use client call xinference endpoint.

Reproduction / 复现过程

Code looks like this: this code referecence xinference examples,but error.

from langchain_community.llms import Xinference
xinference_llm = Xinference(
    server_url="http://XXX.XXX.XXX.XXX:9997",
    model_uid="qwen2-instruct",
)

Run this code with code error

/root/miniconda3/bin/conda run -n llm_service_3.10 --no-capture-output python llm-service/xinference/xinference_qa.py 
Traceback (most recent call last):
  File "llm-service/xinference/xinference_qa.py", line 63, in <module>
    xinference_llm = Xinference(
  File "/root/miniconda3/envs/llm_service_3.10/lib/python3.10/site-packages/langchain_community/llms/xinference.py", line 111, in __init__
    super().__init__(
  File "/root/miniconda3/envs/llm_service_3.10/lib/python3.10/site-packages/langchain_core/load/serializable.py", line 111, in __init__
    super().__init__(*args, **kwargs)
  File "/root/miniconda3/envs/llm_service_3.10/lib/python3.10/site-packages/pydantic/main.py", line 193, in __init__
    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...ct', 'model_kwargs': {}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing
ERROR conda.cli.main_run:execute(125): `conda run python llm-service/xinference/xinference_qa.py` failed. (See above for error)

I don't know what happend.

Expected behavior / 期待表现

It can run withour no errors!

codingl2k1 commented 4 days ago

Could you try using the LangChain OpenAI integration? Xinference is compatible with the OpenAI API.