kavyatayal commited on
Commit
b536bdf
·
verified ·
1 Parent(s): af77948

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -19
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=1).indices
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
- messages = [
115
- {
116
- "role": "system",
117
- "content": (
118
- """
119
- You are a friendly chatbot that gives meal ideas and their 3 main ingredients based on the user's dietary restrictions, what type of meal they want (what time of day), what cuisine they want, and/or what ingredients they have.
120
- Just give the meal idea and the top 3 ingredients needed in your response. DON'T give instructions on how to make it. Base your answer on the provided context. Do not get information from anywhere else besides the provided text file. Do not give the user a meal idea that is not in the context.
121
- If the user's needs don't match a meal idea in the text file, tell the user to give different requirements (DON'T give an alternative meal idea) Don't cut off the response.
122
- """
123
- )
124
- },
125
- {
126
- "role": "user",
127
- "content": (
128
- f"Context:\n{str_recipes_chunk}\n\n"
129
- f"Question: {message}"
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)