Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -115,12 +115,12 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 115 |
|
| 116 |
|
| 117 |
# ======================================
|
| 118 |
-
def respond(message, history):
|
| 119 |
best_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 120 |
print(best_chunks)
|
| 121 |
|
| 122 |
str_chunks = "/n".join(best_chunks)
|
| 123 |
-
messages = [{'role':'system', 'content': 'You are a very kind chatbot giving people hobby suggestions to help them spend less time on their electronic devices. You answer their questions based on ' + str_chunks + '.'}]
|
| 124 |
|
| 125 |
if history:
|
| 126 |
messages.extend(history)
|
|
@@ -135,8 +135,11 @@ def respond(message, history):
|
|
| 135 |
|
| 136 |
with gr.Blocks(theme='earneleh/paris') as chatbot:
|
| 137 |
with gr.Row(scale=1):
|
|
|
|
|
|
|
|
|
|
| 138 |
gr.Image("ai.png")
|
| 139 |
with gr.Row(scale=1):
|
| 140 |
-
gr.ChatInterface(respond, type=
|
| 141 |
|
| 142 |
chatbot.launch()
|
|
|
|
| 115 |
|
| 116 |
|
| 117 |
# ======================================
|
| 118 |
+
def respond(message, history, hobby_type, age):
|
| 119 |
best_chunks = get_top_chunks(message, chunk_embeddings, cleaned_chunks)
|
| 120 |
print(best_chunks)
|
| 121 |
|
| 122 |
str_chunks = "/n".join(best_chunks)
|
| 123 |
+
messages = [{'role':'system', 'content': f'You are a very kind chatbot giving people hobby suggestions to help them spend less time on their electronic devices. Make sure to be specific to {hobby_type} hobbies. You answer their questions based on ' + str_chunks + '.'}]
|
| 124 |
|
| 125 |
if history:
|
| 126 |
messages.extend(history)
|
|
|
|
| 135 |
|
| 136 |
with gr.Blocks(theme='earneleh/paris') as chatbot:
|
| 137 |
with gr.Row(scale=1):
|
| 138 |
+
with gr.Column(scale=1):
|
| 139 |
+
hobby_type = gr.CheckboxGroup(['Long-term budget plan', 'Short-term budget plan','Cut back spending'], label = "What category of hobbies are you interested in?")
|
| 140 |
+
age = gr.Textbox(label = "How old are you", info = "Enter your age", placeholder = "Type a sentence here...")
|
| 141 |
gr.Image("ai.png")
|
| 142 |
with gr.Row(scale=1):
|
| 143 |
+
gr.ChatInterface(fn=respond, additional_inputs = [hobby_type, age], type= "messages")
|
| 144 |
|
| 145 |
chatbot.launch()
|