-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult.py
More file actions
43 lines (32 loc) · 1.36 KB
/
Copy pathresult.py
File metadata and controls
43 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from config import client, temp_path
from langchain.document_loaders import UnstructuredFileLoader
import json
result_candidate = []
def load_system_prompt():
loader = UnstructuredFileLoader("./prompts/result_system_2.txt")
docs = loader.load()
content = docs[0].page_content
return content
def result(parsed_job_details, parsed_candidates, process):
potential_candidate = generate_result(parsed_job_details, parsed_candidates)
if(potential_candidate is not None):
for id in potential_candidate['candidates_id']:
for candidate in parsed_candidates:
if (candidate['id'] == id):
result_candidate.append(candidate)
process.update(label="Completed", expanded=False, state="complete")
return result_candidate
def generate_result(parsed_job_details, parsed_candidates):
response = client.chat.completions.create(
model="gpt-3.5-turbo-1106",
messages=[{"role": "system", "content": f"{load_system_prompt()}"},
{"role": "user", "content": f"{parsed_job_details}, {parsed_candidates}"}],
response_format={"type": "json_object"},
temperature=0,
)
print(response)
if (response.choices[0].message.content == None):
return None
response_json = json.loads(
response.choices[0].message.content)
return response_json