Find answers from the community

Updated 4 months ago

Syntax error

At a glance

The community member is trying to get the LlamaIndex library up and running, but is encountering a syntax error when running a query. The comments suggest that the issue is likely due to a specific line or file, and provide some potential solutions, such as installing the library from PyPI instead of the source code, and providing sample code that should work. However, there is no explicitly marked answer in the comments.

Useful resources
not running any debugger. Context is the following:
  1. Goal of trying to get LlamaIndex up an running and to run a successful query
  2. Git cloned https://github.com/jerryjliu/llama_index
  3. Navigated to llama_index/examples/paul_graham_essay
  4. Created py file per instructions here: https://gpt-index.readthedocs.io/en/latest/getting_started/starter_example.html. py file is in the paul_graham_essay directory
  5. Ran response = index.query("What did the author do growing up?")
print(response)
  1. Got syntax error
L
3 comments
Right, but the syntax error is probably pointing to a particular line or file πŸ‘

Makes it easier to debug once we know the line that has the error πŸ’ͺ
As far as I can tell, your code should be working

Plain Text
from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader('./data').load_data()
index = GPTSimpleVectorIndex.from_documents(documents)
(You might have better luck installing from pypi rather than source pip install --upgrade llama_index)
Add a reply
Sign up and join the conversation on Discord