|
14 | 14 | use Cortex\Events\AgentStepStart; |
15 | 15 | use Illuminate\Http\JsonResponse; |
16 | 16 | use Illuminate\Routing\Controller; |
| 17 | +use Cortex\LLM\Enums\StreamingProtocol; |
17 | 18 | use Cortex\LLM\Data\Messages\UserMessage; |
| 19 | +use Symfony\Component\HttpFoundation\StreamedResponse; |
18 | 20 |
|
19 | 21 | class AgentsController extends Controller |
20 | 22 | { |
@@ -77,7 +79,7 @@ public function invoke(string $agent, Request $request): JsonResponse |
77 | 79 | ]); |
78 | 80 | } |
79 | 81 |
|
80 | | - public function stream(string $agent, Request $request)//: void// : StreamedResponse |
| 82 | + public function stream(string $agent, Request $request): StreamedResponse |
81 | 83 | { |
82 | 84 | $agent = Cortex::agent($agent); |
83 | 85 |
|
@@ -120,16 +122,16 @@ public function stream(string $agent, Request $request)//: void// : StreamedResp |
120 | 122 | // // dump($chunk->toArray()); |
121 | 123 | // } |
122 | 124 |
|
123 | | - return $result->agUiStreamResponse(); |
| 125 | + return $result->streamResponse(StreamingProtocol::AGUI); |
124 | 126 | } catch (Throwable $e) { |
125 | 127 | dd($e); |
126 | 128 | } |
127 | 129 |
|
128 | | - dd([ |
129 | | - 'total_usage' => $agent->getTotalUsage()->toArray(), |
130 | | - 'steps' => $agent->getSteps()->toArray(), |
131 | | - 'parsed_output' => $agent->getParsedOutput(), |
132 | | - 'memory' => $agent->getMemory()->getMessages()->toArray(), |
133 | | - ]); |
| 130 | + // dd([ |
| 131 | + // 'total_usage' => $agent->getTotalUsage()->toArray(), |
| 132 | + // 'steps' => $agent->getSteps()->toArray(), |
| 133 | + // 'parsed_output' => $agent->getParsedOutput(), |
| 134 | + // 'memory' => $agent->getMemory()->getMessages()->toArray(), |
| 135 | + // ]); |
134 | 136 | } |
135 | 137 | } |
0 commit comments