Update extract_insights.py
Browse files- extract_insights.py +1 -71
extract_insights.py
CHANGED
@@ -213,74 +213,4 @@ async def process_synchronous_job(user_id,email,message_id,raw_text):
|
|
213 |
.insert(json.loads(completion.choices[0].message.content))
|
214 |
.execute()
|
215 |
)
|
216 |
-
|
217 |
-
return insert_data
|
218 |
-
# try:
|
219 |
-
|
220 |
-
# openai_tasks = []
|
221 |
-
# for ds in dataset.get('data'):
|
222 |
-
# user_id = ds.get('user_id')
|
223 |
-
|
224 |
-
# message_id = ds.get('message_id')
|
225 |
-
|
226 |
-
# receipt_text = ds.get('receipt_text')
|
227 |
-
# email = ds.get('email')
|
228 |
-
|
229 |
-
# text = adjust_prompt_tokens_v1(receipt_radar_prompt(receipt_text))
|
230 |
-
|
231 |
-
# task = {
|
232 |
-
# "custom_id": f"{message_id}*{user_id}*{email}",
|
233 |
-
# "method": "POST",
|
234 |
-
# "url": "/v1/chat/completions",
|
235 |
-
# "body": {
|
236 |
-
# "model": "gpt-4o-mini",
|
237 |
-
# "temperature": 0.1,
|
238 |
-
# "response_format": {
|
239 |
-
# "type": "json_object"
|
240 |
-
# },
|
241 |
-
# "messages": [
|
242 |
-
# {
|
243 |
-
# "role": "user",
|
244 |
-
# "content": text
|
245 |
-
# }
|
246 |
-
# ]
|
247 |
-
# }
|
248 |
-
# }
|
249 |
-
# openai_tasks.append(task)
|
250 |
-
|
251 |
-
# # Create batch file
|
252 |
-
# json_obj = io.BytesIO()
|
253 |
-
# for obj in openai_tasks:
|
254 |
-
# json_obj.write((json.dumps(obj) + '\n').encode('utf-8'))
|
255 |
-
|
256 |
-
# batch_file = client.files.create(
|
257 |
-
# file=json_obj,
|
258 |
-
# purpose="batch"
|
259 |
-
# )
|
260 |
-
|
261 |
-
# # Create batch job
|
262 |
-
# batch_job = client.batches.create(
|
263 |
-
# input_file_id=batch_file.id,
|
264 |
-
# endpoint="/v1/chat/completions",
|
265 |
-
# completion_window="24h"
|
266 |
-
# )
|
267 |
-
|
268 |
-
# # Update status in Supabase
|
269 |
-
# supabase.table("batch_processing_details").insert({
|
270 |
-
# "batch_job_status": False,
|
271 |
-
# "batch_job_id" : batch_job.id
|
272 |
-
# }).execute()
|
273 |
-
|
274 |
-
# for ds in dataset.get('data'):
|
275 |
-
# user_id = ds.get('user_id')
|
276 |
-
# message_id = ds.get('message_id')
|
277 |
-
# email = ds.get('email')
|
278 |
-
# supabase.table("gmail_receipts_data").update({"batch_id":batch_job.id}).eq('user_id',user_id).eq("message_id",message_id).eq("email",email).execute()
|
279 |
-
# print("Batch sent for processing")
|
280 |
-
# except Exception as e:
|
281 |
-
# logger.error(f"Error processing batch job {batch_job_id}: {str(e)}")
|
282 |
-
# # Update status with error
|
283 |
-
# supabase.table("batch_processing_details").insert({
|
284 |
-
# "batch_job_status": False,
|
285 |
-
# "error": str(e)
|
286 |
-
# }).execute()
|
|
|
213 |
.insert(json.loads(completion.choices[0].message.content))
|
214 |
.execute()
|
215 |
)
|
216 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|