Spaces:
Configuration error
Configuration error
Updated post-processing of job call summary from model - converted to Python dictionary.
Browse files- functions/job_call.py +6 -17
functions/job_call.py
CHANGED
@@ -101,10 +101,11 @@ def summarize_job_call(job_call: str) -> str:
|
|
101 |
|
102 |
if response is not None:
|
103 |
summary = response.choices[0].message.content
|
|
|
104 |
|
105 |
# Save the extracted job call information to data directory
|
106 |
try:
|
107 |
-
_save_job_call_data(
|
108 |
|
109 |
except Exception as save_error:
|
110 |
logger.warning("Failed to save job call data: %s", str(save_error))
|
@@ -115,14 +116,14 @@ def summarize_job_call(job_call: str) -> str:
|
|
115 |
return summary
|
116 |
|
117 |
|
118 |
-
def _save_job_call_data(
|
119 |
"""
|
120 |
Save job call data (original and extracted summary) to the data/job_calls directory.
|
121 |
|
122 |
Args:
|
123 |
-
original_job_call (str): The original job call text
|
124 |
extracted_summary (str): The extracted/summarized job call information
|
125 |
"""
|
|
|
126 |
try:
|
127 |
# Get the project root directory and job_calls subdirectory
|
128 |
project_root = Path(__file__).parent.parent
|
@@ -136,21 +137,9 @@ def _save_job_call_data(original_job_call: str, extracted_summary: str) -> None:
|
|
136 |
filename = f"job_call_extracted_{timestamp}.json"
|
137 |
file_path = job_calls_dir / filename
|
138 |
|
139 |
-
# Prepare data to save
|
140 |
-
job_call_data = {
|
141 |
-
"timestamp": datetime.now().isoformat(),
|
142 |
-
"original_job_call": original_job_call,
|
143 |
-
"extracted_summary": extracted_summary,
|
144 |
-
"metadata": {
|
145 |
-
"original_length": len(original_job_call),
|
146 |
-
"summary_length": len(extracted_summary) if extracted_summary else 0,
|
147 |
-
"extraction_successful": extracted_summary is not None
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
# Save to JSON file
|
152 |
-
with open(file_path, 'w', encoding='utf-8') as
|
153 |
-
json.dump(
|
154 |
|
155 |
logger.info("Saved job call data to: %s", file_path)
|
156 |
|
|
|
101 |
|
102 |
if response is not None:
|
103 |
summary = response.choices[0].message.content
|
104 |
+
summary = json.loads(summary)
|
105 |
|
106 |
# Save the extracted job call information to data directory
|
107 |
try:
|
108 |
+
_save_job_call_data(summary)
|
109 |
|
110 |
except Exception as save_error:
|
111 |
logger.warning("Failed to save job call data: %s", str(save_error))
|
|
|
116 |
return summary
|
117 |
|
118 |
|
119 |
+
def _save_job_call_data(extracted_summary: str) -> None:
|
120 |
"""
|
121 |
Save job call data (original and extracted summary) to the data/job_calls directory.
|
122 |
|
123 |
Args:
|
|
|
124 |
extracted_summary (str): The extracted/summarized job call information
|
125 |
"""
|
126 |
+
|
127 |
try:
|
128 |
# Get the project root directory and job_calls subdirectory
|
129 |
project_root = Path(__file__).parent.parent
|
|
|
137 |
filename = f"job_call_extracted_{timestamp}.json"
|
138 |
file_path = job_calls_dir / filename
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
# Save to JSON file
|
141 |
+
with open(file_path, 'w', encoding='utf-8') as output_file:
|
142 |
+
json.dump(extracted_summary, output_file)
|
143 |
|
144 |
logger.info("Saved job call data to: %s", file_path)
|
145 |
|