Implement black code formatter
Browse files- requirements.txt +2 -1
- src/domain/candidate.py +2 -1
- src/domain/emotion_metrics.py +2 -1
- src/domain/enums/emotion_types.py +2 -1
- src/domain/enums/interview_status.py +2 -1
- src/domain/interview.py +5 -1
- src/domain/resume.py +1 -0
- src/frontend/interface.py +8 -7
- src/service/interview_analyzer.py +9 -4
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
gradio==5.6.0
|
2 |
-
gradio_client==1.4.3
|
|
|
|
1 |
gradio==5.6.0
|
2 |
+
gradio_client==1.4.3
|
3 |
+
black==24.10.0
|
src/domain/candidate.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import Dict, List
|
3 |
|
|
|
4 |
@dataclass
|
5 |
class Candidate:
|
6 |
id: str
|
@@ -9,4 +10,4 @@ class Candidate:
|
|
9 |
resume_data: Dict
|
10 |
interview_responses: List[str]
|
11 |
emotional_metrics: Dict
|
12 |
-
feedback: Dict
|
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import Dict, List
|
3 |
|
4 |
+
|
5 |
@dataclass
|
6 |
class Candidate:
|
7 |
id: str
|
|
|
10 |
resume_data: Dict
|
11 |
interview_responses: List[str]
|
12 |
emotional_metrics: Dict
|
13 |
+
feedback: Dict
|
src/domain/emotion_metrics.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import List, Dict
|
3 |
|
|
|
4 |
@dataclass
|
5 |
class EmotionMetrics:
|
6 |
confidence_score: float
|
@@ -11,4 +12,4 @@ class EmotionMetrics:
|
|
11 |
|
12 |
def calculate_overall_score(self) -> float:
|
13 |
# Implementation for calculating overall emotional score
|
14 |
-
pass
|
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import List, Dict
|
3 |
|
4 |
+
|
5 |
@dataclass
|
6 |
class EmotionMetrics:
|
7 |
confidence_score: float
|
|
|
12 |
|
13 |
def calculate_overall_score(self) -> float:
|
14 |
# Implementation for calculating overall emotional score
|
15 |
+
pass
|
src/domain/enums/emotion_types.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from enum import Enum
|
2 |
|
|
|
3 |
class EmotionType(Enum):
|
4 |
HAPPY = "happy"
|
5 |
SAD = "sad"
|
@@ -15,4 +16,4 @@ class EmotionType(Enum):
|
|
15 |
|
16 |
@classmethod
|
17 |
def get_negative_emotions(cls):
|
18 |
-
return [cls.SAD, cls.ANGRY, cls.FEARFUL, cls.DISGUSTED]
|
|
|
1 |
from enum import Enum
|
2 |
|
3 |
+
|
4 |
class EmotionType(Enum):
|
5 |
HAPPY = "happy"
|
6 |
SAD = "sad"
|
|
|
16 |
|
17 |
@classmethod
|
18 |
def get_negative_emotions(cls):
|
19 |
+
return [cls.SAD, cls.ANGRY, cls.FEARFUL, cls.DISGUSTED]
|
src/domain/enums/interview_status.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from enum import Enum, auto
|
2 |
|
|
|
3 |
class InterviewStatus(Enum):
|
4 |
SCHEDULED = auto()
|
5 |
IN_PROGRESS = auto()
|
@@ -7,4 +8,4 @@ class InterviewStatus(Enum):
|
|
7 |
CANCELLED = auto()
|
8 |
PENDING_REVIEW = auto()
|
9 |
REVIEWED = auto()
|
10 |
-
FAILED = auto()
|
|
|
1 |
from enum import Enum, auto
|
2 |
|
3 |
+
|
4 |
class InterviewStatus(Enum):
|
5 |
SCHEDULED = auto()
|
6 |
IN_PROGRESS = auto()
|
|
|
8 |
CANCELLED = auto()
|
9 |
PENDING_REVIEW = auto()
|
10 |
REVIEWED = auto()
|
11 |
+
FAILED = auto()
|
src/domain/interview.py
CHANGED
@@ -4,6 +4,7 @@ from typing import List, Dict
|
|
4 |
from src.domain.enums.interview_status import InterviewStatus
|
5 |
from src.domain.enums.emotion_types import EmotionType
|
6 |
|
|
|
7 |
@dataclass
|
8 |
class Interview:
|
9 |
id: str
|
@@ -21,4 +22,7 @@ class Interview:
|
|
21 |
return self.status == InterviewStatus.COMPLETED
|
22 |
|
23 |
def is_reviewable(self) -> bool:
|
24 |
-
return self.status in [
|
|
|
|
|
|
|
|
4 |
from src.domain.enums.interview_status import InterviewStatus
|
5 |
from src.domain.enums.emotion_types import EmotionType
|
6 |
|
7 |
+
|
8 |
@dataclass
|
9 |
class Interview:
|
10 |
id: str
|
|
|
22 |
return self.status == InterviewStatus.COMPLETED
|
23 |
|
24 |
def is_reviewable(self) -> bool:
|
25 |
+
return self.status in [
|
26 |
+
InterviewStatus.COMPLETED,
|
27 |
+
InterviewStatus.PENDING_REVIEW,
|
28 |
+
]
|
src/domain/resume.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import List, Dict
|
3 |
|
|
|
4 |
@dataclass
|
5 |
class Resume:
|
6 |
id: str
|
|
|
1 |
from dataclasses import dataclass
|
2 |
from typing import List, Dict
|
3 |
|
4 |
+
|
5 |
@dataclass
|
6 |
class Resume:
|
7 |
id: str
|
src/frontend/interface.py
CHANGED
@@ -5,6 +5,7 @@ from src.infrastructure.llm import LangchainService
|
|
5 |
from src.infrastructure.emotion import DeepFaceService
|
6 |
from src.infrastructure.speech import GoogleSpeechService
|
7 |
|
|
|
8 |
class GradioInterface:
|
9 |
def __init__(self):
|
10 |
# Initialize services
|
@@ -16,14 +17,12 @@ class GradioInterface:
|
|
16 |
self.analyzer = InterviewAnalyzer(
|
17 |
emotion_service=self.emotion_service,
|
18 |
speech_service=self.speech_service,
|
19 |
-
llm_service=self.llm_service
|
20 |
)
|
21 |
|
22 |
def create_interface(self) -> gr.Interface:
|
23 |
def process_submission(
|
24 |
-
|
25 |
-
resume_file: str,
|
26 |
-
job_requirements: str
|
27 |
) -> Dict:
|
28 |
# Implementation for processing submission
|
29 |
pass
|
@@ -34,19 +33,21 @@ class GradioInterface:
|
|
34 |
inputs=[
|
35 |
gr.Video(label="Interview Recording"),
|
36 |
gr.File(label="Resume"),
|
37 |
-
gr.Textbox(label="Job Requirements", lines=5)
|
38 |
],
|
39 |
outputs=gr.JSON(label="Analysis Results"),
|
40 |
title="HR Interview Analysis System",
|
41 |
-
description="Upload interview recording and resume to analyze candidate performance"
|
42 |
)
|
43 |
|
44 |
return interface
|
45 |
|
|
|
46 |
def launch_app():
|
47 |
app = GradioInterface()
|
48 |
interface = app.create_interface()
|
49 |
interface.launch()
|
50 |
|
|
|
51 |
if __name__ == "__main__":
|
52 |
-
launch_app()
|
|
|
5 |
from src.infrastructure.emotion import DeepFaceService
|
6 |
from src.infrastructure.speech import GoogleSpeechService
|
7 |
|
8 |
+
|
9 |
class GradioInterface:
|
10 |
def __init__(self):
|
11 |
# Initialize services
|
|
|
17 |
self.analyzer = InterviewAnalyzer(
|
18 |
emotion_service=self.emotion_service,
|
19 |
speech_service=self.speech_service,
|
20 |
+
llm_service=self.llm_service,
|
21 |
)
|
22 |
|
23 |
def create_interface(self) -> gr.Interface:
|
24 |
def process_submission(
|
25 |
+
video_file: str, resume_file: str, job_requirements: str
|
|
|
|
|
26 |
) -> Dict:
|
27 |
# Implementation for processing submission
|
28 |
pass
|
|
|
33 |
inputs=[
|
34 |
gr.Video(label="Interview Recording"),
|
35 |
gr.File(label="Resume"),
|
36 |
+
gr.Textbox(label="Job Requirements", lines=5),
|
37 |
],
|
38 |
outputs=gr.JSON(label="Analysis Results"),
|
39 |
title="HR Interview Analysis System",
|
40 |
+
description="Upload interview recording and resume to analyze candidate performance",
|
41 |
)
|
42 |
|
43 |
return interface
|
44 |
|
45 |
+
|
46 |
def launch_app():
|
47 |
app = GradioInterface()
|
48 |
interface = app.create_interface()
|
49 |
interface.launch()
|
50 |
|
51 |
+
|
52 |
if __name__ == "__main__":
|
53 |
+
launch_app()
|
src/service/interview_analyzer.py
CHANGED
@@ -3,12 +3,15 @@ from src.domain.enums.emotion_types import EmotionType
|
|
3 |
from src.domain.entities.interview import Interview
|
4 |
from typing import Dict, List
|
5 |
|
|
|
6 |
class InterviewAnalyzer:
|
7 |
def validate_video(self, video_path: str) -> bool:
|
8 |
-
file_extension = video_path[video_path.rfind("."):]
|
9 |
return VideoFileType.validate_format(file_extension)
|
10 |
|
11 |
-
def analyze_emotions(
|
|
|
|
|
12 |
analyzed_emotions = {}
|
13 |
for emotion_name, score in emotion_data.items():
|
14 |
try:
|
@@ -18,10 +21,12 @@ class InterviewAnalyzer:
|
|
18 |
continue
|
19 |
return analyzed_emotions
|
20 |
|
21 |
-
def get_dominant_emotion(
|
|
|
|
|
22 |
return max(emotion_scores.items(), key=lambda x: x[1])[0]
|
23 |
|
24 |
def is_positive_response(self, emotion_scores: Dict[EmotionType, float]) -> bool:
|
25 |
positive_emotions = EmotionType.get_positive_emotions()
|
26 |
dominant_emotion = self.get_dominant_emotion(emotion_scores)
|
27 |
-
return dominant_emotion in positive_emotions
|
|
|
3 |
from src.domain.entities.interview import Interview
|
4 |
from typing import Dict, List
|
5 |
|
6 |
+
|
7 |
class InterviewAnalyzer:
|
8 |
def validate_video(self, video_path: str) -> bool:
|
9 |
+
file_extension = video_path[video_path.rfind(".") :]
|
10 |
return VideoFileType.validate_format(file_extension)
|
11 |
|
12 |
+
def analyze_emotions(
|
13 |
+
self, emotion_data: Dict[str, float]
|
14 |
+
) -> Dict[EmotionType, float]:
|
15 |
analyzed_emotions = {}
|
16 |
for emotion_name, score in emotion_data.items():
|
17 |
try:
|
|
|
21 |
continue
|
22 |
return analyzed_emotions
|
23 |
|
24 |
+
def get_dominant_emotion(
|
25 |
+
self, emotion_scores: Dict[EmotionType, float]
|
26 |
+
) -> EmotionType:
|
27 |
return max(emotion_scores.items(), key=lambda x: x[1])[0]
|
28 |
|
29 |
def is_positive_response(self, emotion_scores: Dict[EmotionType, float]) -> bool:
|
30 |
positive_emotions = EmotionType.get_positive_emotions()
|
31 |
dominant_emotion = self.get_dominant_emotion(emotion_scores)
|
32 |
+
return dominant_emotion in positive_emotions
|