File tree Expand file tree Collapse file tree 1 file changed +18
-14
lines changed Expand file tree Collapse file tree 1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -458,20 +458,24 @@ def codegen(
458
458
459
459
outputs = []
460
460
for _ in range (batch_size ):
461
- response = model .generate_content (
462
- "Please generate self-contained code to complete the following problem wrapped in a Python markdown block:"
463
- + f"\n ```python\n { prompt .strip ()} \n ```" ,
464
- generation_config = genai_config
465
- )
466
- try :
467
- output = response .candidates [0 ].content .parts [0 ].text
468
- outputs .append (output )
469
- except Exception as e :
470
- if "list index out of range" in str (e ):
471
- # append dummy response
472
- outputs .append ("NO_RESPONSE" )
473
- else :
474
- raise e
461
+ while True :
462
+ try :
463
+ response = model .generate_content (
464
+ "Please generate self-contained code to complete the following problem wrapped in a Python markdown block:"
465
+ + f"\n ```python\n { prompt .strip ()} \n ```" ,
466
+ generation_config = genai_config
467
+ )
468
+ output = response .candidates [0 ].content .parts [0 ].text
469
+ outputs .append (output )
470
+ break
471
+ except Exception as e :
472
+ if "list index out of range" in str (e ):
473
+ # append dummy response
474
+ outputs .append ("NO_RESPONSE" )
475
+ break
476
+ else :
477
+ print (e )
478
+ continue
475
479
476
480
return outputs
477
481
You can’t perform that action at this time.
0 commit comments