Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -65,7 +65,7 @@ def generate_response(user_query, relevant_segment):
|
|
| 65 |
Generate a response emphasizing the bot's capability in providing country-specific visa information.
|
| 66 |
"""
|
| 67 |
try:
|
| 68 |
-
system_message = "You are a
|
| 69 |
user_message = f"Here's the information on visa requirements for your query: {relevant_segment}"
|
| 70 |
messages = [
|
| 71 |
{"role": "system", "content": system_message},
|
|
@@ -92,13 +92,13 @@ def generate_response(user_query, relevant_segment):
|
|
| 92 |
# Define and configure the Gradio application interface to interact with users.
|
| 93 |
def query_model(question):
|
| 94 |
"""
|
| 95 |
-
|
| 96 |
"""
|
| 97 |
if question == "":
|
| 98 |
-
return "Welcome to
|
| 99 |
relevant_segment = find_relevant_segment(question, segments)
|
| 100 |
if not relevant_segment:
|
| 101 |
-
return "Could not find
|
| 102 |
response = generate_response(question, relevant_segment)
|
| 103 |
return response
|
| 104 |
|
|
@@ -107,38 +107,23 @@ def query_model(question):
|
|
| 107 |
|
| 108 |
# Define the welcome message and specific topics and countries the chatbot can provide information about.
|
| 109 |
welcome_message = """
|
| 110 |
-
|
|
|
|
| 111 |
|
| 112 |
-
## Your AI-driven
|
| 113 |
"""
|
| 114 |
|
| 115 |
topics = """
|
| 116 |
### Feel Free to ask me anything from the topics below!
|
| 117 |
-
-
|
| 118 |
-
-
|
| 119 |
-
-
|
| 120 |
-
-
|
| 121 |
-
-
|
| 122 |
-
-
|
| 123 |
-
-
|
| 124 |
-
- Currency Information
|
| 125 |
-
- Embassy Information
|
| 126 |
-
- Allowed stay
|
| 127 |
"""
|
| 128 |
|
| 129 |
-
countries = """
|
| 130 |
-
### Our chatbot can currently answer questions for these countries!
|
| 131 |
-
- π¨π³ China
|
| 132 |
-
- π«π· France
|
| 133 |
-
- π¬πΉ Guatemala
|
| 134 |
-
- π±π§ Lebanon
|
| 135 |
-
- π²π½ Mexico
|
| 136 |
-
- π΅π Philippines
|
| 137 |
-
- π·πΈ Serbia
|
| 138 |
-
- πΈπ± Sierra Leone
|
| 139 |
-
- πΏπ¦ South Africa
|
| 140 |
-
- π»π³ Vietnam
|
| 141 |
-
"""
|
| 142 |
|
| 143 |
# Define and configure the Gradio application interface to interact with users.
|
| 144 |
def query_model(question):
|
|
@@ -173,7 +158,7 @@ with gr.Blocks() as demo:
|
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column():
|
| 175 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 176 |
-
answer = gr.Textbox(label="
|
| 177 |
submit_button = gr.Button("Submit")
|
| 178 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 179 |
|
|
|
|
| 65 |
Generate a response emphasizing the bot's capability in providing country-specific visa information.
|
| 66 |
"""
|
| 67 |
try:
|
| 68 |
+
system_message = "You are a chess chatbot specialized in providing information on chess rules, strategies, and terminology."
|
| 69 |
user_message = f"Here's the information on visa requirements for your query: {relevant_segment}"
|
| 70 |
messages = [
|
| 71 |
{"role": "system", "content": system_message},
|
|
|
|
| 92 |
# Define and configure the Gradio application interface to interact with users.
|
| 93 |
def query_model(question):
|
| 94 |
"""
|
| 95 |
+
Process a question, find relevant information, and generate a response.
|
| 96 |
"""
|
| 97 |
if question == "":
|
| 98 |
+
return "Welcome to ChessBot! Ask me anything about chess rules, strategies, and terminology."
|
| 99 |
relevant_segment = find_relevant_segment(question, segments)
|
| 100 |
if not relevant_segment:
|
| 101 |
+
return "Could not find specific information. Please refine your question."
|
| 102 |
response = generate_response(question, relevant_segment)
|
| 103 |
return response
|
| 104 |
|
|
|
|
| 107 |
|
| 108 |
# Define the welcome message and specific topics and countries the chatbot can provide information about.
|
| 109 |
welcome_message = """
|
| 110 |
+
welcome_message = """
|
| 111 |
+
# Welcome to ChessBot!
|
| 112 |
|
| 113 |
+
## Your AI-driven assistant for all chess-related queries.
|
| 114 |
"""
|
| 115 |
|
| 116 |
topics = """
|
| 117 |
### Feel Free to ask me anything from the topics below!
|
| 118 |
+
- Chess piece movements
|
| 119 |
+
- Special moves
|
| 120 |
+
- Game phases
|
| 121 |
+
- Common strategies
|
| 122 |
+
- Chess terminology
|
| 123 |
+
- Famous games
|
| 124 |
+
- Chess tactics
|
|
|
|
|
|
|
|
|
|
| 125 |
"""
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
# Define and configure the Gradio application interface to interact with users.
|
| 129 |
def query_model(question):
|
|
|
|
| 158 |
with gr.Row():
|
| 159 |
with gr.Column():
|
| 160 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 161 |
+
answer = gr.Textbox(label="ChessBot Response", placeholder="ChessBot will respond here...", interactive=False, lines=10)
|
| 162 |
submit_button = gr.Button("Submit")
|
| 163 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 164 |
|