Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ def merge_dataframes(dataframes):
|
|
22 |
|
23 |
return combined_dataframe
|
24 |
|
25 |
-
def call_chatgpt(prompt: str) -> str:
|
26 |
"""
|
27 |
Uses the OpenAI API to generate an AI response to a prompt.
|
28 |
|
@@ -40,7 +40,7 @@ def call_chatgpt(prompt: str) -> str:
|
|
40 |
completion = client.chat.completions.create(
|
41 |
model="gpt-3.5-turbo-0125",
|
42 |
messages=[
|
43 |
-
{"role": "system", "content":
|
44 |
{"role": "user", "content": prompt}
|
45 |
]
|
46 |
)
|
@@ -231,6 +231,14 @@ init_messages = {
|
|
231 |
''',
|
232 |
}
|
233 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
# Embed and store the first N supports for this demo
|
235 |
with st.spinner("Loading, please be patient with us ... 🙏"):
|
236 |
L = len(dataset["train"]["questions"])
|
@@ -294,7 +302,7 @@ if prompt := st.chat_input("Tell me about YSA"):
|
|
294 |
answer the user question: {question}.
|
295 |
"""
|
296 |
|
297 |
-
answer = call_chatgpt(engineered_prompt)
|
298 |
|
299 |
response = answer
|
300 |
# Display assistant response in chat message container
|
|
|
22 |
|
23 |
return combined_dataframe
|
24 |
|
25 |
+
def call_chatgpt(prompt: str, instructions: str) -> str:
|
26 |
"""
|
27 |
Uses the OpenAI API to generate an AI response to a prompt.
|
28 |
|
|
|
40 |
completion = client.chat.completions.create(
|
41 |
model="gpt-3.5-turbo-0125",
|
42 |
messages=[
|
43 |
+
{"role": "system", "content": instructions},
|
44 |
{"role": "user", "content": prompt}
|
45 |
]
|
46 |
)
|
|
|
231 |
''',
|
232 |
}
|
233 |
|
234 |
+
instructions = {
|
235 |
+
"About YSA": 'You are an assistant to help the user learn more about Youth Spirit Artworks.',
|
236 |
+
"Our Team and Youth Leaders": "You are an assistant to help the user learn more about the backgrounds, stories, experiences of Team Members Jimi and Alastair and Youth Leaders Aceeyah, Brandon, Eli, Griffin, Ma'ayon, Reggie, Sean, Inti, Jason, Justin, and Rossi at YSA.",
|
237 |
+
"Tiny House Village": 'You are an assistant to help the user learn more about the Tiny House Village at YSA: its inspiration, how it was built, its goals, its impact, and how people can volunteer and donate.',
|
238 |
+
"Qualify/Apply for Village": 'You are an assistant to help unhoused youth learn about wheter or not they qualify and how to apply for the Tiny House Village. Give clear and concise responses and instructions and include all relevant details. When asked for shelter assistance, direct the user towards an Alameda County Coordinated Entry location.',
|
239 |
+
"YSA Supporters": "You are an assitant to help the user learn more about YSA's suporters. Return a list of supporters depending on the user's request."
|
240 |
+
}
|
241 |
+
|
242 |
# Embed and store the first N supports for this demo
|
243 |
with st.spinner("Loading, please be patient with us ... 🙏"):
|
244 |
L = len(dataset["train"]["questions"])
|
|
|
302 |
answer the user question: {question}.
|
303 |
"""
|
304 |
|
305 |
+
answer = call_chatgpt(engineered_prompt, instructions[domain])
|
306 |
|
307 |
response = answer
|
308 |
# Display assistant response in chat message container
|