aashnaj commited on
Commit
55a30b0
·
verified ·
1 Parent(s): 7cd0c55
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -17,14 +17,14 @@ def get_top_chunks(query):
17
  top_indices = torch.topk(similarities, k=5).indices.tolist()
18
  return [cleaned_chunks[i] for i in top_indices]
19
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
20
- def respond(message, history):
21
  response = ""
22
  top_chunks = get_top_chunks(message)
23
  context = "\n".join(top_chunks)
24
  messages = [
25
  {
26
  "role": "system",
27
- "content": f"You are a friendly chatbot that responds to the user with this context {context}"
28
  }
29
  ]
30
  if history:
@@ -59,9 +59,13 @@ theme = gr.themes.Monochrome(
59
 
60
  with gr.Blocks(theme=theme) as chatbot:
61
  gr.Markdown("## 🥗🍴 The BiteBot")
 
 
 
62
  gr.ChatInterface(
63
  fn=respond,
64
- type="messages",
65
  )
 
66
  chatbot.launch()
67
 
 
17
  top_indices = torch.topk(similarities, k=5).indices.tolist()
18
  return [cleaned_chunks[i] for i in top_indices]
19
  client = InferenceClient("mistralai/Mistral-7B-Instruct-v0.2")
20
+ def respond(message, history, cuisine, dietary_restrictions, allergies):
21
  response = ""
22
  top_chunks = get_top_chunks(message)
23
  context = "\n".join(top_chunks)
24
  messages = [
25
  {
26
  "role": "system",
27
+ "content": f"You are a friendly recipe chatbot named BiteBot that responds to the user with any recipe from this: {context}. Find a recipe that is {cuisine} cuisine. They have the dietary restrictions,{dietary_restrictions} and are allergic to {allergies}. Return the title to the user and ask if this is the recipe they want. If they say yes return the recipe to the user, and if they say no provide another recipe."
28
  }
29
  ]
30
  if history:
 
59
 
60
  with gr.Blocks(theme=theme) as chatbot:
61
  gr.Markdown("## 🥗🍴 The BiteBot")
62
+ cuisine=gr.Textbox()
63
+ dietary_restrictions=gr.Dropdown(["Gluten-Free","Dairy-Free","Vegan","Vegetarian","Keto","Kosher","No Soy","No Seafood","No Pork","No Beef"])
64
+ allergies=gr.Textbox()
65
  gr.ChatInterface(
66
  fn=respond,
67
+ type="messages", additional_inputs=[cuisine,dietary_restrictions,allergies]
68
  )
69
+
70
  chatbot.launch()
71