Spaces:
Sleeping
Sleeping
adding columns
Browse files
app.py
CHANGED
|
@@ -90,7 +90,7 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 90 |
|
| 91 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
| 92 |
|
| 93 |
-
def respond(message, history):
|
| 94 |
top_weather = get_top_chunks(message, chunk_embeddings_weather, cleaned_chunks_weather)
|
| 95 |
top_luggage = get_top_chunks(message, chunk_embeddings_luggage, cleaned_chunks_luggage)
|
| 96 |
print(top_weather)
|
|
@@ -98,6 +98,15 @@ def respond(message, history):
|
|
| 98 |
|
| 99 |
str_top_weather = "\n".join(top_weather)
|
| 100 |
str_top_luggage = "\n".join(top_luggage)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
messages = [{"role": "system", "content": f"You're a friendly and gen z chatbot. Base your response on the provided context: {top_weather} and {top_luggage}."}]
|
| 103 |
|
|
@@ -117,13 +126,52 @@ def respond(message, history):
|
|
| 117 |
chatbot = gr.ChatInterface(respond, type = 'messages')
|
| 118 |
|
| 119 |
with gr.Blocks() as demo:
|
| 120 |
-
gr.
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
demo.launch(debug=True)
|
|
|
|
| 90 |
|
| 91 |
client = InferenceClient("Qwen/Qwen2.5-72B-Instruct")
|
| 92 |
|
| 93 |
+
def respond(message, history,use_spanish, destinations, season, luggage_types, luggage_size, food_prefs):
|
| 94 |
top_weather = get_top_chunks(message, chunk_embeddings_weather, cleaned_chunks_weather)
|
| 95 |
top_luggage = get_top_chunks(message, chunk_embeddings_luggage, cleaned_chunks_luggage)
|
| 96 |
print(top_weather)
|
|
|
|
| 98 |
|
| 99 |
str_top_weather = "\n".join(top_weather)
|
| 100 |
str_top_luggage = "\n".join(top_luggage)
|
| 101 |
+
|
| 102 |
+
lang = "Spanish" if use_spanish else "English"
|
| 103 |
+
ctx = (
|
| 104 |
+
f"Language: {lang}\n"
|
| 105 |
+
f"Destination: {', '.join(destinations)}\n"
|
| 106 |
+
f"Season: {', '.join(season)}\n"
|
| 107 |
+
f"Luggage: {', '.join(luggage_types)} of size {luggage_size}\n"
|
| 108 |
+
f"Food: {', '.join(food_prefs)}\n"
|
| 109 |
+
)
|
| 110 |
|
| 111 |
messages = [{"role": "system", "content": f"You're a friendly and gen z chatbot. Base your response on the provided context: {top_weather} and {top_luggage}."}]
|
| 112 |
|
|
|
|
| 126 |
chatbot = gr.ChatInterface(respond, type = 'messages')
|
| 127 |
|
| 128 |
with gr.Blocks() as demo:
|
| 129 |
+
with gr.Row():
|
| 130 |
+
# ─── left column: your controls ───
|
| 131 |
+
with gr.Column(scale=1):
|
| 132 |
+
use_spanish = gr.Checkbox(label="Use Spanish", value=False)
|
| 133 |
+
gr.Markdown("### Where are you going?")
|
| 134 |
+
destinations = gr.CheckboxGroup(
|
| 135 |
+
choices=["San Francisco","Los Angeles"],
|
| 136 |
+
label=None
|
| 137 |
+
)
|
| 138 |
+
gr.Markdown("### Season of travel")
|
| 139 |
+
season = gr.CheckboxGroup(
|
| 140 |
+
choices=["Winter","Spring","Summer","Fall"],
|
| 141 |
+
label=None
|
| 142 |
+
)
|
| 143 |
+
gr.Markdown("### Luggage")
|
| 144 |
+
luggage_types = gr.CheckboxGroup(
|
| 145 |
+
choices=["Carry-on","Checked"],
|
| 146 |
+
label="Type"
|
| 147 |
+
)
|
| 148 |
+
luggage_size = gr.Slider(
|
| 149 |
+
minimum=10, maximum=100, step=10, value=20,
|
| 150 |
+
label="Size (liters)"
|
| 151 |
+
)
|
| 152 |
+
gr.Markdown("### Food preferences")
|
| 153 |
+
food_prefs = gr.CheckboxGroup(
|
| 154 |
+
choices=["Italian","Thai","Mexican","Japanese"],
|
| 155 |
+
label=None
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
with gr.Column(scale=3):
|
| 159 |
+
# put your header image here
|
| 160 |
+
gr.Image(value="Go Buddy2.png",
|
| 161 |
+
interactive=False,
|
| 162 |
+
show_label=False)
|
| 163 |
+
# ChatInterface now takes all of those controls + the message/history
|
| 164 |
+
chatbot = gr.ChatInterface(
|
| 165 |
+
fn=respond,
|
| 166 |
+
inputs=[use_spanish,
|
| 167 |
+
destinations,
|
| 168 |
+
season,
|
| 169 |
+
luggage_types,
|
| 170 |
+
luggage_size,
|
| 171 |
+
food_prefs],
|
| 172 |
+
type="messages",
|
| 173 |
+
title="🌟 GoBuddy Chat",
|
| 174 |
+
description="Your travel companion""
|
| 175 |
+
)
|
| 176 |
|
| 177 |
demo.launch(debug=True)
|