你好!
晚上好!
似乎https://docs.llamaindex.ai/en/stable/examples/output_parsing/guidance_pydantic_program/文档已经过时了,你能看一下吗?这些示例会抛出异常。
llama-index==0.10.43
llama-index-program-guidance==0.1.2
版本
0.10.43
重现步骤
请检查第3步(导入)的colab。
https://docs.llamaindex.ai/en/stable/examples/output_parsing/guidance_pydantic_program/
相关日志/回溯
ImportError Traceback (most recent call last)
<ipython-input-3-fc0a30d8938f> in <cell line: 1>()
----> 1 from llama_index.question_gen.guidance import GuidanceQuestionGenerator
2 from guidance.llms import OpenAI as GuidanceOpenAI
3 frames
/usr/local/lib/python3.10/dist-packages/llama_index/program/guidance/base.py in <module>
11 from guidance import assistant, gen, user
12 from guidance.models import Model as GuidanceLLM
---> 13 from guidance.models import OpenAIChat
14
15
ImportError: cannot import name 'OpenAIChat' from 'guidance.models' (/usr/local/lib/python3.10/dist-packages/guidance/models/__init__.py)
2条答案
按热度按时间k4aesqcs1#
晚上好,@zeloras!我在这里为您提供任何错误、问题或贡献的帮助。让我们一起解决这个问题!
要解决LlamaIndex包中"Guidance Pydantic Program"文档中的导入错误,请确保在脚本开头正确包含以下导入:
此外,确保您已从
llama_index.program.guidance.base
模块正确导入了GuidancePydanticProgram
类:这些导入对于
GuidancePydanticProgram
类的正常运行是必要的。请确保您的环境中所有导入的模块和类都是可用的。如果缺少这些模块中的任何一个,您可能需要安装它们或检查它们的路径。此外,请确保您正在使用Pydantic的正确版本。
llama_index.core.bridge.pydantic
模块尝试首先导入pydantic.v1
,如果前者不可用,则回退到pydantic
。请确保已安装pydantic.v1
或相应地调整导入:这确保了与
Guidance Pydantic Program
的兼容性并解决了潜在的导入错误1(https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/program/llama-index-program-guidance/llama_index/program/guidance/base.py)2(https://github.com/run-llama/llama_index/blob/main/llama-index-integrations/program/llama-index-program-guidance/llama_index/program/guidance/init.py)3(https://github.com/run-llama/llama_index/blob/main/llama-index-core/llama_index/core/bridge/pydantic.py)4(https://github.com/run-llama/llama_index/blob/main/llama-index-legacy/llama_index/legacy/bridge/pydantic.py)。iyr7buue2#
重复的#13379