File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace NeuronAI \Tools \Toolkits ;
6+
7+ use NeuronAI \Chat \Messages \UserMessage ;
8+ use NeuronAI \RAG \Retrieval \RetrievalInterface ;
9+ use NeuronAI \Tools \PropertyType ;
10+ use NeuronAI \Tools \Tool ;
11+ use NeuronAI \Tools \ToolProperty ;
12+
13+ class RetrievalTool extends Tool
14+ {
15+ public function __construct (
16+ protected RetrievalInterface $ retrieval
17+ ) {
18+ parent ::__construct (
19+ name: 'context_retrieval ' ,
20+ description: 'Search for documents similar to a given query. ' ,
21+ );
22+ }
23+
24+ protected function properties (): array
25+ {
26+ return [
27+ new ToolProperty (
28+ name: 'query ' ,
29+ type: PropertyType::STRING ,
30+ description: 'The query to retrieve documents for. ' ,
31+ required: true
32+ )
33+ ];
34+ }
35+
36+ public function __invoke (string $ query ): array
37+ {
38+ return $ this ->retrieval ->retrieve (new UserMessage ($ query ));
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments