Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ from utils import (
|
|
6 |
parse_pdf,
|
7 |
parse_txt,
|
8 |
parse_csv,
|
9 |
-
parse_pptx,
|
10 |
search_docs,
|
11 |
embed_docs,
|
12 |
text_to_docs,
|
@@ -22,7 +21,7 @@ def clear_submit():
|
|
22 |
def set_openai_api_key(api_key: str):
|
23 |
st.session_state["OPENAI_API_KEY"] = api_key
|
24 |
|
25 |
-
st.markdown('<h1>File GPT </h1>', unsafe_allow_html=True)
|
26 |
|
27 |
# Sidebar
|
28 |
index = None
|
@@ -40,7 +39,7 @@ with st.sidebar:
|
|
40 |
|
41 |
uploaded_file = st.file_uploader(
|
42 |
"Upload a pdf, docx, or txt file",
|
43 |
-
type=["pdf", "docx", "txt", "csv"
|
44 |
help="Scanned documents are not supported yet!",
|
45 |
on_change=clear_submit,
|
46 |
)
|
@@ -54,13 +53,10 @@ with st.sidebar:
|
|
54 |
doc = parse_csv(uploaded_file)
|
55 |
elif uploaded_file.name.endswith(".txt"):
|
56 |
doc = parse_txt(uploaded_file)
|
57 |
-
elif uploaded_file.name.endswith(".pptx"):
|
58 |
-
doc = parse_pptx(uploaded_file)
|
59 |
else:
|
60 |
st.error("File type not supported")
|
61 |
doc = None
|
62 |
text = text_to_docs(doc)
|
63 |
-
st.write(text)
|
64 |
try:
|
65 |
with st.spinner("Indexing document... This may take a while⏳"):
|
66 |
index = embed_docs(text)
|
@@ -68,9 +64,25 @@ with st.sidebar:
|
|
68 |
except OpenAIError as e:
|
69 |
st.error(e._message)
|
70 |
|
71 |
-
tab1 = st.tabs(["Chat with the File"])
|
72 |
-
|
73 |
with tab1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
st.write('To obtain an API Key you must create an OpenAI account at the following link: https://openai.com/api/')
|
75 |
if 'generated' not in st.session_state:
|
76 |
st.session_state['generated'] = []
|
|
|
6 |
parse_pdf,
|
7 |
parse_txt,
|
8 |
parse_csv,
|
|
|
9 |
search_docs,
|
10 |
embed_docs,
|
11 |
text_to_docs,
|
|
|
21 |
def set_openai_api_key(api_key: str):
|
22 |
st.session_state["OPENAI_API_KEY"] = api_key
|
23 |
|
24 |
+
st.markdown('<h1>File GPT 🤖<small> by <a href="https://codegpt.co">Code GPT</a></small></h1>', unsafe_allow_html=True)
|
25 |
|
26 |
# Sidebar
|
27 |
index = None
|
|
|
39 |
|
40 |
uploaded_file = st.file_uploader(
|
41 |
"Upload a pdf, docx, or txt file",
|
42 |
+
type=["pdf", "docx", "txt", "csv"],
|
43 |
help="Scanned documents are not supported yet!",
|
44 |
on_change=clear_submit,
|
45 |
)
|
|
|
53 |
doc = parse_csv(uploaded_file)
|
54 |
elif uploaded_file.name.endswith(".txt"):
|
55 |
doc = parse_txt(uploaded_file)
|
|
|
|
|
56 |
else:
|
57 |
st.error("File type not supported")
|
58 |
doc = None
|
59 |
text = text_to_docs(doc)
|
|
|
60 |
try:
|
61 |
with st.spinner("Indexing document... This may take a while⏳"):
|
62 |
index = embed_docs(text)
|
|
|
64 |
except OpenAIError as e:
|
65 |
st.error(e._message)
|
66 |
|
67 |
+
tab1, tab2 = st.tabs(["Intro", "Chat with the File"])
|
|
|
68 |
with tab1:
|
69 |
+
st.markdown("### How does it work?")
|
70 |
+
st.markdown('Read the article to know how it works: [Medium Article]("https://medium.com/@dan.avila7")')
|
71 |
+
st.write("File GPT was written with the following tools:")
|
72 |
+
st.markdown("#### Code GPT")
|
73 |
+
st.write("All code was written with the help of Code GPT. Visit [codegpt.co]('https://codegpt.co') to get the extension.")
|
74 |
+
st.markdown("#### Streamlit")
|
75 |
+
st.write("The design was written with [Streamlit]('https://streamlit.io/').")
|
76 |
+
st.markdown("#### LangChain")
|
77 |
+
st.write("Question answering with source [Langchain QA]('https://langchain.readthedocs.io/en/latest/use_cases/question_answering.html#adding-in-sources').")
|
78 |
+
st.markdown("#### Embedding")
|
79 |
+
st.write('[Embedding]("https://platform.openai.com/docs/guides/embeddings") is done via the OpenAI API with "text-embedding-ada-002"')
|
80 |
+
st.markdown("""---""")
|
81 |
+
st.write('Author: [Daniel Ávila](https://www.linkedin.com/in/daniel-avila-arias/)')
|
82 |
+
st.write('Repo: [Github](https://github.com/davila7/file-gpt)')
|
83 |
+
st.write("This software was developed with Code GPT, for more information visit: https://codegpt.co")
|
84 |
+
|
85 |
+
with tab2:
|
86 |
st.write('To obtain an API Key you must create an OpenAI account at the following link: https://openai.com/api/')
|
87 |
if 'generated' not in st.session_state:
|
88 |
st.session_state['generated'] = []
|