Samilincoln commited on
Commit ·
60da547
1
Parent(s): 20514e9
adjusted the code further more
Browse files
app.py
CHANGED
|
@@ -41,19 +41,19 @@ Instructions:
|
|
| 41 |
3. Maintain context across multiple messages.
|
| 42 |
"""
|
| 43 |
|
| 44 |
-
|
| 45 |
-
def recipe_chatbot(messages: str, history
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
history.append(messages)
|
| 51 |
-
response
|
| 52 |
-
return response.text
|
| 53 |
|
| 54 |
bot = gr.ChatInterface(
|
| 55 |
fn=recipe_chatbot,
|
| 56 |
-
type="
|
| 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 |
)
|