Shangkhonil commited on
Commit
1a540b4
·
verified ·
1 Parent(s): bba7d00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -2,8 +2,9 @@ import os
2
  import google.generativeai as genai
3
  import gradio as gr
4
 
5
- # Configure the Google Gemini API with the environment variable for the API key
6
- genai.configure(api_key=os.getenv("GEMINI_API_KEY"))
 
7
 
8
  # Set up the generation configuration
9
  generation_config = {
@@ -33,15 +34,15 @@ def generate_response(user_input):
33
  return response.text
34
 
35
  # Gradio Interface
36
- with gr.Blocks() as demo:
37
- gr.Markdown("# Google Gemini Chat Interface")
38
-
39
- user_input = gr.Textbox(label="Enter your prompt", placeholder="Ask anything...")
40
- output_text = gr.Textbox(label="Model Output")
41
-
42
- generate_button = gr.Button("Generate Response")
43
-
44
- generate_button.click(generate_response, inputs=user_input, outputs=output_text)
45
 
46
  # Launch the Gradio app
47
- demo.launch()
 
 
2
  import google.generativeai as genai
3
  import gradio as gr
4
 
5
+ # Configure the API key for Google Generative AI
6
+ GOOGLE_API_KEY = "AIzaSyA9Bh3WRz6LzKaA7MDm6foj1dw8w8kh-gc"
7
+ genai.configure(api_key=GOOGLE_API_KEY)
8
 
9
  # Set up the generation configuration
10
  generation_config = {
 
34
  return response.text
35
 
36
  # Gradio Interface
37
+ iface = gr.Interface(
38
+ fn=generate_response,
39
+ inputs="text",
40
+ outputs="text",
41
+ title="Recipe Generator",
42
+ description="Ask for recipes or any other text-based generation using Google's Gemini AI",
43
+ theme="default",
44
+ )
 
45
 
46
  # Launch the Gradio app
47
+ if __name__ == "__main__":
48
+ iface.launch()