Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,11 +60,11 @@ def find_relevant_segment(user_query, segments):
|
|
| 60 |
|
| 61 |
def generate_response(user_query, relevant_segment):
|
| 62 |
"""
|
| 63 |
-
Generate a response emphasizing the bot's capability in providing
|
| 64 |
"""
|
| 65 |
try:
|
| 66 |
-
system_message = "You are
|
| 67 |
-
user_message = f"Here's the information on
|
| 68 |
messages = [
|
| 69 |
{"role": "system", "content": system_message},
|
| 70 |
{"role": "user", "content": user_message}
|
|
@@ -88,7 +88,7 @@ def query_model(question):
|
|
| 88 |
Process a question, find relevant information, and generate a response.
|
| 89 |
"""
|
| 90 |
if question == "":
|
| 91 |
-
return "Welcome to
|
| 92 |
relevant_segment = find_relevant_segment(question, segments)
|
| 93 |
if not relevant_segment:
|
| 94 |
return "Could not find specific information. Please refine your question."
|
|
@@ -97,24 +97,22 @@ def query_model(question):
|
|
| 97 |
|
| 98 |
# Define the welcome message and specific topics the chatbot can provide information about
|
| 99 |
welcome_message = """
|
| 100 |
-
# ♟️ Welcome to
|
| 101 |
-
|
| 102 |
-
## Your AI-driven assistant for all chess-related queries.
|
| 103 |
"""
|
| 104 |
|
| 105 |
topics = """
|
| 106 |
### Feel Free to ask me anything from the topics below!
|
| 107 |
-
-
|
| 108 |
-
-
|
| 109 |
-
-
|
| 110 |
-
-
|
| 111 |
-
-
|
| 112 |
-
-
|
| 113 |
-
- Chess tactics
|
| 114 |
"""
|
| 115 |
|
| 116 |
# Setup the Gradio Blocks interface with custom layout components
|
| 117 |
-
with gr.Blocks(theme='
|
| 118 |
gr.Markdown(welcome_message) # Display the formatted welcome message
|
| 119 |
with gr.Row():
|
| 120 |
with gr.Column():
|
|
@@ -122,10 +120,10 @@ with gr.Blocks(theme='JohnSmith9982/small_and_pretty') as demo:
|
|
| 122 |
with gr.Row():
|
| 123 |
with gr.Column():
|
| 124 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 125 |
-
answer = gr.Textbox(label="
|
| 126 |
submit_button = gr.Button("Submit")
|
| 127 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 128 |
|
| 129 |
|
| 130 |
# Launch the Gradio app to allow user interaction
|
| 131 |
-
demo.launch(share=True)
|
|
|
|
| 60 |
|
| 61 |
def generate_response(user_query, relevant_segment):
|
| 62 |
"""
|
| 63 |
+
Generate a response emphasizing the bot's capability in providing college-related information.
|
| 64 |
"""
|
| 65 |
try:
|
| 66 |
+
system_message = "You are an informational chatbot specialized in providing information on college advising, financial aid, registration, and advice on navigating college."
|
| 67 |
+
user_message = f"Here's the information on college: {relevant_segment}"
|
| 68 |
messages = [
|
| 69 |
{"role": "system", "content": system_message},
|
| 70 |
{"role": "user", "content": user_message}
|
|
|
|
| 88 |
Process a question, find relevant information, and generate a response.
|
| 89 |
"""
|
| 90 |
if question == "":
|
| 91 |
+
return "Welcome to FirstGen Guide! Ask me anything about college advising, financial aid, registration, and advice on navigating college."
|
| 92 |
relevant_segment = find_relevant_segment(question, segments)
|
| 93 |
if not relevant_segment:
|
| 94 |
return "Could not find specific information. Please refine your question."
|
|
|
|
| 97 |
|
| 98 |
# Define the welcome message and specific topics the chatbot can provide information about
|
| 99 |
welcome_message = """
|
| 100 |
+
# ♟️ Welcome to FirstGen Guide!
|
| 101 |
+
## Your AI-driven assistant for all college-related queries.
|
|
|
|
| 102 |
"""
|
| 103 |
|
| 104 |
topics = """
|
| 105 |
### Feel Free to ask me anything from the topics below!
|
| 106 |
+
- College advising
|
| 107 |
+
- Financial aid
|
| 108 |
+
- Registration
|
| 109 |
+
- Courses
|
| 110 |
+
- College life
|
| 111 |
+
- Advice on navigating college
|
|
|
|
| 112 |
"""
|
| 113 |
|
| 114 |
# Setup the Gradio Blocks interface with custom layout components
|
| 115 |
+
with gr.Blocks(theme='HaleyCH/HaleyCH_Theme') as demo:
|
| 116 |
gr.Markdown(welcome_message) # Display the formatted welcome message
|
| 117 |
with gr.Row():
|
| 118 |
with gr.Column():
|
|
|
|
| 120 |
with gr.Row():
|
| 121 |
with gr.Column():
|
| 122 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 123 |
+
answer = gr.Textbox(label="FirstGenGuide Response", placeholder="FirstGen Guide will respond here...", interactive=False, lines=10)
|
| 124 |
submit_button = gr.Button("Submit")
|
| 125 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 126 |
|
| 127 |
|
| 128 |
# Launch the Gradio app to allow user interaction
|
| 129 |
+
demo.launch(share=True)
|