----------------------
To retrieve available indices from LlamaCloud, you can use the
LlamaCloudIndex
and
LlamaCloudRetriever
classes provided by LlamaIndex. Here's an example of how you can do it:
First, you need to set your LlamaCloud API key:
import os
os.environ["LLAMA_CLOUD_API_KEY"] = "llx-..." # replace with your actual API key
Then, you can connect to an existing index on LlamaCloud:
from llama_index.indices.managed.llama_cloud import LlamaCloudIndex
# connect to an existing index
index = LlamaCloudIndex("my_first_index", project_name="default")
You can also configure a retriever for managed retrieval:
# from the existing index
index.as_retriever()
# or from scratch
from llama_index.indices.managed.llama_cloud import LlamaCloudRetriever
retriever = LlamaCloudRetriever("my_first_index", project_name="default")
And of course, you can use other index shortcuts to get use out of your new managed index:
query_engine = index.as_query_engine(llm=llm)
chat_engine = index.as_chat_engine(llm=llm)
Please replace
"my_first_index"
and
"default"
with your actual index name and project name.
Source ()
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------