@@ -35,9 +35,6 @@ $app = (new SingleCommandApplication('LLM Chain Example Runner'))
35
35
$ process ->start ();
36
36
}
37
37
38
- $ examplesRunning = fn () => array_reduce ($ exampleRuns , fn ($ running , $ example ) => $ running || $ example ['process ' ]->isRunning (), false );
39
- $ examplesSuccessful = fn () => array_reduce ($ exampleRuns , fn ($ successful , $ example ) => $ successful && $ example ['process ' ]->isSuccessful (), true );
40
-
41
38
$ section = $ output ->section ();
42
39
$ renderTable = function () use ($ exampleRuns , $ section ) {
43
40
$ section ->clear ();
@@ -64,21 +61,37 @@ $app = (new SingleCommandApplication('LLM Chain Example Runner'))
64
61
$ table ->render ();
65
62
};
66
63
64
+ $ examplesRunning = fn () => array_reduce ($ exampleRuns , fn ($ running , $ example ) => $ running || $ example ['process ' ]->isRunning (), false );
67
65
while ($ examplesRunning ()) {
68
66
$ renderTable ();
69
67
sleep (1 );
70
68
}
71
69
72
70
$ renderTable ();
73
-
74
71
$ io ->newLine ();
75
- if (!$ examplesSuccessful ()) {
76
- $ io ->error ('Some examples failed or were skipped! ' );
77
72
78
- return Command::FAILURE ;
73
+ $ successCount = array_reduce ($ exampleRuns , function ($ count , $ example ) {
74
+ if ($ example ['process ' ]->isSuccessful () && strlen (trim ($ example ['process ' ]->getOutput ())) > 0 ) {
75
+ return $ count + 1 ;
76
+ }
77
+ return $ count ;
78
+ }, 0 );
79
+
80
+ $ totalCount = count ($ exampleRuns );
81
+
82
+ if ($ successCount < $ totalCount ) {
83
+ $ io ->warning (sprintf ('%d out of %d examples ran successfully. ' , $ successCount , $ totalCount ));
84
+ } else {
85
+ $ io ->success (sprintf ('All %d examples ran successfully! ' , $ totalCount ));
79
86
}
80
87
81
- $ io ->success ('All examples ran successfully! ' );
88
+ foreach ($ exampleRuns as $ run ) {
89
+ if (!$ run ['process ' ]->isSuccessful ()) {
90
+ $ io ->section ('Error in ' . $ run ['example ' ]->getFilename ());
91
+ $ io ->text ($ run ['process ' ]->getOutput ());
92
+ $ io ->text ($ run ['process ' ]->getErrorOutput ());
93
+ }
94
+ }
82
95
83
96
return Command::SUCCESS ;
84
97
})
0 commit comments