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

Added env vars for through lib #61

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
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
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
"customizations": {
"codespaces": {
"openFiles": [
"README.md",
"src/gui.py"
]
},
"vscode": {
"settings": {},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
]
}
},
"updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
"postAttachCommand": {
"server": "streamlit run src/gui.py --server.enableCORS false --server.enableXsrfProtection false"
},
"portsAttributes": {
"8501": {
"label": "Application",
"onAutoForward": "openPreview"
}
},
"forwardPorts": [
8501
]
}
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
COMMUNITY_USER="bhargav"
OPENAI_KEY="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"
COMMUNITY_DAILY_USD="1"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/__pycache__
**/*secret*.*
data/**
venv/
46 changes: 46 additions & 0 deletions program_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# program_data.py

# Custom table plan for ELEENG-BS (Electrical Engineering)
eleeng_bs_plan = {
"Semester 1": {
"Required Courses": ["Course A", "Course B"],
"Electives": ["Elective X", "Elective Y"],
"Additional Notes": "Place Course A in the first semester."
},
"Semester 2": {
"Required Courses": ["Course C", "Course D"],
"Electives": ["Elective Z"],
"Additional Notes": "Course D is a prerequisite for Course E."
},
# Continue for all 8 semesters
}

# Custom table plan for BIOLOGY-BS (Biology)
biology_bs_plan = {
"Semester 1": {
"Required Courses": ["Intro to Biology", "Chemistry 101"],
"Electives": ["General Education Elective X"],
"Additional Notes": "Complete Biology lab in Semester 2."
},
"Semester 2": {
"Required Courses": ["Biology Lab", "Chemistry 102"],
"Electives": ["General Education Elective Y"],
"Additional Notes": "Course C is a prerequisite for Course D."
},
# Continue for all semesters
}

# Custom table plan for CSCIENCE-BS (Computer Science)
cscience_bs_plan = {
"Semester 1": {
"Required Courses": ["Intro to Computer Science", "Discrete Math"],
"Electives": ["General Education Elective A"],
"Additional Notes": "Start with fundamental courses."
},
"Semester 2": {
"Required Courses": ["Data Structures", "Computer Architecture"],
"Electives": ["General Education Elective B"],
"Additional Notes": "Course X is a prerequisite for Course Y."
},
# Continue for all semesters
}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pycryptodome
boto3
redis
retry
python-dotenv
1 change: 1 addition & 0 deletions src/css.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
v1 = """

/* feedback checkbox */
.css-18fuwiq {
position: relative;
Expand Down
44 changes: 24 additions & 20 deletions src/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__version__ = "0.4.8.3"
app_name = "Ask my PDF"
__version__ = "1.0"
app_name = "EduXGPT"


# BOILERPLATE
Expand All @@ -25,6 +25,11 @@

from time import time as now

import os
from dotenv import load_dotenv

load_dotenv()

# HANDLERS

def on_api_key_change():
Expand Down Expand Up @@ -60,23 +65,22 @@ def ui_spacer(n=2, line=False, next_n=0):

def ui_info():
st.markdown(f"""
# Ask my PDF
# EduXGPT
version {__version__}

Question answering system built on top of GPT3.
Degree Scheduling using GPT3.
""")
ui_spacer(1)
st.write("Made by [Maciej Obarski](https://www.linkedin.com/in/mobarski/).", unsafe_allow_html=True)
st.write("Made by [EduX Team](https://www.edux.ai).", unsafe_allow_html=True)
ui_spacer(1)
st.markdown("""
Thank you for your interest in my application.
Please be aware that this is only a Proof of Concept system
We value your feedback on our application.
Please be aware that this is in Beta
and may contain bugs or unfinished features.
If you like this app you can ❤️ [follow me](https://twitter.com/KerbalFPV)
on Twitter for news and updates.
Your graduation is our priority, we are working dilligently to remove unwanted stress and issues in your pathway. ❤️
""")
ui_spacer(1)
st.markdown('Source code can be found [here](https://github.com/mobarski/ask-my-pdf).')
st.markdown('Check out our documentation [here](https://www.edux.ai/docs/product/getting-started/introduction).')

def ui_api_key():
if ss['community_user']:
Expand Down Expand Up @@ -120,7 +124,7 @@ def debug_index():
ss['debug']['index'] = d

def ui_pdf_file():
st.write('## 2. Upload or select your PDF file')
st.write('## 2. Upload your Academic PDF Audit')
disabled = not ss.get('user') or (not ss.get('api_key') and not ss.get('community_pct',0))
t1,t2 = st.tabs(['UPLOAD','SELECT'])
with t1:
Expand Down Expand Up @@ -188,9 +192,9 @@ def ui_hyde_prompt():
st.text_area('HyDE prompt', prompts.HYDE, key='hyde_prompt')

def ui_question():
st.write('## 3. Ask questions'+(f' to {ss["filename"]}' if ss.get('filename') else ''))
st.write('## 3. List Course Preferences and Schedule Limitations'+(f' to {ss["filename"]}' if ss.get('filename') else ''))
disabled = False
st.text_area('question', key='question', height=100, placeholder='Enter question here', help='', label_visibility="collapsed", disabled=disabled)
st.text_area('question', key='question', height=100, placeholder='Enter text here', help='', label_visibility="collapsed", disabled=disabled)

# REF: Hypotetical Document Embeddings
def ui_hyde_answer():
Expand All @@ -216,14 +220,14 @@ def b_ask():
ss['feedback'].send(-1, ss, details=ss['send_details'])
ss['feedback_score'] = ss['feedback'].get_score()
score = ss.get('feedback_score',0)
c5.write(f'feedback score: {score}')
c4.checkbox('send details', True, key='send_details',
help='allow question and the answer to be stored in the ask-my-pdf feedback database')
c5.write(f'Paths Calculated: {score}')
c4.checkbox('Analytics', True, key='send_details',
help='Allow your PDF Degree Audit data to be used towards our research')
#c1,c2,c3 = st.columns([1,3,1])
#c2.radio('zzz',['👍',r'...',r'👎'],horizontal=True,label_visibility="collapsed")
#
disabled = (not ss.get('api_key') and not ss.get('community_pct',0)) or not ss.get('index')
if c1.button('get answer', disabled=disabled, type='primary', use_container_width=True):
if c1.button('Calculate Route', disabled=disabled, type='primary', use_container_width=True):
question = ss.get('question','')
temperature = ss.get('temperature', 0.0)
hyde = ss.get('use_hyde')
Expand Down Expand Up @@ -281,8 +285,8 @@ def b_save():
api_key = ss.get('api_key')
disabled = not api_key or not db or not index or not name
help = "The file will be stored for about 90 days. Available only when using your own API key."
if st.button('save encrypted index in ask-my-pdf', disabled=disabled, help=help):
with st.spinner('saving to ask-my-pdf'):
if st.button('Save encrypted data to EduX Database', disabled=disabled, help=help):
with st.spinner('Saving to EduX'):
db.put(name, index)

def b_delete():
Expand All @@ -306,7 +310,7 @@ def output_add(q,a):
with st.sidebar:
ui_info()
ui_spacer(2)
with st.expander('advanced'):
with st.expander('Advanced (For Developers)'):
ui_show_debug()
b_clear()
ui_model()
Expand Down
10 changes: 3 additions & 7 deletions src/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@

TASK = {
'v6': (
"Answer the question truthfully based on the text below. "
"Include verbatim quote and a comment where to find it in the text (page number). "
#"After the quote write a step by step explanation in a new paragraph. "
"After the quote write a step by step explanation. "
"Use bullet points. "
#"After that try to rephrase the original question so it might give better results. "
),
"Create a UI table from the PDF that lists: Full Name (usually under 'Prepared:'), Student ID (across 'Prepared:'), Program code (without '(Page 1)'), Graduation date (without '(Page 1)'), GPA (without '(Page 1)') and Catalog year (is underneath Graduation Date and without '(Page 1)'). "
"Create another UI table underneath and fill in the table from the specific data from this PDF including General University Requirements, Core Courses, Electives, and fill in the table with class name, credits, and whether completed or incomplete (based on OK or NO). Group the courses such as Core courses together separate from the electives, and general education classes and also include the grade received (if the grade is C- or better it's considered OK)."
),
'v5': (
"Answer the question truthfully based on the text below. "
"Include at least one verbatim quote (marked with quotation marks) and a comment where to find it in the text (ie name of the section and page number). "
Expand Down