Spaces:
Runtime error
Runtime error
Add multiple pages (#22)
Browse files- app.py → GnosisPages.py +0 -0
- README.md +2 -2
- gnosis/builder.py +0 -1
- gnosis/components/sidebar.py +5 -5
- pages/01_How_to_use.py +33 -0
- pages/02_About.py +19 -0
- pages/images/01_Add_API_Key.png +0 -0
- pages/images/02_Upload_PDF.png +0 -0
- pages/images/03_Save_Chunks.png +0 -0
- pages/images/04_Consult_KB.png +0 -0
- pages/images/05_Use_Wikipedia.png +0 -0
- pages/images/06_Creativity.PNG +0 -0
- pages/images/07_Delete_Collection.PNG +0 -0
app.py → GnosisPages.py
RENAMED
|
File without changes
|
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 📝
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
-
app_file:
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
| 10 |
---
|
|
@@ -69,7 +69,7 @@ Follow the next steps to set up GnosisPages in your local environment:
|
|
| 69 |
```
|
| 70 |
6. Run on your local environment
|
| 71 |
```bash
|
| 72 |
-
streamlit run
|
| 73 |
```
|
| 74 |
|
| 75 |
## Deployment
|
|
|
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: pink
|
| 6 |
sdk: streamlit
|
| 7 |
+
app_file: GnosisPages.py
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
| 10 |
---
|
|
|
|
| 69 |
```
|
| 70 |
6. Run on your local environment
|
| 71 |
```bash
|
| 72 |
+
streamlit run GnosisPages.py
|
| 73 |
```
|
| 74 |
|
| 75 |
## Deployment
|
gnosis/builder.py
CHANGED
|
@@ -8,7 +8,6 @@ def build(key, client):
|
|
| 8 |
"""An Agent builder"""
|
| 9 |
# Build Agent
|
| 10 |
try:
|
| 11 |
-
print(str(st.session_state.temperature))
|
| 12 |
llm = ChatOpenAI(
|
| 13 |
temperature=st.session_state.temperature,
|
| 14 |
model="gpt-3.5-turbo-16k",
|
|
|
|
| 8 |
"""An Agent builder"""
|
| 9 |
# Build Agent
|
| 10 |
try:
|
|
|
|
| 11 |
llm = ChatOpenAI(
|
| 12 |
temperature=st.session_state.temperature,
|
| 13 |
model="gpt-3.5-turbo-16k",
|
gnosis/components/sidebar.py
CHANGED
|
@@ -8,11 +8,11 @@ def delete_collection(client, collection):
|
|
| 8 |
"""Delete collection button."""
|
| 9 |
if st.button("Delete collection"):
|
| 10 |
st.warning("Are you sure?")
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
|
| 18 |
def openai_api_key_box():
|
|
|
|
| 8 |
"""Delete collection button."""
|
| 9 |
if st.button("Delete collection"):
|
| 10 |
st.warning("Are you sure?")
|
| 11 |
+
if st.button("Yes"):
|
| 12 |
+
try:
|
| 13 |
+
client.delete_collection(collection.name)
|
| 14 |
+
except AttributeError:
|
| 15 |
+
st.error("Collection erased.")
|
| 16 |
|
| 17 |
|
| 18 |
def openai_api_key_box():
|
pages/01_How_to_use.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Instructions on how to use the website"""
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
# Title of the page
|
| 5 |
+
st.title("How to use this website")
|
| 6 |
+
st.markdown(
|
| 7 |
+
"1. **Add your OpenAI API key**: You can get it from [here](https://beta.openai.com/).",
|
| 8 |
+
unsafe_allow_html=True,
|
| 9 |
+
)
|
| 10 |
+
st.image(image="pages/images/01_Add_API_Key.png", caption="Add your OpenAI API key")
|
| 11 |
+
st.markdown(
|
| 12 |
+
"2. **Upload a PDF file**: It should be a PDF file with text. Scanned pages are not supported."
|
| 13 |
+
)
|
| 14 |
+
st.image(image="pages/images/02_Upload_PDF.png", caption="Upload a PDF file")
|
| 15 |
+
st.markdown(
|
| 16 |
+
"3. **Save chunks**: Text is extracted, splitted and save in chunks on ChromaDB."
|
| 17 |
+
)
|
| 18 |
+
st.image(image="pages/images/03_Save_Chunks.png", caption="Save chunks")
|
| 19 |
+
st.markdown(
|
| 20 |
+
"4. **Consult your knowledge base**: You can consult your knowledge base with the chatbot."
|
| 21 |
+
)
|
| 22 |
+
st.image(image="pages/images/04_Consult_KB.png", caption="Consult your knowledge base")
|
| 23 |
+
st.markdown(
|
| 24 |
+
"5. **Use Wikipedia**: You can use Wikipedia to enrich your knowledge base."
|
| 25 |
+
)
|
| 26 |
+
st.image(image="pages/images/05_Use_Wikipedia.png", caption="Use Wikipedia")
|
| 27 |
+
st.markdown(
|
| 28 |
+
'6. **Change creativity level**: Also called "temperature". As higher, more unexpected results.'
|
| 29 |
+
)
|
| 30 |
+
st.image(image="pages/images/06_Creativity.png", caption="Change creativity level")
|
| 31 |
+
st.markdown("7. **Delete collection**: You can delete your collection and start over.")
|
| 32 |
+
st.image(image="pages/images/07_Delete_Collection.png", caption="Delete collection")
|
| 33 |
+
st.write("That's all! Enjoy!")
|
pages/02_About.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Collection's Page"""
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import openai
|
| 4 |
+
from gnosis.chroma_client import ChromaDB
|
| 5 |
+
|
| 6 |
+
chroma_db = ChromaDB(openai.api_key)
|
| 7 |
+
|
| 8 |
+
st.header("About")
|
| 9 |
+
|
| 10 |
+
# A summary of the project
|
| 11 |
+
st.write(
|
| 12 |
+
"""
|
| 13 |
+
GnosisPages was developed by
|
| 14 |
+
[J.P. Pérez Tejada](https://www.linkedin.com/in/juanpaulopereztejada/). December, 2023.
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
Check the [GitHub repository](https://github.com/maclenn77/pdf-explainer) for more information.
|
| 18 |
+
"""
|
| 19 |
+
)
|
pages/images/01_Add_API_Key.png
ADDED
|
pages/images/02_Upload_PDF.png
ADDED
|
pages/images/03_Save_Chunks.png
ADDED
|
pages/images/04_Consult_KB.png
ADDED
|
pages/images/05_Use_Wikipedia.png
ADDED
|
pages/images/06_Creativity.PNG
ADDED
|
|
pages/images/07_Delete_Collection.PNG
ADDED
|
|