Spaces:
Sleeping
Sleeping
LordFarquaad42
commited on
added temperature and chat history
Browse files
app.py
CHANGED
@@ -14,6 +14,7 @@ schemer = client.get_collection(
|
|
14 |
)
|
15 |
DATA_AVAL: bool = schemer.count() > 0
|
16 |
APP_NAME: str = "Groove-GPT"
|
|
|
17 |
|
18 |
st.title(APP_NAME)
|
19 |
st.header("What is Groovy-GPT?")
|
@@ -22,16 +23,21 @@ st.write("The model is trained on the MIT Scheme textbook and a handful of Discr
|
|
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). Make sure it has money in it ☠️*", 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],
|
@@ -42,12 +48,17 @@ if st.button('Query Database') & (access_key != "") & (user_question != ""):
|
|
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 |
|
53 |
|
|
|
14 |
)
|
15 |
DATA_AVAL: bool = schemer.count() > 0
|
16 |
APP_NAME: str = "Groove-GPT"
|
17 |
+
history: list(str) = []
|
18 |
|
19 |
st.title(APP_NAME)
|
20 |
st.header("What is Groovy-GPT?")
|
|
|
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("Creativity of Model", 0, 2, 1, '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...'):
|
|
|
41 |
# Perform the Chromadb query.
|
42 |
results = schemer.query(
|
43 |
query_texts=[user_question],
|
|
|
48 |
response = openai_client.chat.completions.create(
|
49 |
model="gpt-3.5-turbo",
|
50 |
messages=[
|
51 |
+
{"role": "system", "content": "You are an expert in functional programming in Scheme, with great knowledge on programming paradigms. You wish to teach the user everything you know about programming paradigms in scheme - so you explain everything thoroughly"},
|
52 |
{"role": "user", "content": user_question},
|
53 |
{"role": "assistant", "content": str(documents)},
|
54 |
+
{"role": "assistant", "history": str(history)}
|
55 |
+
],
|
56 |
+
temperature=temperature
|
57 |
)
|
58 |
+
|
59 |
+
history.append({user_question : response.choices[0].message.content})
|
60 |
+
|
61 |
+
st.header("Prof Says ...")
|
62 |
st.write(response.choices[0].message.content)
|
63 |
|
64 |
|