Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,7 +74,7 @@ print(top_results)
|
|
| 74 |
# HUGGING FACE PROJECT
|
| 75 |
client = InferenceClient("Qwen/Qwen2.5-72B-instruct")
|
| 76 |
|
| 77 |
-
def respond(message, history, name, country): # Generate a response using the most relevant travel info chunks
|
| 78 |
new_message = message + " " + country
|
| 79 |
top_chunks = get_top_chunks(new_message, chunk_embeddings, cleaned_chunks)
|
| 80 |
str_top_chunks = "\n".join(top_chunks)
|
|
@@ -82,7 +82,7 @@ def respond(message, history, name, country): # Generate a response using the mo
|
|
| 82 |
messages = [
|
| 83 |
{
|
| 84 |
"role": "system",
|
| 85 |
-
"content": f"You are a friendly travel agent. Base your response on the following data: {top_chunks}. The user's name is {name} and they are traveling to {country}. Don't create anything, only take from our data. Look for {country} in the data and pull the specific information from the data. Help the customer to plan outfits for their vacation and etiquette for the country."
|
| 86 |
},
|
| 87 |
{
|
| 88 |
"role": "user",
|
|
@@ -111,8 +111,8 @@ def respond(message, history, name, country): # Generate a response using the mo
|
|
| 111 |
|
| 112 |
|
| 113 |
# SURVEY
|
| 114 |
-
def submit_survey(name, country):
|
| 115 |
-
print(f"Survey received - Name: {name}, Country: {country}")
|
| 116 |
return f"Thank you, {name}! Your survey response has been recorded. Ask Miles about any questions you have!", name, country
|
| 117 |
|
| 118 |
class MyCustomTheme(gr.themes.Base):
|
|
@@ -149,14 +149,15 @@ with gr.Blocks(theme=custom_theme, css="* { color: #0c265b !important; }") as de
|
|
| 149 |
with gr.Column():
|
| 150 |
name = gr.Textbox(label="Name", placeholder="Enter your name")
|
| 151 |
country = gr.Dropdown(label="Country", choices=["Argentina", "Australia", "Brazil", "Canada", "China", "Costa Rica", "Ecuador", "Egypt", "England", "France", "Germany", "Greece", "India", "Ireland", "Italy", "Jamaica", "Japan", "Kenya", "Malaysia", "Maldives", "Mexico", "Morocco", "Netherlands", "New Zealand", "Norway", "Panama", "Peru", "Philippines", "Poland", "Portugal", "Russia", "South Africa", "South Korea", "Spain", "Sweden", "Switzerland", "Taiwan", "Thailand", "Turkey", "USA", "Vietnam", "Zimbabwe"])
|
| 152 |
-
|
|
|
|
| 153 |
submit_btn = gr.Button("Submit Survey")
|
| 154 |
survey_output = gr.Textbox(label="Response", interactive=False)
|
| 155 |
|
| 156 |
submit_btn.click(
|
| 157 |
fn=submit_survey,
|
| 158 |
-
inputs=[name, country],
|
| 159 |
-
outputs=[survey_output, name_state, country_state]
|
| 160 |
)
|
| 161 |
|
| 162 |
gr.Markdown("---")
|
|
@@ -167,9 +168,9 @@ with gr.Blocks(theme=custom_theme, css="* { color: #0c265b !important; }") as de
|
|
| 167 |
send_btn = gr.Button("Send")
|
| 168 |
|
| 169 |
send_btn.click(
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
).then(
|
| 174 |
fn=lambda history: history,
|
| 175 |
inputs=[chat_state],
|
|
|
|
| 74 |
# HUGGING FACE PROJECT
|
| 75 |
client = InferenceClient("Qwen/Qwen2.5-72B-instruct")
|
| 76 |
|
| 77 |
+
def respond(message, history, name, country, season): # Generate a response using the most relevant travel info chunks
|
| 78 |
new_message = message + " " + country
|
| 79 |
top_chunks = get_top_chunks(new_message, chunk_embeddings, cleaned_chunks)
|
| 80 |
str_top_chunks = "\n".join(top_chunks)
|
|
|
|
| 82 |
messages = [
|
| 83 |
{
|
| 84 |
"role": "system",
|
| 85 |
+
"content": f"You are a friendly travel agent. Base your response on the following data: {top_chunks}. The user's name is {name} and they are traveling to {country} in the {season}. Don't create anything, only take from our data. Look for {country} in the data and pull the specific information from the data. Help the customer to plan outfits for their vacation and etiquette for the country."
|
| 86 |
},
|
| 87 |
{
|
| 88 |
"role": "user",
|
|
|
|
| 111 |
|
| 112 |
|
| 113 |
# SURVEY
|
| 114 |
+
def submit_survey(name, country, season):
|
| 115 |
+
print(f"Survey received - Name: {name}, Country: {country}, Season: {season}")
|
| 116 |
return f"Thank you, {name}! Your survey response has been recorded. Ask Miles about any questions you have!", name, country
|
| 117 |
|
| 118 |
class MyCustomTheme(gr.themes.Base):
|
|
|
|
| 149 |
with gr.Column():
|
| 150 |
name = gr.Textbox(label="Name", placeholder="Enter your name")
|
| 151 |
country = gr.Dropdown(label="Country", choices=["Argentina", "Australia", "Brazil", "Canada", "China", "Costa Rica", "Ecuador", "Egypt", "England", "France", "Germany", "Greece", "India", "Ireland", "Italy", "Jamaica", "Japan", "Kenya", "Malaysia", "Maldives", "Mexico", "Morocco", "Netherlands", "New Zealand", "Norway", "Panama", "Peru", "Philippines", "Poland", "Portugal", "Russia", "South Africa", "South Korea", "Spain", "Sweden", "Switzerland", "Taiwan", "Thailand", "Turkey", "USA", "Vietnam", "Zimbabwe"])
|
| 152 |
+
season = gr.Radio(label="Season", choices=["Spring", "Summer", "Autumn", "Winter"])
|
| 153 |
+
|
| 154 |
submit_btn = gr.Button("Submit Survey")
|
| 155 |
survey_output = gr.Textbox(label="Response", interactive=False)
|
| 156 |
|
| 157 |
submit_btn.click(
|
| 158 |
fn=submit_survey,
|
| 159 |
+
inputs=[name, country, season],
|
| 160 |
+
outputs=[survey_output, name_state, country_state, season_state]
|
| 161 |
)
|
| 162 |
|
| 163 |
gr.Markdown("---")
|
|
|
|
| 168 |
send_btn = gr.Button("Send")
|
| 169 |
|
| 170 |
send_btn.click(
|
| 171 |
+
fn=respond,
|
| 172 |
+
inputs=[msg, chat_state, name_state, country_state, season_state],
|
| 173 |
+
outputs=[chat_state, chat_state]
|
| 174 |
).then(
|
| 175 |
fn=lambda history: history,
|
| 176 |
inputs=[chat_state],
|