Ntabukiraniro commited on
Commit
c4e2fe1
1 Parent(s): abe1c0a

Update initialization.py

Browse files
Files changed (1) hide show
  1. initialization.py +50 -36
initialization.py CHANGED
@@ -27,53 +27,67 @@ def resume_reader(resume):
27
 
28
  def initialize_session_state(template=None, position=None):
29
  """ initialize session states """
30
- print("Initializing session state...")
31
-
32
  if 'jd' in st.session_state:
33
- print("Using job description for embedding...")
34
  st.session_state.docsearch = embedding(st.session_state.jd)
35
  else:
36
- print("Using resume for embedding...")
37
  st.session_state.docsearch = embedding(resume_reader(st.session_state.resume))
38
 
39
- print("Creating retriever...")
40
  st.session_state.retriever = st.session_state.docsearch.as_retriever(search_type="similarity")
41
-
42
  if 'jd' in st.session_state:
43
- print("Using job description prompt template...")
44
  Interview_Prompt = PromptTemplate(input_variables=["context", "question"],
45
- template=template)
46
  st.session_state.chain_type_kwargs = {"prompt": Interview_Prompt}
47
  else:
48
- print("Using position-specific prompt template...")
49
- st.session_state.chain_type_kwargs = prompt_sector(position, templates)
50
-
51
- print("Creating memory...")
52
  st.session_state.memory = ConversationBufferMemory()
53
-
54
- print("Initializing history and token count...")
55
  st.session_state.history = []
 
 
56
  st.session_state.token_count = 0
57
-
58
- print("Creating screen chain...")
59
- llm = ChatOpenAI(model_name="gpt-3.5-turbo", temperature=0.8)
 
 
 
 
 
 
 
 
 
 
 
60
  PROMPT = PromptTemplate(
61
- input_variables=["history", "input"],
62
- template="""I want you to act as an interviewer strictly following the guideline in the current conversation.
63
- Ask me questions and wait for my answers like a real person.
64
- Do not write explanations.
65
- Ask question like a real person, only one question at a time.
66
- Do not ask the same question.
67
- Do not repeat the question.
68
- Do ask follow-up questions if necessary.
69
- You name is GPTInterviewer.
70
- I want you to only reply as an interviewer.
71
- Do not write all the conversation at once.
72
- If there is an error, point it out.
73
- Current Conversation:
74
- {history}
75
- Candidate: {input}
76
- AI: """)
77
- st.session_state.screen = ConversationChain(prompt=PROMPT, llm=llm, memory=st.session_state.memory)
78
-
79
- print("Session state initialized.")
 
 
 
 
 
 
 
 
 
27
 
28
  def initialize_session_state(template=None, position=None):
29
  """ initialize session states """
 
 
30
  if 'jd' in st.session_state:
 
31
  st.session_state.docsearch = embedding(st.session_state.jd)
32
  else:
 
33
  st.session_state.docsearch = embedding(resume_reader(st.session_state.resume))
34
 
35
+ #if 'retriever' not in st.session_state:
36
  st.session_state.retriever = st.session_state.docsearch.as_retriever(search_type="similarity")
37
+ #if 'chain_type_kwargs' not in st.session_state:
38
  if 'jd' in st.session_state:
 
39
  Interview_Prompt = PromptTemplate(input_variables=["context", "question"],
40
+ template=template)
41
  st.session_state.chain_type_kwargs = {"prompt": Interview_Prompt}
42
  else:
43
+ st.session_state.chain_type_kwargs = prompt_sector(position, templates)
44
+ #if 'memory' not in st.session_state:
 
 
45
  st.session_state.memory = ConversationBufferMemory()
46
+ # interview history
47
+ #if "history" not in st.session_state:
48
  st.session_state.history = []
49
+ # token count
50
+ #if "token_count" not in st.session_state:
51
  st.session_state.token_count = 0
52
+ #if "guideline" not in st.session_state:
53
+ llm = ChatOpenAI(
54
+ model_name="gpt-3.5-turbo",
55
+ temperature=0.6, )
56
+ st.session_state.guideline = RetrievalQA.from_chain_type(
57
+ llm=llm,
58
+ chain_type_kwargs=st.session_state.chain_type_kwargs, chain_type='stuff',
59
+ retriever=st.session_state.retriever, memory=st.session_state.memory).run(
60
+ "Create an interview guideline and prepare only one questions for each topic. Make sure the questions tests the technical knowledge")
61
+ # llm chain and memory
62
+ #if "screen" not in st.session_state:
63
+ llm = ChatOpenAI(
64
+ model_name="gpt-3.5-turbo",
65
+ temperature=0.8, )
66
  PROMPT = PromptTemplate(
67
+ input_variables=["history", "input"],
68
+ template="""I want you to act as an interviewer strictly following the guideline in the current conversation.
69
+ Ask me questions and wait for my answers like a real person.
70
+ Do not write explanations.
71
+ Ask question like a real person, only one question at a time.
72
+ Do not ask the same question.
73
+ Do not repeat the question.
74
+ Do ask follow-up questions if necessary.
75
+ You name is GPTInterviewer.
76
+ I want you to only reply as an interviewer.
77
+ Do not write all the conversation at once.
78
+ If there is an error, point it out.
79
+ Current Conversation:
80
+ {history}
81
+ Candidate: {input}
82
+ AI: """)
83
+ st.session_state.screen = ConversationChain(prompt=PROMPT, llm=llm,
84
+ memory=st.session_state.memory)
85
+ #if "feedback" not in st.session_state:
86
+ llm = ChatOpenAI(
87
+ model_name = "gpt-3.5-turbo",
88
+ temperature = 0.5,)
89
+ st.session_state.feedback = ConversationChain(
90
+ prompt=PromptTemplate(input_variables = ["history", "input"], template = templates.feedback_template),
91
+ llm=llm,
92
+ memory = st.session_state.memory,
93
+ )