Spaces:
Sleeping
Sleeping
import gradio as gr | |
import google.generativeai as genai | |
# Configure your Gemini API key | |
genai.configure(api_key="AIzaSyCCkG05NQrWCoO9kNeWoI1Y83ltdmYKiNM") # Replace with your real key | |
# Use the correct model that supports text-only chat | |
model = genai.GenerativeModel(model_name="models/gemini-1.5-flash") | |
# Prediction function | |
def predict_role(skills): | |
try: | |
prompt = f""" | |
You are a smart career advisor AI. Based on the following skills: {skills}, suggest the most suitable job title. | |
Respond ONLY with a clear job title, like: | |
- Data Analyst | |
- Full Stack Developer | |
- DevOps Engineer | |
Don't repeat the input. Output one job title only. | |
""" | |
response = model.generate_content(prompt) | |
result = response.text.strip() | |
# Clean result | |
if "\n" in result: | |
result = result.split("\n")[0] | |
if result.startswith("- "): | |
result = result[2:] | |
return result | |
except Exception as e: | |
return f"❌ Error: {str(e)}" | |
# Gradio app | |
gr.Interface( | |
fn=predict_role, | |
inputs=gr.Textbox(lines=2, placeholder="e.g., Python, SQL, Docker"), | |
outputs="text", | |
title="Career Predictor", | |
description="Enter your tech skills. Get a predicted job title." | |
).launch() | |