Spaces:
Sleeping
Sleeping
bsiddhharth
commited on
Commit
·
46cb87d
1
Parent(s):
70085b0
updated resume_advance_analysis.py
Browse files- resume_advance_analysis.py +1 -59
resume_advance_analysis.py
CHANGED
@@ -141,62 +141,4 @@ class ResumeImprovementEngine:
|
|
141 |
st.error(f"JSON Extraction Error: {e}")
|
142 |
# logger.error(f"JSON Extraction Error: {e}")
|
143 |
return {}
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
# def _extract_json(self, text: str) -> Dict[str, Any]:
|
149 |
-
# """
|
150 |
-
# Safely extract JSON from LLM response with robust error handling
|
151 |
-
|
152 |
-
# Args:
|
153 |
-
# text (str): LLM response text
|
154 |
-
|
155 |
-
# Returns:
|
156 |
-
# Dict of extracted JSON or empty dict
|
157 |
-
# """
|
158 |
-
# try:
|
159 |
-
# logger.debug("Attempting to extract JSON from response text.")
|
160 |
-
|
161 |
-
# # Clean the text and remove any non-JSON characters
|
162 |
-
# # Remove text before first '{' and after last '}'
|
163 |
-
# cleaned_text = text.strip()
|
164 |
-
# first_brace = cleaned_text.find('{')
|
165 |
-
# last_brace = cleaned_text.rfind('}')
|
166 |
-
|
167 |
-
# if first_brace != -1 and last_brace != -1:
|
168 |
-
# cleaned_text = cleaned_text[first_brace:last_brace+1]
|
169 |
-
|
170 |
-
# # Extraction strategies
|
171 |
-
# extraction_strategies = [
|
172 |
-
# # Direct parsing of cleaned text
|
173 |
-
# lambda t: json.loads(t),
|
174 |
-
|
175 |
-
# # Remove non-printable characters and try parsing
|
176 |
-
# lambda t: json.loads(re.sub(r'[^\x20-\x7E\n]', '', t)),
|
177 |
-
|
178 |
-
# # Extract JSON within code block
|
179 |
-
# lambda t: json.loads(re.search(r'```json\n(.*?)```', t, re.DOTALL).group(1) if re.search(r'```json\n(.*?)```', t, re.DOTALL) else '')
|
180 |
-
# ]
|
181 |
-
|
182 |
-
# # Try each extraction strategy
|
183 |
-
# for strategy in extraction_strategies:
|
184 |
-
# try:
|
185 |
-
# parsed_json = strategy(cleaned_text)
|
186 |
-
|
187 |
-
# # Additional validation to ensure it's a dictionary
|
188 |
-
# if isinstance(parsed_json, dict):
|
189 |
-
# logger.info("Successfully extracted and parsed JSON.")
|
190 |
-
# return parsed_json
|
191 |
-
# except (json.JSONDecodeError, AttributeError, IndexError):
|
192 |
-
# continue
|
193 |
-
|
194 |
-
# # Detailed logging for troubleshooting
|
195 |
-
# logger.warning(f"Could not extract valid JSON. Raw text: {text}")
|
196 |
-
# return {}
|
197 |
-
|
198 |
-
# except Exception as e:
|
199 |
-
# # Log the full error details
|
200 |
-
# logger.error(f"JSON Extraction Error: {e}", exc_info=True)
|
201 |
-
# st.error(f"JSON Extraction Error: {e}")
|
202 |
-
# return {}
|
|
|
141 |
st.error(f"JSON Extraction Error: {e}")
|
142 |
# logger.error(f"JSON Extraction Error: {e}")
|
143 |
return {}
|
144 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|