import gradio as gr import pandas as pd import google.generativeai as genai import kagglehub path = kagglehub.dataset_download("fahmidachowdhury/food-adulteration-dataset") gemapi = "AIzaSyAmDOBWfGuEju0oZyUIcn_H0k8XW0cTP7k" genai.configure(api_key = gemapi) import os os.listdir(path) path = path + "/"+ os.listdir(path)[0] # Initializing Model: system_instruction = f""" You are a public assistant who specializes in food safety. You look at data and explain to the user any question they ask; here is your data {str(data.to_json())}\ You are also a food expert in Indian context. You act as the representative of the Goverment or public agencies always keeping the needs of the people to the forefront. You will try to help the customer launch a feedback review whenever they complain. You are to prepare a "markdown" report which is detailed and which can be sent to the company or restaurant.\ In case of a complaint or a grievance, You will act like a detective gathering necessary information from the user untill you are satisfied; Once You gather all the info, you are supposed to generate a markdown report\ Once the customer asks you to show them the markdown report, you will use the information given to you to generate a report.\ You will ask the customer a single question at a time, which is relevent and you will not repeat another question until youve generated the report. """ model_path = "gemini-1.5-flash" FoodSafetyAssistant = genai.GenerativeModel(model_path, system_instruction = system_instruction) def startChat(usertxt, chat_history=[]): while usertxt != "exit" or usertxt != "Exit": chat = FoodSafetyAssistant.start_chat(history = chat_history) response = chat.send_message(usertxt) yield response.text demo = gr.ChatInterface( respond ) if __name__ == "__main__": demo.launch()