Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,7 +86,7 @@ def get_top_chunks(query, chunk_embeddings, text_chunks):
|
|
| 86 |
print(similarities)
|
| 87 |
|
| 88 |
# Find the indices of the 3 chunks with highest similarity scores
|
| 89 |
-
top_indices = torch.topk(similarities, k=
|
| 90 |
|
| 91 |
# Print the top indices
|
| 92 |
print(top_indices)
|
|
@@ -111,24 +111,24 @@ def respond(message, history):
|
|
| 111 |
print("RECIPES!!!!!!: " + str_recipes_chunk)
|
| 112 |
|
| 113 |
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
{
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
|
| 133 |
if history:
|
| 134 |
messages.extend(history)
|
|
|
|
| 86 |
print(similarities)
|
| 87 |
|
| 88 |
# Find the indices of the 3 chunks with highest similarity scores
|
| 89 |
+
top_indices = torch.topk(similarities, k=3).indices
|
| 90 |
|
| 91 |
# Print the top indices
|
| 92 |
print(top_indices)
|
|
|
|
| 111 |
print("RECIPES!!!!!!: " + str_recipes_chunk)
|
| 112 |
|
| 113 |
|
| 114 |
+
messages = [
|
| 115 |
+
{
|
| 116 |
+
"role": "system",
|
| 117 |
+
"content": (
|
| 118 |
+
"You are a friendly chatbot that gives meal ideas and their 3 main ingredients "
|
| 119 |
+
"based only on the provided recipe list. DO NOT make up new recipes. "
|
| 120 |
+
"If no match is found, ask the user to rephrase."
|
| 121 |
+
)
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"role": "assistant",
|
| 125 |
+
"content": f"Here are the available recipes:\n{str_recipes_chunk}"
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"role": "user",
|
| 129 |
+
"content": message
|
| 130 |
+
}]
|
| 131 |
+
|
| 132 |
|
| 133 |
if history:
|
| 134 |
messages.extend(history)
|