Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
747 stars 276 forks source link

llama-index not working #99

Closed daniel-counto closed 3 weeks ago

daniel-counto commented 6 months ago

I am running on google colab with ngrok. I got the following error for running the llama-index cookbook:

Traceback (most recent call last): File "/content/app.py", line 24, in storage_context = StorageContext.from_defaults(persist_dir="./storage") File "/usr/local/lib/python3.10/dist-packages/llama_index/core/storage/storage_context.py", line 107, in from_defaults docstore = docstore or SimpleDocumentStore.from_persist_dir( File "/usr/local/lib/python3.10/dist-packages/llama_index/core/storage/docstore/simple_docstore.py", line 57, in from_persist_dir return cls.from_persist_path(persist_path, namespace=namespace, fs=fs) File "/usr/local/lib/python3.10/dist-packages/llama_index/core/storage/docstore/simple_docstore.py", line 74, in from_persist_path simple_kvstore = SimpleKVStore.from_persist_path(persist_path, fs=fs) File "/usr/local/lib/python3.10/dist-packages/llama_index/core/storage/kvstore/simple_kvstore.py", line 97, in from_persist_path with fs.open(persist_path, "rb") as f: File "/usr/local/lib/python3.10/dist-packages/fsspec/spec.py", line 1241, in open f = self._open( File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 184, in _open return LocalFileOpener(path, mode, fs=self, **kwargs) File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 315, in init self._open() File "/usr/local/lib/python3.10/dist-packages/fsspec/implementations/local.py", line 320, in _open self.f = open(self.path, mode=self.mode) FileNotFoundError: [Errno 2] No such file or directory: '/content/storage/docstore.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/chainlit", line 8, in sys.exit(cli()) File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/chainlit/cli/init.py", line 154, in chainlit_run run_chainlit(target) File "/usr/local/lib/python3.10/dist-packages/chainlit/cli/init.py", line 56, in run_chainlit load_module(config.run.module_name) File "/usr/local/lib/python3.10/dist-packages/chainlit/config.py", line 379, in load_module spec.loader.exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "/content/app.py", line 28, in documents = SimpleDirectoryReader("./data").load_data(show_progress=True) File "/usr/local/lib/python3.10/dist-packages/llama_index/core/readers/file/base.py", line 220, in init raise ValueError(f"Directory {input_dir} does not exist.") ValueError: Directory ./data does not exist.

droid42 commented 1 month ago

I think this should be simple to fix, see the last line: "ValueError: Directory ./data does not exist."

Just create directory "data", as mentioned in the guide https://docs.chainlit.io/integrations/llama-index: "Create a folder named data in the root of your app folder. Download the state of the union file (or any files of your own choice) and place it in the data folder."

The code tries to load the index and if it does not succeed, it tries to index the documents from "./data", which also fails, because the dir does not exist.

ModEnter commented 3 weeks ago

I fixed the link in the doc to download the state of the union file. I'm closing the issue, feel free to ask technical questions on the Chainlit Discord server to interact directly with the Chainlit community ⚡