Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -103,7 +103,7 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
-
def respond(message, history):
|
| 107 |
best_physics_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_physics_chunks)
|
| 109 |
str_physics_chunks = "\n".join(best_physics_chunks)
|
|
@@ -112,7 +112,7 @@ def respond(message, history):
|
|
| 112 |
"role": "system",
|
| 113 |
"content": (
|
| 114 |
"You are a very smart, arrogant professor who knows a lot about physics. "
|
| 115 |
-
"You answer the questions from the user directly and concisely as if they were
|
| 116 |
"Keep your answers below 100 words!"
|
| 117 |
)
|
| 118 |
},
|
|
@@ -155,7 +155,12 @@ with gr.Blocks(theme='mgetz/Celeb_glitzy') as chatbot:
|
|
| 155 |
gr.Markdown(about_text)
|
| 156 |
|
| 157 |
with gr.Column(scale=2):
|
| 158 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
#chatbot = gr.ChatInterface(respond, type="messages", theme="mgetz/Celeb_glitzy", title="Physics Chatbot", description="Use this chatbot to help you with Physics")
|
|
|
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
+
def respond(message, history, name, level):
|
| 107 |
best_physics_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 108 |
print(best_physics_chunks)
|
| 109 |
str_physics_chunks = "\n".join(best_physics_chunks)
|
|
|
|
| 112 |
"role": "system",
|
| 113 |
"content": (
|
| 114 |
"You are a very smart, arrogant professor who knows a lot about physics. "
|
| 115 |
+
f"You answer the questions from the user, whose name is {name} directly and concisely as if they were a {level}. Base your response on the provided context."
|
| 116 |
"Keep your answers below 100 words!"
|
| 117 |
)
|
| 118 |
},
|
|
|
|
| 155 |
gr.Markdown(about_text)
|
| 156 |
|
| 157 |
with gr.Column(scale=2):
|
| 158 |
+
user_name = gr.Textbox(placeholder="Type your name here")
|
| 159 |
+
difficulty_level = gr.CheckboxGroup(["baby", "child", "middle school student", "high school student", "Physics Genius"], label="Physics Level")
|
| 160 |
+
gr.ChatInterface(
|
| 161 |
+
fn=respond,
|
| 162 |
+
additional_inputs=[user_name, difficulty_level],
|
| 163 |
+
type="messages")
|
| 164 |
|
| 165 |
|
| 166 |
#chatbot = gr.ChatInterface(respond, type="messages", theme="mgetz/Celeb_glitzy", title="Physics Chatbot", description="Use this chatbot to help you with Physics")
|