如何正确导入llama-index类?

huangapple go评论93阅读模式
英文:

How to properly import llama-index classes?

问题

最近,我在使用Llama Index进行一些PoC项目。我正在按照文档中的说明来使用不同索引的路由功能。我创建了两个索引,想要使用SubQueryEngine来路由我创建的查询引擎。

在教程中,我们有以下导入示例:

from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
from llama_index.tools import QueryEngineTool, ToolMetadata
from llama_index.query_engine import SubQuestionQueryEngine

但当我运行我的示例时,我无法导入ToolMetadata和SubQuestionQueryEngine。我遇到了以下错误:

ImportError: cannot import name 'SubQuestionQueryEngine' from 'llama_index.query_engine'

有谁知道可能出现的问题是什么?其他导入工作正常,我能够运行使用GPTVectorStoreIndex类的示例。

我正在使用Python 3.10.11

英文:

Recently I making some PoCs using Llama Index.

I'm following the documentation in order to use routing features for different indexes. I made two indexes and I want to use SubQueryEngine to route the query engines that I have created.

In the tutorial, we have the following example of imports:

from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
from llama_index.tools import QueryEngineTool, ToolMetadata
from llama_index.query_engine import SubQuestionQueryEngine

But when I run my example, I'm not able to import ToolMetadata neither SubQuestionQueryEngine. I got the following error:

ImportError: cannot import name 'SubQuestionQueryEngine' from 'llama_index.query_engine'

Does anybody know what possible can be the problem? The other imports work normaly and I was able to run examples using GPTVectorStoreIndex class.

I'm using Python 3.10.11

答案1

得分: 1

请提供您正在使用的llama-index版本。

一个简单的修复方法是:pip install -U llama-index。我经常遇到由于库的持续更新而引起的问题。我建议每天更新它,以确保您使用的是最新版本。

英文:

Please provide the version of llama-index that you are using.

A simple fix would be: pip install -U llama-index. I frequently encounter issues due to the continuous updates of the library. I would suggest updating it every day just to make sure you are using the latest version.

huangapple
  • 本文由 发表于 2023年6月1日 00:01:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375382.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定