Karan6124 commited on
Commit
b841b71
·
1 Parent(s): db48c8b

clean up celery_worker.py by removing rate-limit delays and logs for paid Gemini key

Browse files
Files changed (1) hide show
  1. app/workers/celery_worker.py +2 -7
app/workers/celery_worker.py CHANGED
@@ -52,7 +52,6 @@ def run_case_manager_task(self, case_id: str):
52
  """
53
  logger.info(f"Starting async agent investigation for case ID: {case_id}")
54
  db = SessionLocal()
55
- start_time = time.time()
56
 
57
  try:
58
  # 1. Fetch case context from database
@@ -77,7 +76,7 @@ def run_case_manager_task(self, case_id: str):
77
  # 3. Retrieve refreshed case context containing assigned hypothesis database IDs
78
  refreshed_context = ContextManager.get_context(db=db, case_id=case_id)
79
 
80
- # 4. Loop through hypotheses and execute ResearchAgent on each
81
  for hypothesis in refreshed_context.hypotheses:
82
  logger.info(f"Investigating Hypothesis: '{hypothesis.statement}' (ID: {hypothesis.id})")
83
 
@@ -133,10 +132,6 @@ def run_case_manager_task(self, case_id: str):
133
  hypothesis_id=hypothesis.id,
134
  status=verdict.get("status", "inconclusive")
135
  )
136
-
137
- # ADD A DELAY TO PREVENT RATE LIMITING
138
- logger.info("Sleeping for 12 seconds to respect OpenRouter Free Rate Limits...")
139
- time.sleep(12)
140
 
141
  # 5. Mark overall case status as completed
142
  ContextManager.update_status(db=db, case_id=case_id, status=CaseStatus.COMPLETED)
@@ -158,7 +153,7 @@ def run_case_manager_task(self, case_id: str):
158
  logger.error(f"Failed to set status to FAILED for case ID {case_id}: {str(rollback_err)}")
159
 
160
  try:
161
- raise self.retry(exc=e, countdown=60)
162
  except Exception as retry_err:
163
  logger.error(f"Task retry failed: {str(retry_err)}")
164
  return {"status": "failed", "error": str(e)}
 
52
  """
53
  logger.info(f"Starting async agent investigation for case ID: {case_id}")
54
  db = SessionLocal()
 
55
 
56
  try:
57
  # 1. Fetch case context from database
 
76
  # 3. Retrieve refreshed case context containing assigned hypothesis database IDs
77
  refreshed_context = ContextManager.get_context(db=db, case_id=case_id)
78
 
79
+ # 4. Loop through hypotheses and execute ResearchAgent on each (No delays since we are on paid Gemini API)
80
  for hypothesis in refreshed_context.hypotheses:
81
  logger.info(f"Investigating Hypothesis: '{hypothesis.statement}' (ID: {hypothesis.id})")
82
 
 
132
  hypothesis_id=hypothesis.id,
133
  status=verdict.get("status", "inconclusive")
134
  )
 
 
 
 
135
 
136
  # 5. Mark overall case status as completed
137
  ContextManager.update_status(db=db, case_id=case_id, status=CaseStatus.COMPLETED)
 
153
  logger.error(f"Failed to set status to FAILED for case ID {case_id}: {str(rollback_err)}")
154
 
155
  try:
156
+ raise self.retry(exc=e, countdown=10)
157
  except Exception as retry_err:
158
  logger.error(f"Task retry failed: {str(retry_err)}")
159
  return {"status": "failed", "error": str(e)}