[求助]langchain_RAGproject执行调用错误 #391
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: HswOAuth/llm_course#391
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
使用知识库:/private/var/folders/2d/j1j7jfyj0s96pm65btg8x_pc0000gp/T/gradio/0bd74a929ae84dbb2815120863c8a98abeef39e8fa189e15021ca284c249440e/招聘管理.docx
Traceback (most recent call last):
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/gradio/queueing.py", line 624, in process_events
response = await route_utils.call_process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/gradio/route_utils.py", line 323, in call_process_api
output = await app.get_blocks().process_api(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/gradio/blocks.py", line 2018, in process_api
result = await self.call_function(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/gradio/blocks.py", line 1567, in call_function
prediction = await anyio.to_thread.run_sync( # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 2441, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 943, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/gradio/utils.py", line 846, in wrapper
response = f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/main.py", line 132, in llm_reply
response = self.llm.invoke( # 使用LLM模型生成回复
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/src/LLM.py", line 97, in invoke
).invoke(
^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3024, in invoke
input = context.run(step.invoke, input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 4713, in invoke
return self._call_with_config(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1927, in _call_with_config
context.run(
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable_args
return func(input, **kwargs) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 4578, in _invoke
output = output.invoke(
^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3024, in invoke
input = context.run(step.invoke, input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/passthrough.py", line 494, in invoke
return self._call_with_config(self._invoke, input, config, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1927, in _call_with_config
context.run(
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable_args
return func(input, **kwargs) # type: ignore[call-arg]
^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/passthrough.py", line 481, in _invoke
**self.mapper.invoke(
^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3727, in invoke
output = {key: future.result() for key, future in zip(steps, futures)}
^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3711, in _invoke_step
return context.run(
^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 5354, in invoke
return self.bound.invoke(
^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 3024, in invoke
input = context.run(step.invoke, input, config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 286, in invoke
self.generate_prompt(
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 786, in generate_prompt
return self.generate(prompt_messages, stop=stop, callbacks=callbacks, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 643, in generate
raise e
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 633, in generate
self._generate_with_cache(
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 851, in _generate_with_cache
result = self._generate(
^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 706, in _generate
return self._create_chat_result(response, generation_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 743, in _create_chat_result
message = _convert_dict_to_message(res["message"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 160, in _convert_dict_to_message
return ChatMessage(content=dict.get("content", ""), role=role, id=id) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/messages/base.py", line 76, in init
super().init(content=content, **kwargs)
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/site-packages/langchain_core/load/serializable.py", line 125, in init
super().init(*args, **kwargs)
File "/Users/xuelong/Pyproject/Langchain_RAGProject/.venv/lib/python3.12/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 ChatMessage
role
Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.9/v/string_type
你新建一个虚拟环境 按照requirements.txt 文件 去安装模块