• iLeGeND
    2023-09-28 来自湖北
    老师提下代码
    
    1
  • 抽象派
    2023-09-28 来自广东
    使用结构化工具对话代理的实例代码报错,请问怎么改?。具体输出如下: Traceback (most recent call last): File "/Users/abc/project/python/learnlangchain/struct_tool.py", line 17, in <module> agent_chain = initialize_agent( ^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/agents/initialize.py", line 57, in initialize_agent agent_obj = agent_cls.from_llm_and_tools( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/agents/structured_chat/base.py", line 132, in from_llm_and_tools _output_parser = output_parser or cls._get_default_output_parser(llm=llm) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/agents/structured_chat/base.py", line 65, in _get_default_output_parser return StructuredChatOutputParserWithRetries.from_llm(llm=llm) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/agents/structured_chat/output_parser.py", line 82, in from_llm output_fixing_parser = OutputFixingParser.from_llm( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/output_parsers/fix.py", line 45, in from_llm return cls(parser=parser, retry_chain=chain) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/lib/python3.11/site-packages/langchain/load/serializable.py", line 74, in __init__ super().__init__(**kwargs) File "pydantic/main.py", line 339, in pydantic.main.BaseModel.__init__ File "pydantic/main.py", line 1076, in pydantic.main.validate_model File "pydantic/fields.py", line 860, in pydantic.fields.ModelField.validate pydantic.errors.ConfigError: field "retry_chain" not yet prepared so type is still a ForwardRef, you might need to call OutputFixingParser.update_forward_refs().
    展开
    
    1