Spaces:
Sleeping
Sleeping
Update main.py
Browse files22 unmodified lines2324252627282930313233343536373839404115 unmodified lines5758596061626364656667686970717273747576777879808182838422 unmodified linesbatch_id = body.get('batch_job_id')print(batch_id)# Add the processing task to background tasks# if batch_job.status == 'completed':# background_tasks.add_task(process_batch_data, batch_id)# return {"batch_job_status":'completed'}# Immediately return success response# return {'batch_job_status':'notcompleted'}insert_response = (supabase.table("batch_processing_details").update({"batch_job_status": True,}).eq('batch_job_id',batch_id).execute())return {'batch_job_status':'completed'}15 unmodified linesres.append(json_dict)except json.JSONDecodeError as e:print(f"Error decoding JSON on line: {line}\nError: {e}")for resp in res:id = resp.get('custom_id')res_id = id.split('-')[1]output = json.loads(resp.get('response').get('body').get('choices')[0].get('message').get('content'))categories = str(output.get('categories'))summary = str(output.get('summary'))supabase_resp = supabase.table("imdb_dataset").select("Description").eq("imdb_id", res_id).execute()description = supabase_resp.data[0].get('Description')insert_response = (supabase.table("imdb_outputs").insert({"id": res_id,"description": description,'categories': categories,'summary': summary}).execute())print(f"Inserted data for ID: {res_id}")except Exception as e:22 unmodified lines23242526272829303132333435363738394015 unmodified lines56575859606162636465666768697071727374757677787922 unmodified linesbatch_id = body.get('batch_job_id')print(batch_id)# Add the processing task to background tasksif batch_job.status == 'completed':background_tasks.add_task(process_batch_data, batch_id)insert_response = (supabase.table("batch_processing_details").update({"batch_job_status": True,}).eq('batch_job_id',batch_id).execute())return {"batch_job_status":'completed'}return {'batch_job_status':'completed'}15 unmodified linesres.append(json_dict)except json.JSONDecodeError as e:print(f"Error decoding JSON on line: {line}\nError: {e}")supa_data = []for resp in res:id = resp.get('custom_id').split('-')message_id = id[0]user_id = id[1]email = id[2]output = json.loads(resp.get('response').get('body').get('choices')[0].get('message').get('content'))supa_data.append(output)print("Printing the the data")print(supa_data)# insert_response = (# supabase.table("imdb_outputs")# .insert()# .execute()# )print(f"Inserted data for ID: {res_id}")except Exception as e:
main.py+21-26