xdragxt commited on
Commit
ea4e8b4
·
verified ·
1 Parent(s): 0f7321f

Update jarvis.py

Browse files
Files changed (1) hide show
  1. jarvis.py +4 -2
jarvis.py CHANGED
@@ -157,6 +157,7 @@ async def jarvis_trigger(client, message):
157
 
158
  success = False
159
  code = ""
 
160
  for attempt in range(1, 6):
161
  await progress_msg.edit(f"`Attempt {attempt}/5:` Thinking and generating code...\n- Executing prerequisite shell commands...")
162
 
@@ -172,8 +173,8 @@ async def jarvis_trigger(client, message):
172
  f"5. Make functions async when using bot methods\n\n"
173
  f"Output ONLY Python code, no explanations or markdown."
174
  )
175
- if attempt > 1:
176
- prompt += f"\n\nNote: Previous attempt failed with error: {str(e)}. Fix that issue this time."
177
 
178
  response = model.generate_content(prompt)
179
  code = clean_code_blocks(response.text.strip())
@@ -248,6 +249,7 @@ async def jarvis_trigger(client, message):
248
  break
249
 
250
  except Exception as e:
 
251
  await progress_msg.edit(f"❌ Attempt {attempt} Error: `{str(e)[:100]}...`")
252
 
253
  if not success:
 
157
 
158
  success = False
159
  code = ""
160
+ last_error = None
161
  for attempt in range(1, 6):
162
  await progress_msg.edit(f"`Attempt {attempt}/5:` Thinking and generating code...\n- Executing prerequisite shell commands...")
163
 
 
173
  f"5. Make functions async when using bot methods\n\n"
174
  f"Output ONLY Python code, no explanations or markdown."
175
  )
176
+ if attempt > 1 and last_error is not None:
177
+ prompt += f"\n\nNote: Previous attempt failed with error: {str(last_error)}. Fix that issue this time."
178
 
179
  response = model.generate_content(prompt)
180
  code = clean_code_blocks(response.text.strip())
 
249
  break
250
 
251
  except Exception as e:
252
+ last_error = e
253
  await progress_msg.edit(f"❌ Attempt {attempt} Error: `{str(e)[:100]}...`")
254
 
255
  if not success: