Skip to content

Commit 0326b53

Browse files
Merge pull request #1 from tylerjrichards/main
Updated Streamlit Example, deployed app link added to readme
2 parents 0b752e4 + dedfe07 commit 0326b53

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.envrc
2+
.direnv
3+
.streamlit/secrets.toml
4+
.mypy_cache

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# llama_index_starter_pack
2-
This repository provides very basic flask, streamlit, and docker examples for the [llama_index](https://github.com/jerryjliu/gpt_index) (FKA gpt_index) package.
2+
This repository provides very basic flask, [Streamlit](https://llama-index.streamlit.app/), and docker examples for the [llama_index](https://github.com/jerryjliu/gpt_index) (FKA gpt_index) package.
33

44
If you need to quickly create a POC to impress your boss, start here!
55

@@ -20,13 +20,14 @@ There are two main example files
2020
- creates a simple api that loads the text from the documents folder
2121
- The "/query" endpoint accepts requests that contain a "text" parameter, which is used to query the index
2222
- resturns string response containing the query answer
23-
23+
2424
- streamlit_demo.py (localhost:8501)
2525
- `streamlit run streamlit_demo.py`
2626
- creates a simple UI using streamlit
2727
- loads text from the documents folder (using `st.cache_resource`, so it only loads once)
2828
- provides an input text-box and a button to run the query
2929
- The string response is displayed after it finishes
30+
- Want to see this example in action? Check it out [here](https://llama-index.streamlit.app/)
3031

3132

3233
## Docker

streamlit_demo.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import os
22

3+
import streamlit as st
4+
from llama_index import GPTSimpleVectorIndex, SimpleDirectoryReader
5+
36
# NOTE: for local testing only, do NOT deploy with your key hardcoded
4-
os.environ['OPENAI_API_KEY'] = "your_key_here"
7+
# to use this for yourself, create a file called .streamlit/secrets.toml with your api key
8+
# Learn more about Streamlit on the docs: https://docs.streamlit.io/
9+
os.environ["OPENAI_API_KEY"] = st.secrets["openai_api_key"]
510

6-
import streamlit as st
7-
from llama_index import SimpleDirectoryReader, GPTSimpleVectorIndex
811

912
index_name = "./index.json"
1013
documents_folder = "./documents"
@@ -32,15 +35,12 @@ def query_index(_index, query_text):
3235
index = initialize_index(index_name, documents_folder)
3336

3437

35-
st.title("Llama Index")
36-
37-
st.header("Welcome to the Llama Index streamlit")
38-
39-
st.text("Please enter a query about Paul Graham's essay?")
38+
st.title("🦙 Llama Index Demo 🦙")
39+
st.header("Welcome to the Llama Index Streamlit Demo")
40+
st.text("Please enter a query about Paul Graham's essays")
4041

4142
text = st.text_input("Query text:")
4243

4344
if st.button("Run Query") and text is not None:
4445
response = query_index(index, text)
4546
st.markdown(response)
46-

0 commit comments

Comments
 (0)