Samilincoln commited on
Commit ·
60da547
1
Parent(s): 20514e9
adjusted the code further more
Browse files40 unmodified lines4142434445464748495051525354555657585940 unmodified lines3. Maintain context across multiple messages."""history = []def recipe_chatbot(messages: str, history: list[str]):ask = {"current message" : messages,"previous message": history[::-1]}history.append(messages)response = model.generate_content([few_shot_prompt,ask], request_options=retry_policy)return response.textbot = gr.ChatInterface(fn=recipe_chatbot,type="chat",title="Kitcher - The recipe Assistant",description="Ask me about Nigerian dishes and I'll provide recipes or similar dish suggestions!",)40 unmodified lines4142434445464748495051525354555657585940 unmodified lines3. Maintain context across multiple messages."""def recipe_chatbot(messages: str, history=[]):full_conversation = "\n".join(history + [messages])prompt = f"{few_shot_prompt}\n\nUser Query:\n{full_conversation}"response = model.generate_content(prompt, request_options=retry_policy)history.append(messages)history.append(response.text)return history, response.textbot = gr.ChatInterface(fn=recipe_chatbot,type="messages",title="Kitcher - The recipe Assistant",description="Ask me about Nigerian dishes and I'll provide recipes or similar dish suggestions!",)
app.py+9-9