Ujeshhh commited on
Commit
1284607
·
verified ·
1 Parent(s): 1bfe8a5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +79 -0
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # skill_assessment_tool/app.py
2
+ import ast
3
+ from textblob import TextBlob
4
+ from transformers import pipeline
5
+ import gradio as gr
6
+
7
+ # Coding Test Analyzer
8
+ def analyze_code(code_str):
9
+ try:
10
+ tree = ast.parse(code_str)
11
+ complexity = sum(1 for node in ast.walk(tree) if isinstance(node, ast.For))
12
+ return {"syntax": "valid", "complexity": complexity, "score": min(100, 90 - complexity * 5)}
13
+ except SyntaxError:
14
+ return {"syntax": "invalid", "complexity": 0, "score": 20}
15
+
16
+ # Video Interview Analyzer (simplified, assumes text input)
17
+ def analyze_video_response(text):
18
+ blob = TextBlob(text)
19
+ sentiment = blob.sentiment.polarity # -1 to 1
20
+ comm_score = max(50, int((sentiment + 1) * 50)) # Normalize to 0-100
21
+ return {"communication": comm_score, "confidence": comm_score - 10}
22
+
23
+ # Behavioral Response Analyzer
24
+ def analyze_behavioral_response(text):
25
+ classifier = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
26
+ result = classifier(text)[0]
27
+ adapt_score = 80 if result["label"] == "POSITIVE" else 60
28
+ return {"adaptability": adapt_score}
29
+
30
+ # Report Generator
31
+ def generate_report(tech_score, comm_score, adapt_score):
32
+ return {
33
+ "Technical Skills": tech_score,
34
+ "Communication": comm_score,
35
+ "Adaptability": adapt_score,
36
+ "Overall": round((tech_score + comm_score + adapt_score) / 3, 2)
37
+ }
38
+
39
+ # Main function for Gradio
40
+ def assess_candidate(code, video_text, behavioral_text):
41
+ code_result = analyze_code(code)
42
+ video_result = analyze_video_response(video_text)
43
+ behavioral_result = analyze_behavioral_response(behavioral_text)
44
+
45
+ report = generate_report(
46
+ code_result["score"],
47
+ video_result["communication"],
48
+ behavioral_result["adaptability"]
49
+ )
50
+
51
+ # Return as a formatted string (Gradio outputs text or UI elements)
52
+ output = (
53
+ f"Report:\n"
54
+ f"Technical Skills: {report['Technical Skills']}/100\n"
55
+ f"Communication: {report['Communication']}/100\n"
56
+ f"Adaptability: {report['Adaptability']}/100\n"
57
+ f"Overall: {report['Overall']}/100\n\n"
58
+ f"Details:\n"
59
+ f"Code Analysis: {code_result}\n"
60
+ f"Video Analysis: {video_result}\n"
61
+ f"Behavioral Analysis: {behavioral_result}"
62
+ )
63
+ return output
64
+
65
+ # Gradio Interface
66
+ interface = gr.Interface(
67
+ fn=assess_candidate,
68
+ inputs=[
69
+ gr.Textbox(lines=5, label="Coding Test Submission", placeholder="Paste your Python code here..."),
70
+ gr.Textbox(lines=3, label="Video Interview Response", placeholder="Type your response (e.g., transcribed video)..."),
71
+ gr.Textbox(lines=3, label="Behavioral Response", placeholder="How do you handle team conflict?...")
72
+ ],
73
+ outputs=gr.Textbox(label="Assessment Report"),
74
+ title="Skill Assessment Tool",
75
+ description="Enter code, video response, and behavioral text to get a skill assessment report."
76
+ )
77
+
78
+ # Launch the app
79
+ interface.launch(server_name="0.0.0.0", server_port=7860)