Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ retrieval_model_name = 'output/sentence-transformer-finetuned/'
|
|
| 11 |
|
| 12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
| 13 |
|
| 14 |
-
system_message = "You are a
|
| 15 |
# Initial system message to set the behavior of the assistant
|
| 16 |
messages = [{"role": "system", "content": system_message}]
|
| 17 |
|
|
@@ -67,7 +67,7 @@ def generate_response(user_query, relevant_segment):
|
|
| 67 |
Generate a response emphasizing the bot's capability in providing exercise information.
|
| 68 |
"""
|
| 69 |
try:
|
| 70 |
-
user_message = f"Here's the information on
|
| 71 |
|
| 72 |
# Append user's message to messages list
|
| 73 |
messages.append({"role": "user", "content": user_message})
|
|
@@ -99,7 +99,7 @@ def query_model(question):
|
|
| 99 |
Process a question, find relevant information, and generate a response.
|
| 100 |
"""
|
| 101 |
if question == "":
|
| 102 |
-
return "Welcome to
|
| 103 |
relevant_segment = find_relevant_segment(question, segments)
|
| 104 |
if not relevant_segment:
|
| 105 |
return "Could not find specific information. Please refine your question."
|
|
@@ -111,27 +111,20 @@ def query_model(question):
|
|
| 111 |
welcome_message = """
|
| 112 |
#
|
| 113 |
|
| 114 |
-
##
|
| 115 |
"""
|
| 116 |
|
| 117 |
topics = """
|
| 118 |
-
###
|
| 119 |
-
-
|
| 120 |
-
-
|
| 121 |
-
-
|
| 122 |
-
-
|
| 123 |
-
-
|
| 124 |
-
-
|
| 125 |
-
-
|
| 126 |
-
-
|
| 127 |
-
-
|
| 128 |
-
"""
|
| 129 |
-
|
| 130 |
-
times = """
|
| 131 |
-
### This is the list of times! Please pick the time that best fits your needs!
|
| 132 |
-
- 15 minutes
|
| 133 |
-
- 30 minutes
|
| 134 |
-
- 1 hour
|
| 135 |
"""
|
| 136 |
|
| 137 |
|
|
@@ -139,7 +132,7 @@ times = """
|
|
| 139 |
# Setup the Gradio Blocks interface with custom layout components
|
| 140 |
theme = gr.themes.Monochrome(
|
| 141 |
primary_hue="blue",
|
| 142 |
-
secondary_hue="
|
| 143 |
).set(
|
| 144 |
background_fill_primary='*primary_200',
|
| 145 |
background_fill_primary_dark='*primary_200',
|
|
@@ -157,19 +150,17 @@ theme = gr.themes.Monochrome(
|
|
| 157 |
# Setup the Gradio Blocks interface with custom layout components
|
| 158 |
with gr.Blocks(theme=theme) as demo:
|
| 159 |
theme='gstaff/xkcd'
|
| 160 |
-
gr.Image("Screenshot 2024-08-01 at 11.03.58 AM.png", show_label = False, show_share_button = False, show_download_button = False, width = 1800, height = 470)
|
| 161 |
gr.Markdown(welcome_message) # Display the formatted welcome message
|
| 162 |
with gr.Row():
|
| 163 |
with gr.Column():
|
| 164 |
-
gr.Markdown(topics)
|
| 165 |
-
with gr.Column():
|
| 166 |
-
gr.Markdown(times)
|
| 167 |
|
| 168 |
|
| 169 |
with gr.Row():
|
| 170 |
with gr.Column():
|
| 171 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 172 |
-
answer = gr.Textbox(label="
|
| 173 |
submit_button = gr.Button("Submit")
|
| 174 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 175 |
|
|
|
|
| 11 |
|
| 12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
| 13 |
|
| 14 |
+
system_message = "You are a chatbot specialized in providing information the Young Yale Global Scholars program. You will be giving information to be applicants and scholars."
|
| 15 |
# Initial system message to set the behavior of the assistant
|
| 16 |
messages = [{"role": "system", "content": system_message}]
|
| 17 |
|
|
|
|
| 67 |
Generate a response emphasizing the bot's capability in providing exercise information.
|
| 68 |
"""
|
| 69 |
try:
|
| 70 |
+
user_message = f"Here's the information on YYGS: {relevant_segment}"
|
| 71 |
|
| 72 |
# Append user's message to messages list
|
| 73 |
messages.append({"role": "user", "content": user_message})
|
|
|
|
| 99 |
Process a question, find relevant information, and generate a response.
|
| 100 |
"""
|
| 101 |
if question == "":
|
| 102 |
+
return "Welcome to Ask YYGS! Ask any question related to the YYGS program and this chatbot should be able to help!"
|
| 103 |
relevant_segment = find_relevant_segment(question, segments)
|
| 104 |
if not relevant_segment:
|
| 105 |
return "Could not find specific information. Please refine your question."
|
|
|
|
| 111 |
welcome_message = """
|
| 112 |
#
|
| 113 |
|
| 114 |
+
## AskYYGS is an AI-driven assistant for all Young Yale Global Scholar related queries. Created by Alexandra, Loli, Abigail, and Lisa at the 2025 YYGS Hack-A-Thon.
|
| 115 |
"""
|
| 116 |
|
| 117 |
topics = """
|
| 118 |
+
### Here are some ideas of things you can ask about!
|
| 119 |
+
- Class Locations
|
| 120 |
+
- Where to get help
|
| 121 |
+
- Laundry
|
| 122 |
+
- Roomate Question Ideas
|
| 123 |
+
- Things To Do
|
| 124 |
+
- What the programs mean
|
| 125 |
+
- Example Lectures
|
| 126 |
+
- Dining Shifts and the Menu
|
| 127 |
+
- How to Beat the Heat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
"""
|
| 129 |
|
| 130 |
|
|
|
|
| 132 |
# Setup the Gradio Blocks interface with custom layout components
|
| 133 |
theme = gr.themes.Monochrome(
|
| 134 |
primary_hue="blue",
|
| 135 |
+
secondary_hue="gray",
|
| 136 |
).set(
|
| 137 |
background_fill_primary='*primary_200',
|
| 138 |
background_fill_primary_dark='*primary_200',
|
|
|
|
| 150 |
# Setup the Gradio Blocks interface with custom layout components
|
| 151 |
with gr.Blocks(theme=theme) as demo:
|
| 152 |
theme='gstaff/xkcd'
|
| 153 |
+
#gr.Image("Screenshot 2024-08-01 at 11.03.58 AM.png", show_label = False, show_share_button = False, show_download_button = False, width = 1800, height = 470)
|
| 154 |
gr.Markdown(welcome_message) # Display the formatted welcome message
|
| 155 |
with gr.Row():
|
| 156 |
with gr.Column():
|
| 157 |
+
gr.Markdown(topics)
|
|
|
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
with gr.Row():
|
| 161 |
with gr.Column():
|
| 162 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 163 |
+
answer = gr.Textbox(label="Ask YYGS's Response:", placeholder="askYYGS will respond here...", interactive=False, lines=10)
|
| 164 |
submit_button = gr.Button("Submit")
|
| 165 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 166 |
|