Executing the code provided above will result in an error:
Traceback (most recent call last):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\tests\test1.py", line 47, in
print(agent_executor.invoke({"input": query}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\chains\base.py", line 170, in invoke
raise e
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\chains\base.py", line 160, in invoke
self._call(inputs, run_manager=run_manager)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1629, in _call
next_step_output = self._take_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1335, in _take_next_step
[
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1335, in
[
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1363, in _iter_next_step
output = self._action_agent.plan(
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 580, in plan
for chunk in self.runnable.stream(inputs, config={"callbacks": callbacks}):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3405, in stream
yield from self.transform(iter([input]), config, kwargs)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3392, in transform
yield from self._transform_stream_with_config(
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 2193, in _transform_stream_with_config
chunk: Output = context.run(next, iterator) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3355, in _transform
yield from final_pipeline
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 1409, in transform
for ichunk in input:
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 5550, in transform
yield from self.bound.transform(
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 1427, in transform
yield from self.stream(final, config, kwargs)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\language_models\chat_models.py", line 418, in stream
raise e
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\language_models\chat_models.py", line 398, in stream
for chunk in self._stream(messages, stop=stop, **kwargs):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_openai\chat_models\base.py", line 626, in _stream
chunk = chunk.model_dump()
^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\pydantic\main.py", line 390, in model_dump
return self.__pydantic_serializer__.to_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'MockValSer' object cannot be converted to 'SchemaSerializer'
This error was solved by setting the environment variable DEFER_PYDANTIC_BUILD=0.
However, when I executed it again, a new error occurred. I don't know how to solve it. I suspect that there is a compatibility issue with the openai interface of langchain. The error message is as follows:
D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\pydantic\main.py:390: UserWarning: Pydantic serializer warnings:
Expected ChoiceDeltaToolCall but got list with value [ChoiceDeltaToolCall(inde...ply'), type='function')] - serialized value may not be as expected
return self.__pydantic_serializer__.to_python(
Traceback (most recent call last):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\tests\test1.py", line 47, in
print(agent_executor.invoke({"input": query}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\chains\base.py", line 170, in invoke
raise e
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\chains\base.py", line 160, in invoke
self._call(inputs, run_manager=run_manager)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1629, in _call
next_step_output = self._take_next_step(
^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1335, in _take_next_step
[
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1335, in
[
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 1363, in _iter_next_step
output = self._action_agent.plan(
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain\agents\agent.py", line 580, in plan
for chunk in self.runnable.stream(inputs, config={"callbacks": callbacks}):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3405, in stream
yield from self.transform(iter([input]), config, kwargs)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3392, in transform
yield from self._transform_stream_with_config(
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 2193, in _transform_stream_with_config
chunk: Output = context.run(next, iterator) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 3355, in _transform
yield from final_pipeline
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 1409, in transform
for ichunk in input:
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 5550, in transform
yield from self.bound.transform(
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\runnables\base.py", line 1427, in transform
yield from self.stream(final, config, kwargs)
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\language_models\chat_models.py", line 418, in stream
raise e
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_core\language_models\chat_models.py", line 398, in stream
for chunk in self._stream(messages, stop=stop, **kwargs):
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_openai\chat_models\base.py", line 627, in _stream
generation_chunk = _convert_chunk_to_generation_chunk(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_openai\chat_models\base.py", line 309, in _convert_chunk_to_generation_chunk
message_chunk = _convert_delta_to_message_chunk(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_openai\chat_models\base.py", line 248, in _convert_delta_to_message_chunk
tool_call_chunks = [
^
File "D:\workSpace\algorithm-platform\project\gdsf\llm\venv_test\Lib\site-packages\langchain_openai\chat_models\base.py", line 250, in
name=rtc["function"].get("name"),
TypeError: list indices must be integers or slices, not str
System Info
System Information
OS: Windows
OS Version: 10.0.19045
Python Version: 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]
Checked other resources
Example Code
The following code is copied from the example provided by langchain to test this problem. ChatOpenAI uses the local environment deployed by xinference
Error Message and Stack Trace (if applicable)
无
Description
Executing the code provided above will result in an error:
This error was solved by setting the environment variable DEFER_PYDANTIC_BUILD=0. However, when I executed it again, a new error occurred. I don't know how to solve it. I suspect that there is a compatibility issue with the openai interface of langchain. The error message is as follows:
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies