Spaces:
Runtime error
Runtime error
Commit
·
4826640
1
Parent(s):
d446300
Disable history; add text in case no results found
Browse files
app.py
CHANGED
|
@@ -26,7 +26,8 @@ async def start_chat():
|
|
| 26 |
|
| 27 |
@cl.on_message
|
| 28 |
async def on_message(message: str, message_id: str):
|
| 29 |
-
history = cl.user_session.get("history")
|
|
|
|
| 30 |
|
| 31 |
# update history
|
| 32 |
history.append({"role": "user", "content": message})
|
|
@@ -58,7 +59,7 @@ async def on_message(message: str, message_id: str):
|
|
| 58 |
|
| 59 |
# If the question is gibberish, stop the querying and make the user rephrase question
|
| 60 |
if query_msg.content == "Please rephrase your question.":
|
| 61 |
-
response_text = await chain.text("Please rephrase your
|
| 62 |
await response_text.update()
|
| 63 |
else:
|
| 64 |
|
|
@@ -134,6 +135,8 @@ async def on_message(message: str, message_id: str):
|
|
| 134 |
obj = tomllib.loads(toml_string)
|
| 135 |
final_ids = [id for id, val in obj['answer'].items() if val]
|
| 136 |
|
|
|
|
|
|
|
| 137 |
|
| 138 |
for i, id in enumerate(final_ids[:3]):
|
| 139 |
id = str(id)
|
|
@@ -157,6 +160,8 @@ async def on_message(message: str, message_id: str):
|
|
| 157 |
]
|
| 158 |
await msg.update()
|
| 159 |
|
|
|
|
|
|
|
| 160 |
# TODO what should the history include? ids only? or also descriptions?
|
| 161 |
# history.append({"role": "assistant", "content": response.content})
|
| 162 |
# await cl.Text(name="rephrase", content=response_text, displlay="inline").send()
|
|
|
|
| 26 |
|
| 27 |
@cl.on_message
|
| 28 |
async def on_message(message: str, message_id: str):
|
| 29 |
+
# history = cl.user_session.get("history")
|
| 30 |
+
history = []
|
| 31 |
|
| 32 |
# update history
|
| 33 |
history.append({"role": "user", "content": message})
|
|
|
|
| 59 |
|
| 60 |
# If the question is gibberish, stop the querying and make the user rephrase question
|
| 61 |
if query_msg.content == "Please rephrase your question.":
|
| 62 |
+
response_text = await chain.text("Please rephrase your query.", final=True)
|
| 63 |
await response_text.update()
|
| 64 |
else:
|
| 65 |
|
|
|
|
| 135 |
obj = tomllib.loads(toml_string)
|
| 136 |
final_ids = [id for id, val in obj['answer'].items() if val]
|
| 137 |
|
| 138 |
+
if len(final_ids) == 0:
|
| 139 |
+
await chain.text("Sorry, no restaurants found. Please try another query.", final=True)
|
| 140 |
|
| 141 |
for i, id in enumerate(final_ids[:3]):
|
| 142 |
id = str(id)
|
|
|
|
| 160 |
]
|
| 161 |
await msg.update()
|
| 162 |
|
| 163 |
+
|
| 164 |
+
|
| 165 |
# TODO what should the history include? ids only? or also descriptions?
|
| 166 |
# history.append({"role": "assistant", "content": response.content})
|
| 167 |
# await cl.Text(name="rephrase", content=response_text, displlay="inline").send()
|