|
13 | 13 | use Symfony\AI\Agent\Toolbox\AgentProcessor;
|
14 | 14 | use Symfony\AI\Agent\Toolbox\Tool\Platform;
|
15 | 15 | use Symfony\AI\Agent\Toolbox\Toolbox;
|
| 16 | +use Symfony\AI\Agent\Toolbox\ToolFactory\ChainFactory; |
| 17 | +use Symfony\AI\Agent\Toolbox\ToolFactory\MemoryToolFactory; |
| 18 | +use Symfony\AI\Agent\Toolbox\ToolFactory\ReflectionToolFactory; |
16 | 19 | use Symfony\AI\Platform\Bridge\ElevenLabs\PlatformFactory as ElevenLabsPlatformFactory;
|
17 | 20 | use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory;
|
18 | 21 | use Symfony\AI\Platform\Message\Content\Audio;
|
|
33 | 36 | // Wrap ElevenLabs platform as a tool
|
34 | 37 | $speechToText = new Platform($elevenLabsPlatform, 'scribe_v1');
|
35 | 38 |
|
| 39 | +// Use MemoryToolFactory to register the tool with metadata |
| 40 | +$memoryFactory = new MemoryToolFactory(); |
| 41 | +$memoryFactory->addTool( |
| 42 | + $speechToText, |
| 43 | + 'transcribe_audio', |
| 44 | + 'Transcribes audio files to text using ElevenLabs speech-to-text. Accepts audio file content.', |
| 45 | +); |
| 46 | + |
| 47 | +// Combine with ReflectionToolFactory using ChainFactory |
| 48 | +$chainFactory = new ChainFactory([ |
| 49 | + $memoryFactory, |
| 50 | + new ReflectionToolFactory(), |
| 51 | +]); |
| 52 | + |
36 | 53 | // Create toolbox with the platform tool
|
37 |
| -$toolbox = new Toolbox([$speechToText], logger: logger()); |
| 54 | +$toolbox = new Toolbox([$speechToText], toolFactory: $chainFactory, logger: logger()); |
38 | 55 | $processor = new AgentProcessor($toolbox);
|
39 | 56 |
|
40 | 57 | // Create agent with OpenAI platform but with ElevenLabs tool available
|
|
0 commit comments