resources/boost/skills/neuron-rag-specialist/SKILL.md
Implement RAG (Retrieval-Augmented Generation) with Neuron AI including vector stores, embeddings providers, document loaders, and retrieval strategies. Use this skill whenever the user mentions RAG, retrieval, vector search, document retrieval, semantic search, knowledge bases, chat with documents, or wants to build AI systems that can query and understand external documents. Also trigger for tasks involving vector databases, embeddings, document chunking, or retrieval strategies.
npx skillsauth add neuron-core/neuron-laravel neuron-rag-specialistInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill helps you implement Retrieval-Augmented Generation (RAG) in Neuron AI. RAG extends the Agent class with document retrieval capabilities.
RAG systems in Neuron AI consist of three main components:
use NeuronAI\RAG\RAG;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\RAG\Embeddings\EmbeddingsProviderInterface;
use NeuronAI\RAG\Embeddings\OpenAIEmbeddingProvider;
use NeuronAI\RAG\VectorStore\VectorStoreInterface;
use NeuronAI\RAG\VectorStore\PineconeVectorStore;
class MyChatBot extends RAG
{
protected function provider(): AIProviderInterface
{
return new Anthropic(
key: $_ENV['ANTHROPIC_API_KEY'],
model: 'claude-3-5-sonnet-20241022',
);
}
protected function embeddings(): EmbeddingsProviderInterface
{
return new OpenAIEmbeddingProvider(
key: $_ENV['OPENAI_API_KEY'],
model: 'text-embedding-3-small',
);
}
protected function vectorStore(): VectorStoreInterface
{
return new PineconeVectorStore(
key: $_ENV['PINECONE_API_KEY'],
indexUrl: $_ENV['PINECONE_INDEX_URL']
);
}
}
use NeuronAI\RAG\VectorStore\PineconeVectorStore;
new PineconeVectorStore(
key: $_ENV['PINECONE_API_KEY'],
indexUrl: $_ENV['PINECONE_INDEX_URL'],
environment: 'us-east-1-aws'
);
use NeuronAI\RAG\VectorStore\ChromaVectorStore;
new ChromaVectorStore(
host: 'localhost',
port: 8000,
collection: 'my_collection'
);
use NeuronAI\RAG\VectorStore\QdrantVectorStore;
new QdrantVectorStore(
apiKey: $_ENV['QDRANT_API_KEY'],
url: $_ENV['QDRANT_URL'],
collection: 'my_collection'
);
use NeuronAI\RAG\VectorStore\ElasticsearchVectorStore;
new ElasticsearchVectorStore(
hosts: ['http://localhost:9200'],
index: 'documents'
);
use NeuronAI\RAG\VectorStore\TypesenseVectorStore;
new TypesenseVectorStore(
apiKey: $_ENV['TYPESENSE_API_KEY'],
nodes: [['host' => 'localhost', 'port' => 8108]],
collection: 'documents'
);
MemoryVectorStore - In-memory for testingMilvusVectorStore - Milvus databaseRedisVectorStore - Redis with RediSearchWeaviateVectorStore - Weaviate databasePgVectorStore - PostgreSQL with pgvector extensionuse NeuronAI\RAG\Embeddings\OpenAIEmbeddingProvider;
new OpenAIEmbeddingProvider(
key: $_ENV['OPENAI_API_KEY'],
model: 'text-embedding-3-small' // or 'text-embedding-3-large'
);
use NeuronAI\RAG\Embeddings\OllamaEmbeddingProvider;
new OllamaEmbeddingProvider(
baseUrl: 'http://localhost:11434',
model: 'nomic-embed-text'
);
use NeuronAI\RAG\Embeddings\GeminiEmbeddingProvider;
new GeminiEmbeddingProvider(
key: $_ENV['GEMINI_API_KEY'],
model: 'text-embedding-004'
);
use NeuronAI\RAG\Embeddings\VoyageEmbeddingProvider;
new VoyageEmbeddingProvider(
key: $_ENV['VOYAGE_API_KEY'],
model: 'voyage-3-lite'
);
use NeuronAI\RAG\DocumentLoader\TextLoader;
use NeuronAI\RAG\Chunker\RecursiveCharacterTextSplitter;
$loader = new TextLoader('/path/to/document.txt');
$documents = $loader->load();
// Chunk documents
$chunker = new RecursiveCharacterTextSplitter(
chunkSize: 1000,
chunkOverlap: 200
);
$chunks = $chunker->chunk($documents);
use NeuronAI\RAG\DocumentLoader\PDFLoader;
$loader = new PDFLoader('/path/to/document.pdf');
$documents = $loader->load();
use NeuronAI\RAG\DocumentLoader\HtmlLoader;
$loader = new HtmlLoader('https://example.com/page');
$documents = $loader->load();
use NeuronAI\RAG\DocumentLoader\DirectoryLoader;
$loader = new DirectoryLoader('/path/to/documents');
$documents = $loader->load();
$rag = MyChatBot::make();
// Load and chunk documents
$loader = new DirectoryLoader('./docs');
$documents = $loader->load();
$chunker = new RecursiveCharacterTextSplitter(
chunkSize: 1000,
chunkOverlap: 200
);
$chunks = $chunker->chunk($documents);
// Add to vector store
$rag->vectorStore()->addDocuments($chunks);
use NeuronAI\RAG\Retrieval\SimilaritySearch;
$rag->setRetrieval(new SimilaritySearch(
k: 5 // Return top 5 documents
));
use NeuronAI\RAG\Retrieval\HybridSearch;
$rag->setRetrieval(new HybridSearch(
k: 5,
alpha: 0.5 // Balance between semantic (1.0) and keyword (0.0)
));
use NeuronAI\RAG\Retrieval\MMRSearch;
$rag->setRetrieval(new MMRSearch(
k: 5,
fetchK: 20, // Fetch 20, return diverse 5
lambdaMult: 0.5 // Diversity parameter
));
use NeuronAI\RAG\Processor\QueryExpansionProcessor;
$rag->addPreProcessor(new QueryExpansionProcessor(
numQueries: 3 // Generate 3 query variations
));
use NeuronAI\RAG\Processor\HydeProcessor;
$rag->addPreProcessor(new HydeProcessor(
model: $rag->provider() // Generate hypothetical document
));
use NeuronAI\RAG\Processor\RerankProcessor;
use NeuronAI\RAG\Processor\JinaReranker;
$rag->addPostProcessor(new RerankProcessor(
reranker: new JinaReranker(
apiKey: $_ENV['JINA_API_KEY']
),
topK: 5
));
use NeuronAI\RAG\Processor\CompressorProcessor;
$rag->addPostProcessor(new CompressorProcessor(
maxTokens: 2000
));
$rag = MyChatBot::make();
$response = $rag->chat(
new UserMessage("What are the main features of our product?")
)->getMessage();
echo $response->getContent();
// Response includes retrieved documents as context
use NeuronAI\Chat\Messages\Stream\Chunks\TextChunk;
foreach ($rag->stream(new UserMessage("Explain the architecture"))->events() as $event) {
if ($event instanceof TextChunk) {
echo $event->content;
}
}
$summary = $rag->structured(
new UserMessage("Summarize the pricing information"),
PricingSummary::class
);
vendor/bin/neuron make:rag MyKnowledgeBot
use NeuronAI\RAG\Retrieval\RetrievalInterface;
class CustomRetrieval implements RetrievalInterface
{
public function retrieve(string $query, VectorStoreInterface $vectorStore): array
{
// Custom retrieval logic
return $vectorStore->similaritySearch($query, k: 3);
}
}
$rag->setRetrieval(new CustomRetrieval());
$rag->chat(
new UserMessage("Find documents about pricing")
)->withMetadataFilter([
'category' => 'pricing',
'year' => 2024
]);
class CompanyKnowledgeBot extends RAG
{
protected function embeddings(): EmbeddingsProviderInterface
{
return new OpenAIEmbeddingProvider(
key: $_ENV['OPENAI_API_KEY'],
model: 'text-embedding-3-small'
);
}
protected function vectorStore(): VectorStoreInterface
{
return new PineconeVectorStore(
key: $_ENV['PINECONE_API_KEY'],
indexUrl: $_ENV['PINECONE_INDEX_URL']
);
}
protected function retrieval(): RetrievalInterface
{
return new HybridSearch(k: 5, alpha: 0.7);
}
protected function instructions(): string
{
return (string) new SystemPrompt(
background: [
"You are a helpful assistant that answers questions",
"about our company using the provided context.",
],
constraints: [
"Only use the provided context to answer.",
"If the answer is not in the context, say you don't know.",
]
);
}
}
$rag = MyChatBot::make();
$rag->addPostProcessor(new CohereRerankerPostProcessor(
key: $_ENV['COHERE_API_KEY'],
model: $_ENV['COHERE_MODEL'],
topN: 5
);
$rag->chat(new UserMessage("Your question here"));
use PHPUnit\Framework\TestCase;
class MyChatBotTest extends TestCase
{
public function testRAGRetrieval(): void
{
$rag = MyChatBot::make();
// Add test document
$rag->vectorStore()->addDocument(
new Document('test', 'The product costs $99.')
);
$response = $rag->chat(
new UserMessage("How much does it cost?")
)->getMessage();
$this->assertStringContainsString('99', $response->getContent());
}
}
development
Build custom Neuron AI workflows with nodes, events, middleware, and human-in-the-loop patterns. Use this skill whenever the user mentions workflows, orchestration, event-driven systems, custom agents, complex multi-step processes, human-in-the-loop patterns, or wants to build a custom agentic system from scratch. Also trigger for tasks involving node creation, event routing, workflow middleware, persistence, or interruption patterns.
tools
Create custom tools, toolkits, and MCP integrations for Neuron AI agents. Use this skill when the user mentions creating tools, building toolkits, extending Tool class, defining tool properties, implementing tool execution, MCP server integration, Model Context Protocol, connecting external tools, or tool guidelines. Also trigger for any task involving ToolProperty, ArrayProperty, ObjectProperty, AbstractToolkit, McpConnector, or StdioTransport/SseHttpTransport/StreamableHttpTransport.
tools
Write tests for Neuron AI agents, RAG systems, workflows, and tools using the built-in testing utilities. Use this skill when the user mentions testing agents, writing unit tests, mocking AI providers, testing tool execution, verifying RAG retrieval, testing workflow behavior, or creating test cases for Neuron AI components. Also trigger for any task involving PHPUnit tests, fake providers, test assertions, or quality assurance in Neuron AI projects.
data-ai
Design and implement structured output classes for Neuron AI agents using SchemaProperty attributes and validation rules. Use this skill when the user mentions structured output, JSON schema extraction, data validation, output classes, DTOs for AI responses, extracting structured data from LLM, or configuring property schemas. Also trigger for any task involving SchemaProperty attribute, validation rules like NotBlank/Email/Url, nested objects, arrays of objects, enums, polymorphic types with anyOf, or the Validator class.