Skip to content

Commit fa71ae2

Browse files
committed
refactor agent interface
1 parent 20b422e commit fa71ae2

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

src/Agent.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@ class Agent implements AgentInterface
2222
*/
2323
protected string $instructions;
2424

25+
/**
26+
* @deprecated
27+
*/
2528
public function withInstructions(string $instructions): AgentInterface
2629
{
2730
$this->instructions = $instructions;
2831
return $this;
2932
}
3033

34+
public function setInstructions(string $instructions): AgentInterface
35+
{
36+
$this->instructions = $instructions;
37+
return $this;
38+
}
39+
3140
public function instructions(): string
3241
{
3342
return 'Your are a helpful and friendly AI agent built with Neuron PHP framework.';

src/AgentInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ public function withProvider(AIProviderInterface $provider): AgentInterface;
1818

1919
public function resolveProvider(): AIProviderInterface;
2020

21+
/**
22+
* @deprecated
23+
*/
2124
public function withInstructions(string $instructions): AgentInterface;
2225

26+
public function setInstructions(string $instructions): AgentInterface;
27+
2328
public function instructions(): string;
2429

2530
/**

src/HandleTools.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function bootstrapTools(): array
112112

113113
$instructions = $this->removeDelimitedContent($this->resolveInstructions(), '<TOOLS-GUIDELINES>', '</TOOLS-GUIDELINES>');
114114
if ($guidelines !== []) {
115-
$this->withInstructions(
115+
$this->setInstructions(
116116
$instructions.\PHP_EOL.'<TOOLS-GUIDELINES>'.\PHP_EOL.\implode(\PHP_EOL.\PHP_EOL, $guidelines).\PHP_EOL.'</TOOLS-GUIDELINES>'
117117
);
118118
}

src/RAG/RAG.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public function withDocumentsContext(array $documents): AgentInterface
109109
}
110110
$newInstructions .= '</EXTRA-CONTEXT>';
111111

112-
$this->withInstructions(\trim($newInstructions));
112+
$this->setInstructions(\trim($newInstructions));
113113

114114
return $this;
115115
}

tests/NeuronAITest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function instructions(): string
5050
}
5151
};
5252
$this->assertEquals('Hello', $agent->resolveInstructions());
53-
$agent->withInstructions('Hello2');
53+
$agent->setInstructions('Hello2');
5454
$this->assertEquals('Hello2', $agent->resolveInstructions());
5555
}
5656

0 commit comments

Comments
 (0)