运行web_demo.py成功了,但是在进行提问回答的时候报错了
To create a public link, set share=True
in launch()
.
F:\anaconda\envs\lm\lib\site-packages\gradio\helpers.py:818: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. return gr.Textbox(...)
instead of return gr.update(...)
.
warnings.warn(
F:\anaconda\envs\lm\lib\site-packages\gradio\components\textbox.py:163: UserWarning: Using the update method is deprecated. Simply return a new object instead, e.g. return gr.Textbox(...)
instead of return gr.Textbox.update(...)
.
warnings.warn(
Traceback (most recent call last):
File "F:\anaconda\envs\lm\lib\site-packages\gradio\queueing.py", line 406, in call_prediction
output = await route_utils.call_process_api(
File "F:\anaconda\envs\lm\lib\site-packages\gradio\route_utils.py", line 226, in call_process_api
output = await app.get_blocks().process_api(
File "F:\anaconda\envs\lm\lib\site-packages\gradio\blocks.py", line 1554, in process_api
result = await self.call_function(
File "F:\anaconda\envs\lm\lib\site-packages\gradio\blocks.py", line 1206, in call_function
prediction = await utils.async_iteration(iterator)
File "F:\anaconda\envs\lm\lib\site-packages\gradio\utils.py", line 517, in async_iteration
return await iterator.anext()
File "F:\anaconda\envs\lm\lib\site-packages\gradio\utils.py", line 510, in anext
return await anyio.to_thread.run_sync(
File "F:\anaconda\envs\lm\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
return await get_asynclib().run_sync_in_worker_thread(
File "F:\anaconda\envs\lm\lib\site-packages\anyio_backends_asyncio.py", line 877, in run_sync_in_worker_thread
return await future
File "F:\anaconda\envs\lm\lib\site-packages\anyio_backends_asyncio.py", line 807, in run
result = context.run(func, args)
File "F:\anaconda\envs\lm\lib\site-packages\gradio\utils.py", line 493, in run_sync_iterator_async
return next(iterator)
File "F:\anaconda\envs\lm\lib\site-packages\gradio\utils.py", line 647, in gen_wrapper
yield from f(args, **kwargs)
File "F:\code\ChatGLM2-6B-main\ChatGLM2-6B-main\web_demo.py", line 66, in predict
for response, history, past_key_values in model.stream_chat(tokenizer, input, history, past_key_value=past_key_values,
ValueError: not enough values to unpack (expected 3, got 2)
这个错误是因为在您的代码中,model.stream_chat
函数的返回值是3个元素的元组,但是您只提供了2个变量来接收这些元素。您需要在调用model.stream_chat
函数时,提供3个变量来接收返回值,例如:
response, history, past_key_values = model.stream_chat(tokenizer, input, history, past_key_value=past_key_values,
这样,就可以正确地接收model.stream_chat
函数的返回值了。
这个错误信息表明你在尝试使用一个过时的方法(update)来创建一个新的对象。这可能是由于你的代码中使用了不兼容的版本导致的。
你可以尝试以下几种解决方案:
检查你的代码,找到使用update
的地方,并改为直接返回新的对象。例如,如果你原来是这样写的:
result = await gr.Textbox.update(...)
改为:
result = gr.Textbox(...)
检查你的依赖库版本,确保你使用的是与你的代码兼容的版本。你可以使用pip list
命令查看你的依赖库版本。如果发现问题,可以尝试升级或降级相应的依赖库。