Spaces:
Sleeping
Sleeping
Update utils/mistral.py
Browse files- utils/mistral.py +12 -18
utils/mistral.py
CHANGED
@@ -102,13 +102,12 @@ def Model_ProfessionalDetails_Output(resume, client):
|
|
102 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=4096, stream=True):#, temperature=0.35):
|
103 |
# response += message.choices[0].delta.content
|
104 |
|
105 |
-
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
106 |
-
print("This is without stream data ",data.choices[0].message.content)
|
107 |
response = data.choices[0].message.content
|
108 |
|
109 |
try:
|
110 |
clean_response = Data_Cleaner(response)
|
111 |
-
print("This is clean_response data ",clean_response)
|
112 |
parsed_response = json.loads(clean_response)
|
113 |
except json.JSONDecodeError as e:
|
114 |
logging.error(f"JSON Decode Error: {e}")
|
@@ -142,13 +141,12 @@ def Model_EducationalDetails_Output(resume, client):
|
|
142 |
#response = ""
|
143 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=4096, stream=True):#, temperature=0.35):
|
144 |
# response += message.choices[0].delta.content
|
145 |
-
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
146 |
-
print("This is without stream data ",data.choices[0].message.content)
|
147 |
response = data.choices[0].message.content
|
148 |
|
149 |
try:
|
150 |
clean_response = Data_Cleaner(response)
|
151 |
-
print("This is clean_response data ",clean_response)
|
152 |
parsed_response = json.loads(clean_response)
|
153 |
except json.JSONDecodeError as e:
|
154 |
logging.error(f"JSON Decode Error: {e}")
|
@@ -182,17 +180,16 @@ def Model_PersonalDetails_Output(resume, client):
|
|
182 |
# Response
|
183 |
#response = ""
|
184 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=True):#, temperature=0.35):
|
185 |
-
#
|
186 |
|
187 |
-
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
188 |
-
print("This is without stream data ",data.choices[0].message.content)
|
189 |
response = data.choices[0].message.content
|
190 |
|
191 |
# Handle cases where the response might have formatting issues
|
192 |
try:
|
193 |
#print('The Og response:-->',response)
|
194 |
clean_response=Data_Cleaner(response)
|
195 |
-
print("This is clean_response data ",clean_response)
|
196 |
parsed_response = json.loads(clean_response)
|
197 |
|
198 |
except json.JSONDecodeError as e:
|
@@ -202,7 +199,6 @@ def Model_PersonalDetails_Output(resume, client):
|
|
202 |
|
203 |
return parsed_response
|
204 |
|
205 |
-
|
206 |
# # Fallback to SpaCy if Mistral fails
|
207 |
|
208 |
# Add regex pattern for LinkedIn and GitHub links
|
@@ -354,7 +350,6 @@ def is_valid_contact(contact):
|
|
354 |
# Check if the contact matches any of the patterns
|
355 |
return any(re.match(pattern, contact) for pattern in patterns) is not None
|
356 |
|
357 |
-
|
358 |
def validate_contact_email(personal_data):
|
359 |
contact = personal_data.get('contact', [])
|
360 |
email = personal_data.get('email', [])
|
@@ -467,8 +462,7 @@ def process_resume_data(file_path):
|
|
467 |
]
|
468 |
}
|
469 |
}
|
470 |
-
|
471 |
-
|
472 |
|
473 |
#Appending the list if any available as a text
|
474 |
if result['personal']['other_links'] is not None:
|
@@ -476,10 +470,10 @@ def process_resume_data(file_path):
|
|
476 |
|
477 |
#Added the validator for details, Validate contact and email
|
478 |
#valid_contact, invalid_contact, valid_email, invalid_email = validate_contact_email(result['personal'])
|
479 |
-
#result['personal']['valid_contact'] =
|
480 |
-
|
481 |
-
#result['personal']['valid_email'] =
|
482 |
-
|
483 |
|
484 |
#Appending the Educational Details if any available as a text
|
485 |
|
|
|
102 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=4096, stream=True):#, temperature=0.35):
|
103 |
# response += message.choices[0].delta.content
|
104 |
|
105 |
+
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
|
|
106 |
response = data.choices[0].message.content
|
107 |
|
108 |
try:
|
109 |
clean_response = Data_Cleaner(response)
|
110 |
+
print("This is clean_response data----> ",clean_response)
|
111 |
parsed_response = json.loads(clean_response)
|
112 |
except json.JSONDecodeError as e:
|
113 |
logging.error(f"JSON Decode Error: {e}")
|
|
|
141 |
#response = ""
|
142 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=4096, stream=True):#, temperature=0.35):
|
143 |
# response += message.choices[0].delta.content
|
144 |
+
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
|
|
145 |
response = data.choices[0].message.content
|
146 |
|
147 |
try:
|
148 |
clean_response = Data_Cleaner(response)
|
149 |
+
print("This is clean_response data----> ",clean_response)
|
150 |
parsed_response = json.loads(clean_response)
|
151 |
except json.JSONDecodeError as e:
|
152 |
logging.error(f"JSON Decode Error: {e}")
|
|
|
180 |
# Response
|
181 |
#response = ""
|
182 |
#for message in client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=True):#, temperature=0.35):
|
183 |
+
#response += message.choices[0].delta.content
|
184 |
|
185 |
+
data = client.chat_completion(messages=[system_role, user_prompt], max_tokens=3000, stream=False, temperature=0.35)
|
|
|
186 |
response = data.choices[0].message.content
|
187 |
|
188 |
# Handle cases where the response might have formatting issues
|
189 |
try:
|
190 |
#print('The Og response:-->',response)
|
191 |
clean_response=Data_Cleaner(response)
|
192 |
+
print("This is clean_response data----> ",clean_response)
|
193 |
parsed_response = json.loads(clean_response)
|
194 |
|
195 |
except json.JSONDecodeError as e:
|
|
|
199 |
|
200 |
return parsed_response
|
201 |
|
|
|
202 |
# # Fallback to SpaCy if Mistral fails
|
203 |
|
204 |
# Add regex pattern for LinkedIn and GitHub links
|
|
|
350 |
# Check if the contact matches any of the patterns
|
351 |
return any(re.match(pattern, contact) for pattern in patterns) is not None
|
352 |
|
|
|
353 |
def validate_contact_email(personal_data):
|
354 |
contact = personal_data.get('contact', [])
|
355 |
email = personal_data.get('email', [])
|
|
|
462 |
]
|
463 |
}
|
464 |
}
|
465 |
+
|
|
|
466 |
|
467 |
#Appending the list if any available as a text
|
468 |
if result['personal']['other_links'] is not None:
|
|
|
470 |
|
471 |
#Added the validator for details, Validate contact and email
|
472 |
#valid_contact, invalid_contact, valid_email, invalid_email = validate_contact_email(result['personal'])
|
473 |
+
#result['personal']['valid_contact'] = None
|
474 |
+
result['personal']['invalid_contact'] = None
|
475 |
+
#result['personal']['valid_email'] = None
|
476 |
+
result['personal']['invalid_email'] = None
|
477 |
|
478 |
#Appending the Educational Details if any available as a text
|
479 |
|