Skip to content

3.0.10

Choose a tag to compare

@ilvalerione ilvalerione released this 03 Mar 18:12
· 133 commits to 3.x since this release

Retrieval as a tool

Built-in tool to build agents with on-demand RAG (Retrieval Augmented Generation)
capabilities instead of the authomatic context injection provided by the RAG component.

use NeuronAI\Tools\Toolkits\RetrievalTool;
use NeuronAI\RAG\Retrieval\SimilarityRetrieval;

class AgenticRAG extends Agent
{
    protected function provider(): AIProviderInterface
    {...}
    
    protected function instructions(): string
    {...}
    
    protected function tools(): array
    {
        return [
            RetrievalTool::make(
                new SimilarityRetrieval(
                    $this->vectorStore(), 
                    $this->embeddings()
                )
            ),
        ];
    }
    
    protected function vectorStore(): VectorStoreInterface
    {
        return new FileVectorStore(__DIR__);
    }
    
    protected function embeddings(): EmbeddingsProviderInterface
    {
        return new OllamaEmbeddingsProvider(
            model: 'OLLAMA_EMBEDDINGS_MODEL'
        );
    }
}

Learn more on the documentation.