LordFarquaad42 commited on
Commit
dea937a
·
verified ·
1 Parent(s): 2e1fc3a

readability

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -4,6 +4,7 @@ from chromadb.utils import embedding_functions
4
  from sentence_transformers import SentenceTransformer
5
  from openai import OpenAI
6
 
 
7
  client = chromadb.PersistentClient(path="./chromadb/")
8
  MODEL_NAME: str = "mixedbread-ai/mxbai-embed-large-v1" # ~ 0.5 gb
9
  COLLECTION_NAME: str = "scheme"
@@ -16,25 +17,32 @@ DATA_AVAL: bool = schemer.count() > 0
16
  APP_NAME: str = "Groove-GPT"
17
  history = []
18
 
 
19
  st.title(APP_NAME)
20
  st.header("What is Groovy-GPT?")
21
  st.write("Groovy-GPT is a RAG (Retrieval-Augmented Generation) model that uses ChromaDB to retrieve relevant documents and then uses OpenAI's models to generate a response.")
22
  st.write("The model is trained on the MIT Scheme textbook and a handful of Discrete Math and Paradigms related content that Professor Troeger posted")
23
  st.write("Data Avaliable: ", DATA_AVAL)
24
 
 
25
  user_question: str = st.text_area("Enter your groovy questions here")
 
26
  remember_chat_history = st.toggle("Remember This Chat's History")
 
27
  temperature = st.slider(label="Creativity of Model", min_value=0, max_value=2, value=1, step='float')
 
28
  st.markdown("High creativity will make it go crazy - keep it low")
29
 
30
  access_key: str = st.text_input("Enter your gpt key here", type="password")
31
  st.markdown("*For more information about how to get an access key, read [this article](https://platform.openai.com/api-keys). Make sure it has money in it ☠️*", unsafe_allow_html=True)
 
32
  gpt_type: str = st.selectbox(label="Choose GPT Type", options=["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-4-32k-0613", "gpt-4-0613", "gpt-4-0125-preview"], index=0)
33
  st.markdown("*For more information about GPT types, read [this article](https://platform.openai.com/docs/models).*", unsafe_allow_html=True)
34
 
35
  st.divider()
36
 
37
- if st.button('Query Database') & (access_key != "") & (user_question != ""):
 
38
  openai_client = OpenAI(api_key=access_key)
39
 
40
  with st.spinner('Loading...'):
@@ -60,5 +68,7 @@ if st.button('Query Database') & (access_key != "") & (user_question != ""):
60
 
61
  st.header("Prof Says ...")
62
  st.write(response.choices[0].message.content)
 
 
63
 
64
 
 
4
  from sentence_transformers import SentenceTransformer
5
  from openai import OpenAI
6
 
7
+ # CONSTANTS
8
  client = chromadb.PersistentClient(path="./chromadb/")
9
  MODEL_NAME: str = "mixedbread-ai/mxbai-embed-large-v1" # ~ 0.5 gb
10
  COLLECTION_NAME: str = "scheme"
 
17
  APP_NAME: str = "Groove-GPT"
18
  history = []
19
 
20
+ # INFO
21
  st.title(APP_NAME)
22
  st.header("What is Groovy-GPT?")
23
  st.write("Groovy-GPT is a RAG (Retrieval-Augmented Generation) model that uses ChromaDB to retrieve relevant documents and then uses OpenAI's models to generate a response.")
24
  st.write("The model is trained on the MIT Scheme textbook and a handful of Discrete Math and Paradigms related content that Professor Troeger posted")
25
  st.write("Data Avaliable: ", DATA_AVAL)
26
 
27
+ # INPUTS
28
  user_question: str = st.text_area("Enter your groovy questions here")
29
+
30
  remember_chat_history = st.toggle("Remember This Chat's History")
31
+
32
  temperature = st.slider(label="Creativity of Model", min_value=0, max_value=2, value=1, step='float')
33
+
34
  st.markdown("High creativity will make it go crazy - keep it low")
35
 
36
  access_key: str = st.text_input("Enter your gpt key here", type="password")
37
  st.markdown("*For more information about how to get an access key, read [this article](https://platform.openai.com/api-keys). Make sure it has money in it ☠️*", unsafe_allow_html=True)
38
+
39
  gpt_type: str = st.selectbox(label="Choose GPT Type", options=["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-3.5-turbo-0125", "gpt-4-32k-0613", "gpt-4-0613", "gpt-4-0125-preview"], index=0)
40
  st.markdown("*For more information about GPT types, read [this article](https://platform.openai.com/docs/models).*", unsafe_allow_html=True)
41
 
42
  st.divider()
43
 
44
+ # ON BUTTON CLICK
45
+ if st.button('Start Scheming') & (access_key != "") & (user_question != ""):
46
  openai_client = OpenAI(api_key=access_key)
47
 
48
  with st.spinner('Loading...'):
 
68
 
69
  st.header("Prof Says ...")
70
  st.write(response.choices[0].message.content)
71
+ else:
72
+ st.write("Please provide an input and (valid) API key")
73
 
74