|
12 | 12 | use Symfony\AI\Agent\Agent; |
13 | 13 | use Symfony\AI\Agent\Toolbox\AgentProcessor; |
14 | 14 | use Symfony\AI\Agent\Toolbox\Tool\Platform as PlatformTool; |
15 | | -use Symfony\AI\Agent\Toolbox\Toolbox; |
16 | 15 | use Symfony\AI\Agent\Toolbox\ToolFactory\ChainFactory; |
17 | 16 | use Symfony\AI\Agent\Toolbox\ToolFactory\MemoryToolFactory; |
18 | 17 | use Symfony\AI\Agent\Toolbox\ToolFactory\ReflectionToolFactory; |
19 | | -use Symfony\AI\Platform\Bridge\ElevenLabs\PlatformFactory as ElevenLabsPlatformFactory; |
| 18 | +use Symfony\AI\Agent\Toolbox\Toolbox; |
20 | 19 | use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; |
21 | | -use Symfony\AI\Platform\Message\Content\Audio; |
22 | 20 | use Symfony\AI\Platform\Message\Message; |
23 | 21 | use Symfony\AI\Platform\Message\MessageBag; |
24 | 22 |
|
25 | 23 | require_once dirname(__DIR__).'/bootstrap.php'; |
26 | 24 |
|
27 | | -// Create the main OpenAI platform |
28 | | -$openAiPlatform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client()); |
29 | | - |
30 | | -// Create ElevenLabs platform as a tool for speech-to-text |
31 | | -$elevenLabsPlatform = ElevenLabsPlatformFactory::create( |
32 | | - apiKey: env('ELEVEN_LABS_API_KEY'), |
33 | | - httpClient: http_client() |
34 | | -); |
| 25 | +$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client()); |
35 | 26 |
|
36 | | -// Wrap ElevenLabs platform as a tool |
37 | | -$speechToText = new PlatformTool($elevenLabsPlatform, 'scribe_v1'); |
| 27 | +// Create a specialized OpenAI platform tool using gpt-4o for complex analysis |
| 28 | +$analysisTool = new PlatformTool($platform, 'gpt-4o'); |
38 | 29 |
|
39 | 30 | // Use MemoryToolFactory to register the tool with metadata |
40 | 31 | $memoryFactory = new MemoryToolFactory(); |
41 | 32 | $memoryFactory->addTool( |
42 | | - $speechToText, |
43 | | - 'transcribe_audio', |
44 | | - 'Transcribes audio files to text using ElevenLabs speech-to-text. Accepts audio file content.', |
| 33 | + $analysisTool, |
| 34 | + 'advanced_analysis', |
| 35 | + 'Performs deep analysis and complex reasoning tasks using GPT-4o. Use this for tasks requiring sophisticated understanding.', |
45 | 36 | ); |
46 | 37 |
|
47 | 38 | // Combine with ReflectionToolFactory using ChainFactory |
|
50 | 41 | new ReflectionToolFactory(), |
51 | 42 | ]); |
52 | 43 |
|
53 | | -// Create toolbox with the platform tool |
54 | | -$toolbox = new Toolbox([$speechToText], toolFactory: $chainFactory, logger: logger()); |
| 44 | +// 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()); |
55 | 46 | $processor = new AgentProcessor($toolbox); |
| 47 | +$agent = new Agent($platform, 'gpt-4o-mini', [$processor], [$processor], logger: logger()); |
56 | 48 |
|
57 | | -// Create agent with OpenAI platform but with ElevenLabs tool available |
58 | | -$agent = new Agent($openAiPlatform, 'gpt-4o-mini', [$processor], [$processor], logger: logger()); |
59 | | - |
60 | | -// The agent can now use ElevenLabs for speech-to-text while using OpenAI for reasoning |
61 | | -$audioPath = dirname(__DIR__, 2).'/fixtures/audio.mp3'; |
62 | | -$messages = new MessageBag( |
63 | | - Message::ofUser('I have an audio file. Please transcribe it and tell me what it says.'), |
64 | | - Message::ofUser(Audio::fromFile($audioPath)), |
65 | | -); |
66 | | - |
| 49 | +// Ask a question that could benefit from advanced analysis |
| 50 | +$messages = new MessageBag(Message::ofUser('Analyze the philosophical implications of artificial consciousness and whether current AI systems exhibit any form of genuine understanding. Provide a detailed analysis.')); |
67 | 51 | $result = $agent->call($messages); |
68 | 52 |
|
69 | 53 | echo $result->getContent().\PHP_EOL; |
0 commit comments