LlamaIndex Beginner’s Journey

Ronghui Ryan Ye
Level Up Coding
Published in
2 min readApr 29, 2024

--

With AI/LLM technology rapidly transforming the world, it’s only logical to embrace the trend. While diving into AI from scratch might seem daunting, opting for a widely used framework such as LlamaIndex is a more practical choice to kickstart my LLM journey. As this field is entirely new to me, I’ll begin by installing essentials like Python 3, pip3, LlamaIndex, and so forth.

I’ve downloaded Python 3 from the official site at https://www.python.org/downloads/macos/, which installed Python 3.12.0 on my Mac. Following this, I utilized python3 -m ensurepip to install pip. Then, I proceeded to install LlamaIndex using pip install llama-index. By default, LlamaIndex utilizes the OpenAI GPT-3.5-turbo model for text generation and text-embedding-ada-002 for retrieval and embeddings. To utilize this functionality, it’s necessary to set up an OPENAI_API_KEY environment variable. You can obtain an API key by logging into your OpenAI account and generating a new API key. Copy this API key and store it as the OPENAI_API_KEY environment variable, then update your .zshrc file with this information. Now you are ready for LlamaIndex development.

Get OpenAI API Key

Subsequently, we’ll adhere to the guidelines outlined on the LlamaIndex official website to compose the “hello world” program using just five lines of code, as instructed. https://docs.llamaindex.ai/en/stable/getting_started/starter_example/

If you’re using the free version of OpenAI, you’ll likely encounter the following error. Please ensure that your billing method is up to date and that there’s a sufficient balance available to utilize the service.

Error Code 429 — You exceeded your current quota, please check your plan and billing details.

Happy coding!

Reference:

https://docs.llamaindex.ai/en/stable/

--

--