Bootstrap

调用 Xinference OpenAI接口时报错 Model not found in the model list, uid

错误如下, 请不要被错误吓住或蒙蔽双眼, 自己看最下面的报错内容

Traceback (most recent call last):
  File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 259, in __call__
    await wrap(partial(self.listen_for_disconnect, receive))
  File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 255, in wrap
    await func()
  File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 232, in listen_for_disconnect
    message = await receive()
              ^^^^^^^^^^^^^^^
  File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 555, in receive
    await self.message_event.wait()
  File "C:\Users\HW\.conda\envs\aibot\Lib\asyncio\locks.py", line 213, in wait
    await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 25257b8d810
During handling of the above exception, another exception occurred:
  + Exception Group Traceback (most recent call last):
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 401, in run_asgi
  |     result = await app(  # type: ignore[func-returns-value]
  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\uvicorn\middleware\proxy_headers.py", line 60, in __call__
  |     return await self.app(scope, receive, send)
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\fastapi\applications.py", line 1054, in __call__
  |     await super().__call__(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\applications.py", line 113, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\middleware\errors.py", line 187, in __call__
  |     raise exc
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\middleware\errors.py", line 165, in __call__
  |     await self.app(scope, receive, _send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\middleware\exceptions.py", line 62, in __call__
  |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\routing.py", line 715, in __call__
  |     await self.middleware_stack(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\routing.py", line 735, in app
  |     await route.handle(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\routing.py", line 288, in handle
  |     await self.app(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\routing.py", line 76, in app
  |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
  |     raise exc
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\_exception_handler.py", line 42, in wrapped_app
  |     await app(scope, receive, sender)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\routing.py", line 74, in app
  |     await response(scope, receive, send)
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 252, in __call__
  |     async with anyio.create_task_group() as task_group:
  |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\anyio\_backends\_asyncio.py", line 763, in __aexit__
  |     raise BaseExceptionGroup(
  | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 255, in wrap
    |     await func()
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\starlette\responses.py", line 244, in stream_response
    |     async for chunk in self.body_iterator:
    |   File "D:\codes\aibot\ask.py", line 49, in answer_generator
    |     for chunk in retrieval_chain.stream({"input": f"{request.question}"}):
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 5525, in stream
    |     yield from self.bound.stream(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3407, in stream
    |     yield from self.transform(iter([input]), config, **kwargs)
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3394, in transform
    |     yield from self._transform_stream_with_config(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 2197, in _transform_stream_with_config
    |     chunk: Output = context.run(next, iterator)  # type: ignore
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3357, in _transform
    |     yield from final_pipeline
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\passthrough.py", line 576, in transform
    |     yield from self._transform_stream_with_config(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 2197, in _transform_stream_with_config
    |     chunk: Output = context.run(next, iterator)  # type: ignore
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\passthrough.py", line 566, in _transform
    |     yield cast(dict[str, Any], first_map_chunk_future.result())
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\_base.py", line 456, in result
    |     return self.__get_result()
    |            ^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\_base.py", line 401, in __get_result
    |     raise self._exception
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\thread.py", line 58, in run
    |     result = self.fn(*self.args, **self.kwargs)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3847, in transform
    |     yield from self._transform_stream_with_config(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 2197, in _transform_stream_with_config
    |     chunk: Output = context.run(next, iterator)  # type: ignore
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3832, in _transform
    |     chunk = AddableDict({step_name: future.result()})
    |                                     ^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\_base.py", line 449, in result
    |     return self.__get_result()
    |            ^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\_base.py", line 401, in __get_result
    |     raise self._exception
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\concurrent\futures\thread.py", line 58, in run
    |     result = self.fn(*self.args, **self.kwargs)
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 5561, in transform
    |     yield from self.bound.transform(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3394, in transform
    |     yield from self._transform_stream_with_config(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 2197, in _transform_stream_with_config
    |     chunk: Output = context.run(next, iterator)  # type: ignore
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 3357, in _transform
    |     yield from final_pipeline
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\output_parsers\transform.py", line 64, in transform
    |     yield from self._transform_stream_with_config(
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 2161, in _transform_stream_with_config
    |     final_input: Optional[Input] = next(input_for_tracing, None)
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\runnables\base.py", line 1431, in transform
    |     yield from self.stream(final, config, **kwargs)
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\language_models\chat_models.py", line 420, in stream
    |     raise e
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_core\language_models\chat_models.py", line 400, in stream
    |     for chunk in self._stream(messages, stop=stop, **kwargs):
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\langchain_openai\chat_models\base.py", line 658, in _stream
    |     response = self.client.create(**payload)
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\openai\_utils\_utils.py", line 274, in wrapper
    |     return func(*args, **kwargs)
    |            ^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\openai\resources\chat\completions.py", line 815, in create
    |     return self._post(
    |            ^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\openai\_base_client.py", line 1277, in post
    |     return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
    |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\openai\_base_client.py", line 954, in request
    |     return self._request(
    |            ^^^^^^^^^^^^^^
    |   File "C:\Users\HW\.conda\envs\aibot\Lib\site-packages\openai\_base_client.py", line 1058, in _request
    |     raise self._make_status_error_from_response(err.response) from None
    | openai.BadRequestError: Error code: 400 - {'detail': '[address=0.0.0.0:12781, pid=304366] Model not found in the model list, uid: qwen2.5-instruct123'}

这里面列出来了找不到model, uid, 在加载模型时, Model UlD, model name by default 可选字段一定要填, 不填的话可能会生成随机的一个ID, 导致调用时找不到模型

重新加载模型, 按如下图示设置名称即可, 使用时使用设置的MODEL UID即可

;