Spaces:
Sleeping
Sleeping
File size: 1,476 Bytes
4b01ae4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import os
import gradio as gr
from dotenv import load_dotenv
import google.generativeai as genai
# Load your Gemini API key from .env
load_dotenv()
api_key = os.getenv("GEMINI_API_KEY")
# Configure Gemini with your API key
genai.configure(api_key=api_key)
# Use the Gemini 1.5 Flash model (fast & free)
model = genai.GenerativeModel("gemini-2.0-flash")
# Main function to generate interview prep
def generate_interview_prep(role):
prompt = f"""
You are a Google-level interviewer preparing candidates for the job role: {role}.
Please provide:
1. Three real-world interview questions for this role
2. One sample answer
3. One practical interview tip
Respond clearly and in numbered format.
"""
try:
response = model.generate_content(prompt)
return response.text
except Exception as e:
return f" Error: {e}"
# Gradio UI
demo = gr.Interface(
fn=generate_interview_prep,
inputs=gr.Textbox(label="Enter Job Role", placeholder="e.g., Prompt Engineer"),
outputs=gr.Textbox(label="AI Interview Prep"),
title=" Gemini-Powered Interview Prep",
description="Enter a job title to receive 3 questions, a sample answer, and one practical tip.",
article=" Made with ❤️ by Mantasha Idrisi • GitHub: [imantasha](https://github.com/imantasha) • Portfolio: [imantasha.github.io](https://imantasha.github.io)"
)
# Launch the app
if __name__ == "__main__":
demo.launch()
|