Try importing it like this:
from llama_index.core.readers import download_loader
also can be imported like this:
from llama_index.core import download_loader
its giving me
zsh: command not found: from
doesnt that mean llama-index is not installed?
which is super weird because it was working until i tried installing the readers separately by accident. Something about that borked my install i think
Wait you meant in the python file
it keeps giving me
ImportError: cannot import name 'download_loader' from 'llama_index.core' (unknown location)
Seems like your llama-index is not properly installed.
- Create a python env
- install pip install llama-index
Then try the example
yeah thats what i figured
any recommendations on which virtual env to use?
I am currently using conda
seems like that might be the root of the issue
So I can see that I have llama-index installed in my homebrew folder
I guess there's a chance I installed it via some other route earlier
So I deactivated conda and created a new regular venv and installed llama-index again
I seem to have upgraded the llama index version, I was on 0.9 before and now its 0.10 i suppose so i need to change an import... reinstalling the core.utils...
and a couple other imports don't seem to be recognized
Like VectorStoreIndex and ServiceContext
I'll take a look at that conda link as well
dont upgrade! Uninstall first and then install as per the given instruction
If I created a brand new venv, and then installed llama-index fresh, it should just be a clean install right?
I didn't specifically use any upgrade command
(So sorry for all the basic questions, I am slowly learning all of this as I go, thanks for your patience)
Ok its finally working again!
I think what i did was accidentally upgrade it the first time, that threw it all out of whack and then i just didn't know how to do a clean install. All good now though.
One final main question, how do I grab the page number from the metadata? When I used the response.source_nodes, I got a wall of text which I believe is the right portion but it doesn't show me the page number.
for source in response.source_nodes:
print(source.node.extra_info)
Ok I'll try that. What would be your recommendation for learning more? There seems to be so many directions to explore and so little guidance for documentation.
And this line goes directly below my actual response line?
Please stop me anytime if I am asking questions which are very simple and require some basic research
You can follow the documentation , each major point is divided into sub sections for easy understanding. You can start from starter_tutorial and once you have enough idea about the core , you can choose any topic and start building πͺ
loader=SimpleDirectoryLoader
raise ValueError("Must provide either input_dir
or input_files
.")
ValueError: Must provide either input_dir
or input_files
.
So this is a new error I'm getting. Its with the SimpleDirectoryLoader. Previously, when I was making new indexes, I would just delete the old files and it would create a new one. I'm assuming that the newer vector store is not being created. Were there any changes in version 0.10 to the simple directory loader?
Oh I think the solution was in your previous message
Yeah its not going through
here is my syntax according to your earlier message
documents = SimpleDirectoryReader(input_files="./data/pdf/document.pdf").load_data()
I think the documentation page needs to be updated as the input files or dir needs to be added now
`documents = SimpleDirectoryReader(input_files=["./data/pdf/document.pdf"]).load_data()
path must be correct and input_files accept list of strs
I think I have the syntax right
I followed the documentation page as well
but now im getting a type error
TypeError: 'method' object is not iterable
Wait i tried again and it worked
input_files is a list
earlier you pass a str into it
Yeah thats the format I followed
And i think its working now
But can you share you code?
reader = SimpleDirectoryReader(input_files=["./data/document.pdf"])
documents = reader.load_data()
index = VectorStoreIndex.from_documents(documents)
Oh boy new problem π ... Its not printing a response
Weirdly I can see the metadata and the source and the page number now but
the response itself is just black
I think i'm done for today and I gotta sleep but thank you for you help for today
If its alright, I might message back on this thread tomorrow
Yeah sleep is important lolπ
@kapa.ai where should I give a callback_manager argument to trace & debug my application?
Let me check the knowledge base for you. One moment! :books:
----------------------
To trace and debug your application using LlamaIndex, you need to provide the
callback_manager
argument when creating an instance of
VectorStoreIndex
. Here's an example of how to do it:
from llama_index.core import VectorStoreIndex
index = VectorStoreIndex.from_documents(docs, callback_manager=callback_manager)
In this example,
docs
is your data and
callback_manager
is an instance of
CallbackManager
that you've set up with the desired handlers. For instance, you might set up a
LlamaDebugHandler
like this:
from llama_index.core.callbacks import CallbackManager, LlamaDebugHandler
llama_debug = LlamaDebugHandler(print_trace_on_end=True)
callback_manager = CallbackManager([llama_debug])
This will allow you to trace and debug your application by logging events as you run queries within LlamaIndex.
For more information, you can refer to the
Llama Debug Handler example () on GitHub.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------