Skip to content

Commit 736e23f

Browse files
committed
Changed capabilities to instructions
1 parent 98aa06c commit 736e23f

3 files changed

Lines changed: 46 additions & 46 deletions

File tree

src/Agents/Adapters/Anthropic.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ public function send(Conversation $conversation): array
102102
];
103103
}
104104

105-
$capabilities = [];
106-
foreach ($this->getAgent()->getCapabilities() as $name => $content) {
107-
$capabilities[] = "# " . $name . "\n\n" . $content;
105+
$instructions = [];
106+
foreach ($this->getAgent()->getInstructions() as $name => $content) {
107+
$instructions[] = "# " . $name . "\n\n" . $content;
108108
}
109109

110110
$collectedMessages = [];
@@ -114,7 +114,7 @@ public function send(Conversation $conversation): array
114114
[
115115
'model' => $this->model,
116116
'system' => $this->getAgent()->getDescription() .
117-
(empty($capabilities) ? '' : "\n\n" . implode("\n\n", $capabilities)),
117+
(empty($instructions) ? '' : "\n\n" . implode("\n\n", $instructions)),
118118
'messages' => $messages,
119119
'max_tokens' => $this->maxTokens,
120120
'temperature' => $this->temperature,

src/Agents/Agent.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Agent
1212
/**
1313
* @var array<string, string>
1414
*/
15-
protected array $capabilities;
15+
protected array $instructions;
1616

1717
/**
1818
* @var Adapter
@@ -29,7 +29,7 @@ class Agent
2929
public function __construct(Adapter $adapter)
3030
{
3131
$this->adapter = $adapter;
32-
$this->capabilities = [];
32+
$this->instructions = [];
3333
$this->description = '';
3434

3535
$this->adapter->setAgent($this);
@@ -49,28 +49,28 @@ public function setDescription(string $description): self
4949
}
5050

5151
/**
52-
* Set the agent's capabilities
52+
* Set the agent's instructions
5353
*
54-
* @param array<string, string> $capabilities
54+
* @param array<string, string> $instructions
5555
* @return self
5656
*/
57-
public function setCapabilities(array $capabilities): self
57+
public function setInstructions(array $instructions): self
5858
{
59-
$this->capabilities = $capabilities;
59+
$this->instructions = $instructions;
6060

6161
return $this;
6262
}
6363

6464
/**
65-
* Add a capability to the agent
65+
* Add an instruction to the agent
6666
*
6767
* @param string $name
6868
* @param string $content
6969
* @return self
7070
*/
71-
public function addCapability(string $name, string $content): self
71+
public function addInstruction(string $name, string $content): self
7272
{
73-
$this->capabilities[$name] = $content;
73+
$this->instructions[$name] = $content;
7474

7575
return $this;
7676
}
@@ -86,13 +86,13 @@ public function getDescription(): string
8686
}
8787

8888
/**
89-
* Get the agent's capabilities
89+
* Get the agent's instructions
9090
*
9191
* @return array<string, string>
9292
*/
93-
public function getCapabilities(): array
93+
public function getInstructions(): array
9494
{
95-
return $this->capabilities;
95+
return $this->instructions;
9696
}
9797

9898
/**

tests/Agents/AgentTest.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function testConstructor(): void
2424
{
2525
$this->assertSame($this->mockAdapter, $this->agent->getAdapter());
2626
$this->assertEquals('', $this->agent->getDescription());
27-
$this->assertEquals([], $this->agent->getCapabilities());
27+
$this->assertEquals([], $this->agent->getInstructions());
2828
}
2929

3030
public function testSetDescription(): void
@@ -37,61 +37,61 @@ public function testSetDescription(): void
3737
$this->assertEquals($description, $this->agent->getDescription());
3838
}
3939

40-
public function testSetCapabilities(): void
40+
public function testSetInstructions(): void
4141
{
42-
$capabilities = [
43-
'Capability 1' => 'This is capability 1',
44-
'Capability 2' => 'This is capability 2'
42+
$instructions = [
43+
'Instruction 1' => 'This is instruction 1',
44+
'Instruction 2' => 'This is instruction 2'
4545
];
4646

47-
$result = $this->agent->setCapabilities($capabilities);
47+
$result = $this->agent->setInstructions($instructions);
4848

4949
$this->assertSame($this->agent, $result);
50-
$this->assertEquals($capabilities, $this->agent->getCapabilities());
50+
$this->assertEquals($instructions, $this->agent->getInstructions());
5151
}
5252

53-
public function testAddCapability(): void
53+
public function testAddInstruction(): void
5454
{
55-
// Test adding a single capability
56-
$result = $this->agent->addCapability('Capability 1', 'This is capability 1');
55+
// Test adding a single instruction
56+
$result = $this->agent->addInstruction('Instruction 1', 'This is instruction 1');
5757
$this->assertSame($this->agent, $result);
5858
$this->assertEquals([
59-
'Capability 1' => 'This is capability 1'
60-
], $this->agent->getCapabilities());
59+
'Instruction 1' => 'This is instruction 1'
60+
], $this->agent->getInstructions());
6161

62-
// Test adding a duplicate capability (should update the content)
63-
$this->agent->addCapability('Capability 1', 'Updated content');
62+
// Test adding a duplicate instruction (should update the content)
63+
$this->agent->addInstruction('Instruction 1', 'Updated content');
6464
$this->assertEquals([
65-
'Capability 1' => 'Updated content'
66-
], $this->agent->getCapabilities());
65+
'Instruction 1' => 'Updated content'
66+
], $this->agent->getInstructions());
6767

68-
// Test adding a second capability
69-
$this->agent->addCapability('Capability 2', 'This is capability 2');
68+
// Test adding a second instruction
69+
$this->agent->addInstruction('Instruction 2', 'This is instruction 2');
7070
$this->assertEquals([
71-
'Capability 1' => 'Updated content',
72-
'Capability 2' => 'This is capability 2'
73-
], $this->agent->getCapabilities());
71+
'Instruction 1' => 'Updated content',
72+
'Instruction 2' => 'This is instruction 2'
73+
], $this->agent->getInstructions());
7474
}
7575

7676
public function testFluentInterface(): void
7777
{
7878
$description = 'Test Description';
79-
$capabilities = [
80-
'Cap 1' => 'Content 1',
81-
'Cap 2' => 'Content 2'
79+
$instructions = [
80+
'Instruction 1' => 'Content 1',
81+
'Instruction 2' => 'Content 2'
8282
];
8383

8484
$result = $this->agent
8585
->setDescription($description)
86-
->setCapabilities($capabilities)
87-
->addCapability('Cap 3', 'Content 3');
86+
->setInstructions($instructions)
87+
->addInstruction('Instruction 3', 'Content 3');
8888

8989
$this->assertSame($this->agent, $result);
9090
$this->assertEquals($description, $this->agent->getDescription());
9191
$this->assertEquals([
92-
'Cap 1' => 'Content 1',
93-
'Cap 2' => 'Content 2',
94-
'Cap 3' => 'Content 3'
95-
], $this->agent->getCapabilities());
92+
'Instruction 1' => 'Content 1',
93+
'Instruction 2' => 'Content 2',
94+
'Instruction 3' => 'Content 3'
95+
], $this->agent->getInstructions());
9696
}
9797
}

0 commit comments

Comments
 (0)