QuentinL52 commited on
Commit
8d38cd3
·
verified ·
1 Parent(s): e35c724

Delete src/interview_simulator

Browse files
src/interview_simulator/__init__.py DELETED
File without changes
src/interview_simulator/__pycache__/__init__.cpython-312.pyc DELETED
Binary file (191 Bytes)
 
src/interview_simulator/__pycache__/entretient_version_prod.cpython-312.pyc DELETED
Binary file (5.44 kB)
 
src/interview_simulator/entretient_version_prod.py DELETED
@@ -1,74 +0,0 @@
1
- import os
2
- import sys
3
- import json
4
- from typing import Dict, List, Any, Annotated
5
- from typing_extensions import TypedDict
6
-
7
- from langchain_core.messages import AIMessage, SystemMessage, HumanMessage
8
- from langgraph.graph import StateGraph, START, END
9
- from langgraph.graph.message import add_messages
10
- from langchain_openai import ChatOpenAI
11
-
12
- from src.config import read_system_prompt, format_cv
13
-
14
- class State(TypedDict):
15
- messages: Annotated[list, add_messages]
16
-
17
- class InterviewProcessor:
18
- def __init__(self, cv_document: Dict[str, Any], job_offer: Dict[str, Any], conversation_history: List[Dict[str, Any]]):
19
- if not cv_document or 'candidat' not in cv_document:
20
- raise ValueError("Document CV invalide fourni.")
21
- if not job_offer:
22
- raise ValueError("Données de l'offre d'emploi non fournies.")
23
-
24
- self.job_offer = job_offer
25
- self.cv_data = cv_document['candidat']
26
- self.conversation_history = conversation_history
27
- self.llm = self._get_llm()
28
-
29
- self.system_prompt_template = self._load_prompt_template()
30
- self.graph = self._build_graph()
31
-
32
- def _get_llm(self) -> ChatOpenAI:
33
- openai_api_key = os.getenv("OPENAI_API_KEY")
34
- return ChatOpenAI(
35
- temperature=0.6,
36
- model_name="gpt-4o-mini",
37
- api_key=openai_api_key
38
- )
39
-
40
- def _load_prompt_template(self) -> str:
41
- return read_system_prompt('prompts/rag_prompt_old.txt')
42
-
43
- def _chatbot_node(self, state: State) -> dict:
44
- messages = state["messages"]
45
- formatted_cv_str = format_cv(self.cv_data)
46
-
47
- # Formatage du prompt système
48
- system_prompt = self.system_prompt_template.format(
49
- entreprise=self.job_offer.get('entreprise', 'notre entreprise'),
50
- poste=self.job_offer.get('poste', 'ce poste'),
51
- mission=self.job_offer.get('mission', 'Non spécifiée'),
52
- profil_recherche=self.job_offer.get('profil_recherche', 'Non spécifié'),
53
- competences=self.job_offer.get('competences', 'Non spécifiées'),
54
- pole=self.job_offer.get('pole', 'Non spécifié'),
55
- cv=formatted_cv_str
56
- )
57
-
58
- llm_messages = [SystemMessage(content=system_prompt)] + messages
59
- response = self.llm.invoke(llm_messages)
60
- return {"messages": [response]}
61
-
62
- def _build_graph(self) -> any:
63
- graph_builder = StateGraph(State)
64
-
65
- graph_builder.add_node("chatbot", self._chatbot_node)
66
- graph_builder.add_edge(START, "chatbot")
67
- # Le graph se termine toujours après la réponse du chatbot
68
- graph_builder.add_edge("chatbot", END)
69
-
70
- return graph_builder.compile()
71
-
72
- def run(self, messages: List[Dict[str, Any]]) -> Dict[str, Any]:
73
- initial_state = self.conversation_history + messages
74
- return self.graph.invoke({"messages": initial_state})