-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranscript_analysis.py
63 lines (44 loc) · 2.25 KB
/
transcript_analysis.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Import necessary modules
import aiohttp
import asyncio
import nest_asyncio
import time
import json
from dotenv import load_dotenv
# Apply nest_asyncio
nest_asyncio.apply()
llava_endpoint = os.getenv("LLAVA_ENDPOINT")
async def fetch(session, url, data):
async with session.post(url, data=data) as response:
return await response.text()
async def analyze(qualification, skills, experience, response_count = 1, result = []):
with open('transcripts/transcript.txt', 'r') as file:
s = file.read()
s += "This is the transcript of a candidate that applied to our organization."
prompts = [f"This is the minimum qualification required for the candidate - {qualification}. Does the candidate possess this qualification? Say yes if it explicitly mentioned that the candidate has either completed this qualification or a higher qualification, else say no. For reference, PhD > Masters > Bachelors > Undergraduate.",
f"These are the skills we require - {skills}. If the candidate has explicitly mentioned these skills, say yes. If even one skill is not explicitly mentioned, say no.",
f"This is the minimum work experience we expect - {experience}. Does the candidate have atleast these many years of experience?Say yes, if it explicitly says that the candidate's experience is equal to or more than the minimum experience, else say no."]
for prompt in prompts:
url = llava_endpoint
data = json.dumps({
"model": "llava:7b-v1.6-mistral-q5_K_M",
"prompt": s + prompt,
"stream": False,
"images": []
})
headers = {'Content-Type': 'application/json'}
async with aiohttp.ClientSession(headers=headers) as session:
tasks = []
for _ in range(response_count):
task = asyncio.create_task(fetch(session, url, data))
tasks.append(task)
responses = await asyncio.gather(*tasks)
# print(responses[0])
data = json.loads(responses[0])
str = data["response"]
print(str)
if('yes' in str.lower()):
result.append(1)
else:
result.append(0)
return result