SivaMallikarjun's picture
Create app.py
c3efe69 verified
import gradio as gr
import json
import random
# Sample ML Model Simulation
def ml_model_evaluate(application_text):
# Simulating ML-based approval (Adjust as per real model)
keywords = ["experience", "Python", "ML", "AI", "certification"]
score = sum(1 for word in keywords if word.lower() in application_text.lower())
return score >= 3 # Approve if at least 3 keywords match
# Job Application Processing Function
def process_application(user_id, application_text):
# Check if the user exists (simulated with JSON storage)
try:
with open("applications.json", "r") as file:
applications = json.load(file)
except FileNotFoundError:
applications = {}
if str(user_id) in applications:
return f"⚠️ You have already applied. Please wait for approval."
# ML Model Decision
approved = ml_model_evaluate(application_text)
if approved:
applications[str(user_id)] = "Approved"
with open("applications.json", "w") as file:
json.dump(applications, file)
return f"✅ Application Approved! You are eligible for job postings."
else:
return f"❌ Application Rejected. Improve details and resubmit."
# Gradio UI
iface = gr.Interface(
fn=process_application,
inputs=["text", "text"],
outputs="text",
title="AI Job Application Approval System",
description="Submit your job application. If everything is correct, it will be approved automatically!",
examples=[["2345", "I have experience in AI, Python, and ML."]],
)
if __name__ == "__main__":
iface.launch()