Spaces:
Sleeping
Sleeping
Updated chatgpt system message and query_model
Browse files
app.py
CHANGED
|
@@ -63,8 +63,9 @@ def generate_response(user_query, relevant_segment):
|
|
| 63 |
Generate a response emphasizing the bot's capability in providing chess information.
|
| 64 |
"""
|
| 65 |
try:
|
| 66 |
-
system_message = "You are a chess chatbot specialized in providing information on chess rules, strategies, and terminology."
|
| 67 |
-
|
|
|
|
| 68 |
messages = [
|
| 69 |
{"role": "system", "content": system_message},
|
| 70 |
{"role": "user", "content": user_message}
|
|
@@ -88,10 +89,10 @@ def query_model(question):
|
|
| 88 |
Process a question, find relevant information, and generate a response.
|
| 89 |
"""
|
| 90 |
if question == "":
|
| 91 |
-
return "
|
| 92 |
relevant_segment = find_relevant_segment(question, segments)
|
| 93 |
if not relevant_segment:
|
| 94 |
-
return "
|
| 95 |
response = generate_response(question, relevant_segment)
|
| 96 |
return response
|
| 97 |
|
|
@@ -118,7 +119,7 @@ with gr.Blocks(theme='gradio/soft') as demo:
|
|
| 118 |
with gr.Row():
|
| 119 |
with gr.Column():
|
| 120 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 121 |
-
answer = gr.Textbox(label="ChessBot Response", placeholder="
|
| 122 |
submit_button = gr.Button("Submit")
|
| 123 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 124 |
|
|
|
|
| 63 |
Generate a response emphasizing the bot's capability in providing chess information.
|
| 64 |
"""
|
| 65 |
try:
|
| 66 |
+
# system_message = "You are a chess chatbot specialized in providing information on chess rules, strategies, and terminology."
|
| 67 |
+
system_message = "You are a chatbot that is specialized in translating Gen-Z/Gen-Alpha slang into standard English. In addition to translation, you are knowledgable knowledgable on synonyms and origins of slang words."
|
| 68 |
+
user_message = f"Here's the question the user inputted: {relevant_segment}"
|
| 69 |
messages = [
|
| 70 |
{"role": "system", "content": system_message},
|
| 71 |
{"role": "user", "content": user_message}
|
|
|
|
| 89 |
Process a question, find relevant information, and generate a response.
|
| 90 |
"""
|
| 91 |
if question == "":
|
| 92 |
+
return "What the sigma! You didn't ask a question. Feel free to ask me anything about the topics listed above."
|
| 93 |
relevant_segment = find_relevant_segment(question, segments)
|
| 94 |
if not relevant_segment:
|
| 95 |
+
return "Unfortunately I cannot answer your question..😔 Try refining your question so I can try again."
|
| 96 |
response = generate_response(question, relevant_segment)
|
| 97 |
return response
|
| 98 |
|
|
|
|
| 119 |
with gr.Row():
|
| 120 |
with gr.Column():
|
| 121 |
question = gr.Textbox(label="Your question", placeholder="What do you want to ask about?")
|
| 122 |
+
answer = gr.Textbox(label="ChessBot Response", placeholder="RotBot will respond here...", interactive=False, lines=10)
|
| 123 |
submit_button = gr.Button("Submit")
|
| 124 |
submit_button.click(fn=query_model, inputs=question, outputs=answer)
|
| 125 |
|