@@ -356,10 +356,20 @@ def create_prompt_input(persona, task, duration, test_input=None):
356
356
prompt_input += [persona .scratch .get_str_firstname ()]
357
357
return prompt_input
358
358
359
- def __func_clean_up (gpt_response , prompt = "" ):
360
- print (gpt_response )
361
- print ("-==- -==- -==- " )
359
+ def extract_numeric_part (k ):
360
+ # Use regular expression to find all digits
361
+ numeric_part = re .findall (r'\d+' , k )
362
+ # Join all found digits into a single string and convert to int
363
+ return int (numeric_part [0 ])
362
364
365
+ def __func_clean_up (gpt_response , prompt = "" ):
366
+
367
+ debug = True
368
+
369
+ if debug :
370
+ print (gpt_response )
371
+ print ("-==- -==- -==- " )
372
+ print ("(cleanup func): Enter function" )
363
373
# TODO SOMETHING HERE sometimes fails... See screenshot
364
374
temp = [i .strip () for i in gpt_response .split ("\n " )]
365
375
_cr = []
@@ -370,22 +380,49 @@ def __func_clean_up(gpt_response, prompt=""):
370
380
else :
371
381
_cr += [i ]
372
382
for count , i in enumerate (_cr ):
383
+ if debug :
384
+ print ("(cleanup func) Unpacking: " , i )
385
+
386
+ # Original version
387
+ # k = [j.strip() for j in i.split("(duration in minutes:")]
388
+
373
389
# Sometimes the simulation fails because it doesn't contain
374
390
# `duration in minutes` but only `duration`.
375
391
if "duration in minutes" in i :
376
392
k = [j .strip () for j in i .split ("(duration in minutes:" )]
377
393
else :
378
394
k = [j .strip () for j in i .split ("(duration:" )]
379
- # k = [j.strip() for j in i.split("(duration in minutes:")]
395
+
396
+ if debug :
397
+ print ("(cleanup func) Unpacked(k): " , k )
380
398
task = k [0 ]
381
399
if task [- 1 ] == "." :
382
400
task = task [:- 1 ]
383
- duration = int (k [1 ].split ("," )[0 ].strip ())
401
+ minutes = k [1 ].split ("," )[0 ]
402
+
403
+ if debug :
404
+ print ("(cleanup func): Minutes: " , minutes )
405
+ duration = extract_numeric_part (minutes )
406
+ if debug :
407
+ print ("(cleanup func): Duration: " , duration )
408
+
409
+ # Original version
410
+ # duration = int(k[1].split(",")[0].strip())
411
+
384
412
cr += [[task , duration ]]
413
+
414
+ if debug :
415
+ print ("(cleanup func) Unpacked(cr): " , cr )
385
416
417
+ if debug :
418
+ print ("(cleanup func) Prompt:" , prompt )
419
+
386
420
total_expected_min = int (prompt .split ("(total duration in minutes" )[- 1 ]
387
421
.split ("):" )[0 ].strip ())
388
422
423
+ if debug :
424
+ print ("(cleanup func) Expected Minutes:" , total_expected_min )
425
+
389
426
# TODO -- now, you need to make sure that this is the same as the sum of
390
427
# the current action sequence.
391
428
curr_min_slot = [["dummy" , - 1 ],] # (task_name, task_index)
@@ -439,8 +476,6 @@ def get_fail_safe():
439
476
prompt = generate_prompt (prompt_input , prompt_template )
440
477
fail_safe = get_fail_safe ()
441
478
442
- print ("?????" )
443
- print (prompt )
444
479
output = safe_generate_response (prompt , gpt_param , 5 , get_fail_safe (),
445
480
__func_validate , __func_clean_up )
446
481
@@ -454,11 +489,12 @@ def get_fail_safe():
454
489
IndexError: list index out of range
455
490
"""
456
491
457
- print ( "IMPORTANT VVV DEBUG" )
458
-
459
- # print (prompt_input )
492
+ # Some debugging prints
493
+ # print ("DEBUG")
494
+ # print("PROMPT:" )
460
495
# print (prompt)
461
- print (output )
496
+ # print("\nOUTPUT:")
497
+ # print (output)
462
498
463
499
fin_output = []
464
500
time_sum = 0
@@ -2913,23 +2949,4 @@ def get_fail_safe():
2913
2949
gpt_param = {"engine" : "gpt-35-turbo-0125" , "max_tokens" : 50 ,
2914
2950
"temperature" : 0 , "top_p" : 1 , "stream" : False ,
2915
2951
"frequency_penalty" : 0 , "presence_penalty" : 0 , "stop" : None }
2916
- return output , [output , prompt , gpt_param , prompt_input , fail_safe ]
2917
-
2918
-
2919
-
2920
-
2921
-
2922
-
2923
-
2924
-
2925
-
2926
-
2927
-
2928
-
2929
-
2930
-
2931
-
2932
-
2933
-
2934
-
2935
-
2952
+ return output , [output , prompt , gpt_param , prompt_input , fail_safe ]
0 commit comments