Samilincoln commited on
Commit
60da547
·
1 Parent(s): 20514e9

adjusted the code further more

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -41,19 +41,19 @@ Instructions:
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="chat",
57
  title="Kitcher - The recipe Assistant",
58
  description="Ask me about Nigerian dishes and I'll provide recipes or similar dish suggestions!",
59
  )
 
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 history, 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
  )