Skip to content

Commit f7b125a

Browse files
committed
wip
1 parent b051882 commit f7b125a

File tree

7 files changed

+16
-20
lines changed

7 files changed

+16
-20
lines changed

src/Agents/Stages/AppendUsage.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Cortex\Agents\Stages;
66

77
use Closure;
8-
use Cortex\LLM\Data\Usage;
98
use Cortex\Contracts\Pipeable;
109
use Cortex\LLM\Data\ChatResult;
1110
use Cortex\Pipeline\RuntimeConfig;

src/Agents/Stages/HandleToolCalls.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Cortex\Support\Traits\CanPipe;
1515
use Illuminate\Support\Collection;
1616
use Cortex\LLM\Data\ChatGeneration;
17-
use Cortex\LLM\Data\ToolCallCollection;
1817
use Cortex\LLM\Data\ChatGenerationChunk;
1918
use Cortex\LLM\Data\Messages\ToolMessage;
2019

@@ -53,10 +52,7 @@ public function handlePipeable(mixed $payload, RuntimeConfig $config, Closure $n
5352

5453
// Track the next step before making the LLM call
5554
$config->context->addStep(
56-
new Step(
57-
number: $config->context->getCurrentStepNumber() + 1,
58-
toolCalls: new ToolCallCollection(),
59-
),
55+
new Step($config->context->getCurrentStepNumber() + 1),
6056
);
6157

6258
// Send the tool messages to the execution pipeline to get a new generation.

src/CortexServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function packageBooted(): void
5959
Cortex::registerAgent(new Agent(
6060
name: 'quote_of_the_day',
6161
prompt: 'Generate a quote of the day about {topic}.',
62-
llm: 'ollama/phi4',
62+
llm: 'ollama/gpt-oss:20b',
6363
output: [
6464
Schema::string('quote')
6565
->description("Don't include the author in the quote. Just a single sentence.")

src/Http/Controllers/AgentsController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ public function invoke(string $agent, Request $request): JsonResponse
2727
// );
2828
// });
2929
$agent->onStepEnd(function (AgentStepEnd $event): void {
30-
dump(
31-
sprintf('step end: %d', $event->config?->context?->getCurrentStepNumber()),
32-
$event->config?->toArray(),
33-
);
30+
// dump(
31+
// sprintf('step end: %d', $event->config?->context?->getCurrentStepNumber()),
32+
// $event->config?->toArray(),
33+
// );
3434
});
3535
$agent->onStepError(function (AgentStepError $event): void {
36-
dump(sprintf('step error: %d', $event->config?->context?->getCurrentStepNumber()));
37-
dump($event->exception->getMessage());
38-
dump($event->exception->getTraceAsString());
36+
// dump(sprintf('step error: %d', $event->config?->context?->getCurrentStepNumber()));
37+
// dump($event->exception->getMessage());
38+
// dump($event->exception->getTraceAsString());
3939
});
4040
$result = $agent->invoke(input: $request->all());
4141
} catch (Throwable $e) {

src/Pipeline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ public function invoke(mixed $payload = null, ?RuntimeConfig $config = null): mi
9090
/**
9191
* Ensures that all LLMs in the pipeline are streaming.
9292
*/
93-
public function stream(mixed $payload = null): mixed
93+
public function stream(mixed $payload = null, ?RuntimeConfig $config = null): mixed
9494
{
95-
return $this->enableStreaming()->invoke($payload);
95+
return $this->enableStreaming()->invoke($payload, $config);
9696
}
9797

98-
public function __invoke(mixed $payload = null): mixed
98+
public function __invoke(mixed $payload = null, ?RuntimeConfig $config = null): mixed
9999
{
100-
return $this->invoke($payload);
100+
return $this->invoke($payload, $config);
101101
}
102102

103103
/**

src/Pipeline/Context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
class Context extends Fluent
1717
{
1818
public const string STEPS_KEY = 'steps';
19+
1920
public const string CURRENT_STEP_KEY = 'current_step';
21+
2022
public const string USAGE_SO_FAR_KEY = 'usage_so_far';
23+
2124
public const string MESSAGE_HISTORY_KEY = 'message_history';
2225

2326
/**

src/Pipeline/RuntimeConfig.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace Cortex\Pipeline;
66

77
use Illuminate\Support\Str;
8-
use Cortex\Agents\Data\Step;
9-
use Illuminate\Support\Collection;
108
use Illuminate\Contracts\Support\Arrayable;
119

1210
/**

0 commit comments

Comments
 (0)