Spaces:
Running
Running
File size: 1,620 Bytes
5e8c4c6 0cc2205 5e8c4c6 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 d58dec6 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 0cc2205 32dc4e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
---
title: README
emoji: 🦙
colorFrom: yellow
colorTo: purple
sdk: static
pinned: false
---
# 🗂️ LlamaIndex 🦙
LlamaIndex (GPT Index) is a project that provides a central interface to connect your LLM's with external data.
PyPI:
- LlamaIndex: https://pypi.org/project/llama-index/.
- GPT Index (duplicate): https://pypi.org/project/gpt-index/.
Documentation: https://gpt-index.readthedocs.io/.
Twitter: https://twitter.com/llama_index.
Discord: https://discord.gg/dGcwcsnxhU.
### Ecosystem
- LlamaHub (community library of data loaders): https://llamahub.ai
- LlamaLab (cutting-edge AGI projects using LlamaIndex): https://github.com/run-llama/llama-lab
## 💻 Example Usage
```
pip install llama-index
```
Examples are in the `examples` folder. Indices are in the `indices` folder (see list of indices below).
To build a simple vector store index:
```python
import os
os.environ["OPENAI_API_KEY"] = 'YOUR_OPENAI_API_KEY'
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader
documents = SimpleDirectoryReader('data').load_data()
index = GPTVectorStoreIndex.from_documents(documents)
```
To query:
```python
query_engine = index.as_query_engine()
query_engine.query("<question_text>?")
```
By default, data is stored in-memory.
To persist to disk (under `./storage`):
```python
index.storage_context.persist()
```
To reload from disk:
```python
from llama_index import StorageContext, load_index_from_storage
# rebuild storage context
storage_context = StorageContext.from_defaults(persist_dir='./storage')
# load index
index = load_index_from_storage(storage_context)
```
|