Pulastya B commited on
Commit
4eacfaa
·
1 Parent(s): f5a1bc3

Fix SyntaxError: use attribute assignment instead of global agent recreation

Browse files
Files changed (1) hide show
  1. src/api/app.py +5 -10
src/api/app.py CHANGED
@@ -179,6 +179,9 @@ async def run_analysis(
179
  "timestamp": time.time()
180
  })
181
 
 
 
 
182
  try:
183
  # Agent's session memory should resolve file_path from context
184
  result = agent.analyze(
@@ -271,16 +274,8 @@ async def run_analysis(
271
  "timestamp": time.time()
272
  })
273
 
274
- # Recreate agent with progress callback
275
- global agent
276
- provider = os.getenv("LLM_PROVIDER", "mistral")
277
- use_compact = provider.lower() in ["mistral", "groq"]
278
- agent = DataScienceCopilot(
279
- reasoning_effort="medium",
280
- provider=provider,
281
- use_compact_prompts=use_compact,
282
- progress_callback=progress_callback
283
- )
284
 
285
  # Call existing agent logic
286
  logger.info(f"Starting analysis with task: {task_description}")
 
179
  "timestamp": time.time()
180
  })
181
 
182
+ # Set progress callback on existing agent
183
+ agent.progress_callback = progress_callback
184
+
185
  try:
186
  # Agent's session memory should resolve file_path from context
187
  result = agent.analyze(
 
274
  "timestamp": time.time()
275
  })
276
 
277
+ # Set progress callback on existing agent
278
+ agent.progress_callback = progress_callback
 
 
 
 
 
 
 
 
279
 
280
  # Call existing agent logic
281
  logger.info(f"Starting analysis with task: {task_description}")