Skip to content

Commit 5023df9

Browse files
committed
[Examples] Use simple math question in platform-as-tool example
Changed from complex philosophical question to the same simple math question used in agent-as-tool.php for consistency and clarity.
1 parent c96f8ce commit 5023df9

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

examples/openai/platform-as-tool.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
use Symfony\AI\Agent\Agent;
1313
use Symfony\AI\Agent\Toolbox\AgentProcessor;
1414
use Symfony\AI\Agent\Toolbox\Tool\Platform as PlatformTool;
15+
use Symfony\AI\Agent\Toolbox\Toolbox;
1516
use Symfony\AI\Agent\Toolbox\ToolFactory\ChainFactory;
1617
use Symfony\AI\Agent\Toolbox\ToolFactory\MemoryToolFactory;
1718
use Symfony\AI\Agent\Toolbox\ToolFactory\ReflectionToolFactory;
18-
use Symfony\AI\Agent\Toolbox\Toolbox;
1919
use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory;
2020
use Symfony\AI\Platform\Message\Message;
2121
use Symfony\AI\Platform\Message\MessageBag;
@@ -24,15 +24,15 @@
2424

2525
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
2626

27-
// Create a specialized OpenAI platform tool using gpt-4o for complex analysis
28-
$analysisTool = new PlatformTool($platform, 'gpt-4o');
27+
// Create a specialized OpenAI platform tool using gpt-4o for mathematical calculations
28+
$mathTool = new PlatformTool($platform, 'gpt-4o');
2929

3030
// Use MemoryToolFactory to register the tool with metadata
3131
$memoryFactory = new MemoryToolFactory();
3232
$memoryFactory->addTool(
33-
$analysisTool,
34-
'advanced_analysis',
35-
'Performs deep analysis and complex reasoning tasks using GPT-4o. Use this for tasks requiring sophisticated understanding.',
33+
$mathTool,
34+
'calculate',
35+
'Performs mathematical calculations using GPT-4o. Use this when you need to solve math problems or do arithmetic.',
3636
);
3737

3838
// Combine with ReflectionToolFactory using ChainFactory
@@ -42,13 +42,13 @@
4242
]);
4343

4444
// Create the main agent with gpt-4o-mini but with gpt-4o available as a tool
45-
$toolbox = new Toolbox([$analysisTool], toolFactory: $chainFactory, logger: logger());
45+
$toolbox = new Toolbox([$mathTool], toolFactory: $chainFactory, logger: logger());
4646
$processor = new AgentProcessor($toolbox);
4747
$agent = new Agent($platform, 'gpt-4o-mini', [$processor], [$processor], logger: logger());
4848

49-
// Ask a question that could benefit from advanced analysis
49+
// Ask a question that requires mathematical calculation
5050
$result = $agent->call(new MessageBag(Message::ofUser(
51-
'Analyze the philosophical implications of artificial consciousness and whether current AI systems exhibit any form of genuine understanding. Provide a detailed analysis.'
51+
'I have 15 apples and I want to share them equally among 4 friends. How many apples does each friend get and how many are left over?'
5252
)));
5353

5454
echo $result->getContent().\PHP_EOL;

0 commit comments

Comments
 (0)