Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #28

Closed
wants to merge 5 commits into from
Closed

Main #28

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app.py → GnosisPages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=invalid-name
""" A Streamlit app for GnosisPages. """
import os
import streamlit as st
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ emoji: 📝
colorFrom: red
colorTo: pink
sdk: streamlit
app_file: app.py
app_file: GnosisPages.py
pinned: false
license: mit
---
Expand All @@ -27,6 +27,10 @@ GnosisPages offers you the following key features:

[Watch a demo here](https://youtu.be/OEQTusJGHFQ)

## Architecture

![schematic-1](https://github.com/Maclenn77/pdf-explainer/assets/1808402/36dbacfa-43f3-4530-9d31-0e9b1127f992)

## Prerrequisites

For using the demo, you only need an OpenAI API Key.
Expand Down Expand Up @@ -69,7 +73,7 @@ Follow the next steps to set up GnosisPages in your local environment:
```
6. Run on your local environment
```bash
streamlit run app.py
streamlit run GnosisPages.py
```

## Deployment
Expand Down
5 changes: 2 additions & 3 deletions gnosis/builder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
"""Module for building the Langchain Agent"""
import streamlit as st
from langchain.chat_models import ChatOpenAI
from langchain_openai import ChatOpenAI
from gnosis.agent import PDFExplainer


def build(key, client):
"""An Agent builder"""
# Build Agent
try:
print(str(st.session_state.temperature))
llm = ChatOpenAI(
temperature=st.session_state.temperature,
model="gpt-3.5-turbo-16k",
model="gpt-4o-mini",
api_key=key,
)
agent = PDFExplainer(
Expand Down
10 changes: 5 additions & 5 deletions gnosis/components/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def delete_collection(client, collection):
"""Delete collection button."""
if st.button("Delete collection"):
st.warning("Are you sure?")
if st.button("Yes"):
try:
client.delete_collection(collection.name)
except AttributeError:
st.error("Collection erased.")
if st.button("Yes"):
try:
client.delete_collection(collection.name)
except AttributeError:
st.error("Collection erased.")


def openai_api_key_box():
Expand Down
34 changes: 34 additions & 0 deletions pages/01_How_to_use.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# pylint: disable=invalid-name
"""Instructions on how to use the website"""
import streamlit as st

# Title of the page
st.title("How to use this website")
st.markdown(
"1. **Add your OpenAI API key**: You can get it from [here](https://beta.openai.com/).",
unsafe_allow_html=True,
)
st.image(image="pages/images/01_Add_API_Key.png", caption="Add your OpenAI API key")
st.markdown(
"2. **Upload a PDF file**: It should be a PDF file with text. Scanned pages are not supported."
)
st.image(image="pages/images/02_Upload_PDF.png", caption="Upload a PDF file")
st.markdown(
"3. **Save chunks**: Text is extracted, splitted and save in chunks on ChromaDB."
)
st.image(image="pages/images/03_Save_Chunks.png", caption="Save chunks")
st.markdown(
"4. **Consult your knowledge base**: You can consult your knowledge base with the chatbot."
)
st.image(image="pages/images/04_Consult_KB.png", caption="Consult your knowledge base")
st.markdown(
"5. **Use Wikipedia**: You can use Wikipedia to enrich your knowledge base."
)
st.image(image="pages/images/05_Use_Wikipedia.png", caption="Use Wikipedia")
st.markdown(
'6. **Change creativity level**: Also called "temperature". As higher, more unexpected results.'
)
st.image(image="pages/images/06_Creativity.png", caption="Change creativity level")
st.markdown("7. **Delete collection**: You can delete your collection and start over.")
st.image(image="pages/images/07_Delete_Collection.png", caption="Delete collection")
st.write("That's all! Enjoy!")
20 changes: 20 additions & 0 deletions pages/02_About.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# pylint: disable=invalid-name
"""Collection's Page"""
import streamlit as st
import openai
from gnosis.chroma_client import ChromaDB

chroma_db = ChromaDB(openai.api_key)

st.header("About")

# A summary of the project
st.write(
"""
GnosisPages was developed by
[J.P. Pérez Tejada](https://www.linkedin.com/in/juanpaulopereztejada/). December, 2023.


Check the [GitHub repository](https://github.com/maclenn77/pdf-explainer) for more information.
"""
)
Binary file added pages/images/01_Add_API_Key.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/02_Upload_PDF.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/03_Save_Chunks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/04_Consult_KB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/05_Use_Wikipedia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/06_Creativity.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/06_Creativity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/07_Delete_Collection.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pages/images/07_Delete_Collection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
openai
tiktoken
langchain
langchain_openai
pymupdf
pypdf
wikipedia
chromadb>='0.4.18'
chromadb
sentence_transformers
streamlit
streamlit
3 changes: 2 additions & 1 deletion wk_flow_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ openai
tiktoken
pylint
langchain
chromadb>='0.4.18'
langchain_openai
chromadb
Loading