Samilincoln commited on
Commit
19d5716
·
1 Parent(s): 7f1bee4
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -41,21 +41,19 @@ Instructions:
41
  3. Maintain context across multiple messages.
42
  """
43
 
44
-
45
- def recipe_chatbot(messages: str, history=[]):
46
- full_conversation = "\n".join(history + [messages])
47
- prompt = f"{few_shot_prompt}\n\nUser Query:\n{full_conversation}"
48
-
49
- response = model.generate_content(prompt, request_options=retry_policy)
50
  history.append(messages)
51
- history.append(response.text)
52
  return response.text
53
 
54
  bot = gr.ChatInterface(
55
  fn=recipe_chatbot,
56
- type="messages",
57
- title="Kitcher - The recipe Assistant",
58
- description="Ask me about Nigerian dishes and I'll provide recipes or similar dish suggestions!",
59
  )
60
 
61
- bot.launch()
 
41
  3. Maintain context across multiple messages.
42
  """
43
 
44
+ history = []
45
+ def recipe_chatbot(messages: str, history: list[str]):
46
+ ask = {
47
+ "current message" : messages,
48
+ "previous message": history[::-1]
49
+ }
50
  history.append(messages)
51
+ response = model.generate_content([few_shot_prompt,ask], request_options=retry_policy)
52
  return response.text
53
 
54
  bot = gr.ChatInterface(
55
  fn=recipe_chatbot,
56
+ type="messages"
 
 
57
  )
58
 
59
+ bot.launch()