Spaces:
Sleeping
Sleeping
LordFarquaad42
commited on
Commit
•
ab53869
1
Parent(s):
250dba9
added support for more gpt types
Browse files
app.py
CHANGED
@@ -16,29 +16,37 @@ DATA_AVAL: bool = schemer.count() > 0
|
|
16 |
APP_NAME: str = "Groove-GPT"
|
17 |
|
18 |
st.title(APP_NAME)
|
|
|
|
|
|
|
19 |
st.write("Data Avaliable: ", DATA_AVAL)
|
|
|
20 |
user_question: str = st.text_area("Enter your groovy questions here")
|
21 |
access_key: str = st.text_input("Enter your gpt key here", type="password")
|
|
|
|
|
|
|
22 |
|
23 |
if st.button('Query Database') & (access_key != "") & (user_question != ""):
|
24 |
openai_client = OpenAI(api_key=access_key)
|
25 |
|
26 |
-
st.
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
st.write(response.choices[0].message.content)
|
44 |
|
|
|
16 |
APP_NAME: str = "Groove-GPT"
|
17 |
|
18 |
st.title(APP_NAME)
|
19 |
+
st.header("What is Groovy-GPT?")
|
20 |
+
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.")
|
21 |
+
st.write("The model is trained on the MIT Scheme textbook and a handful of Discrete Math and Paradigms related content that Professor Gertner posted")
|
22 |
st.write("Data Avaliable: ", DATA_AVAL)
|
23 |
+
|
24 |
user_question: str = st.text_area("Enter your groovy questions here")
|
25 |
access_key: str = st.text_input("Enter your gpt key here", type="password")
|
26 |
+
st.markdown("*For more information about how to get an access key, read [this article](https://platform.openai.com/api-keys).*", unsafe_allow_html=True)
|
27 |
+
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)
|
28 |
+
st.markdown("*For more information about GPT types, read [this article](https://platform.openai.com/docs/models).*", unsafe_allow_html=True)
|
29 |
|
30 |
if st.button('Query Database') & (access_key != "") & (user_question != ""):
|
31 |
openai_client = OpenAI(api_key=access_key)
|
32 |
|
33 |
+
with st.spinner('Loading...'):
|
34 |
+
st.header("Results")
|
35 |
+
# Perform the Chromadb query.
|
36 |
+
results = schemer.query(
|
37 |
+
query_texts=[user_question],
|
38 |
+
n_results=10,
|
39 |
+
include = ['documents']
|
40 |
+
)
|
41 |
+
documents = results["documents"]
|
42 |
+
response = openai_client.chat.completions.create(
|
43 |
+
model="gpt-3.5-turbo",
|
44 |
+
messages=[
|
45 |
+
{"role": "system", "content": "You are an expert in functional programming in Scheme, with great knowledge on programming paradigms."},
|
46 |
+
{"role": "user", "content": user_question},
|
47 |
+
{"role": "assistant", "content": str(documents)},
|
48 |
+
]
|
49 |
+
)
|
50 |
|
51 |
st.write(response.choices[0].message.content)
|
52 |
|