import gradio as gr import pandas as pd import google.generativeai as genai import kagglehub import os path = kagglehub.dataset_download("fahmidachowdhury/food-adulteration-dataset") dataset_file = os.listdir(path)[0] path = os.path.join(path, dataset_file) gemapi = os.getenv("GeminiApi") genai.configure(api_key=gemapi) data = pd.read_csv(path) 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 the Indian context. You act as a representative of the government or public agencies, always keeping the needs of the people at 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 then detailed and can be sent to the company or restaurant. """ model_path = "gemini-1.5-flash" FoodSafetyAssistant = genai.GenerativeModel(model_path, system_instruction=system_instruction) def respond(usertxt): response = FoodSafetyAssistant.generate_content(contents=[usertxt]) return response.text html_content = """

Food Safety Assistant

Your AI-Powered Assistant for Food Safety

Our platform allows consumers to report potential food safety violations, validate reports through AI, and notify local authorities. This proactive approach fosters community involvement in ensuring food integrity.

Core Functionalities

Report Issues

Submit details like the restaurant name and the issue, anonymously.

AI Validation

Validate reports using AI, ensuring accuracy and preventing duplicates.

Alerts

Notify authorities of repeated issues via email or SMS.

Data Chat

Enable real-time discussion between consumers and authorities.

""" with gr.Blocks() as demo: gr.HTML(html_content) with gr.Row(): user_input = gr.Textbox(label="Your Input", placeholder="Enter your message here...", lines=5) output_text = gr.Textbox(label="Assistant Output", interactive=False, lines=5) submit_btn = gr.Button("Submit") submit_btn.click(respond, inputs=user_input, outputs=output_text) gr.Dataframe(value = data) demo.launch()