GoggleGemini / app.py
Atharv756's picture
Update app.py
1da7a2e verified
import os
import google.generativeai as genai
import gradio as gr
# Configure the Google AI SDK
genai.configure(api_key=os.environ["AIzaSyBmjoohxCQW1L92RMAZcfrFcVTi5RPoTeA"])
# Create the model
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 64,
"max_output_tokens": 8192,
"response_mime_type": "text/plain",
}
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
generation_config=generation_config,
)
# Function to generate the recipe
def generate_recipe(food_item):
chat_session = model.start_chat(
history=[
{
"role": "user",
"parts": [f"Generate a recipe for a food item '{food_item}'"],
}
]
)
response = chat_session.send_message("Tell me the recipe.")
return response.text
# Create Gradio interface
iface = gr.Interface(
fn=generate_recipe,
inputs="text",
outputs="text",
title="Recipe Generator",
description="Enter a food item to generate a recipe."
)
# Launch the interface
iface.launch()