Retriever nativo per query engine LlamaIndex con streaming e ricerca ibrida.
SeiznRetriever implementa l'interfaccia BaseRetriever di LlamaIndex, rendendolo compatibile con tutti i query engine e le pipeline LlamaIndex.
Installa l'SDK Seizn insieme a LlamaIndex.
# TypeScript / JavaScript
npm install seizn llamaindex
# Python
pip install seizn llama-indexCostruisci un query engine con SeiznRetriever per la tua applicazione RAG.
import { SeiznRetriever } from 'seizn/llamaindex';
import { OpenAI } from 'llamaindex';
import { VectorStoreIndex, RetrieverQueryEngine } from 'llamaindex';
// Initialize the Seizn retriever
const retriever = new SeiznRetriever({
apiKey: process.env.SEIZN_API_KEY,
dataset: 'my-docs',
topK: 5,
threshold: 0.7,
});
// Create a query engine with the retriever
const llm = new OpenAI({ model: 'gpt-4' });
const queryEngine = new RetrieverQueryEngine(retriever, llm);
// Query your documents
const response = await queryEngine.query(
'How do I configure rate limiting?'
);
console.log(response.response);
// Access the trace for debugging
console.log('Trace:', response.metadata?.seiznTrace);import os
from seizn.llamaindex import SeiznRetriever
from llama_index.llms.openai import OpenAI
from llama_index.core.query_engine import RetrieverQueryEngine
# Initialize the Seizn retriever
retriever = SeiznRetriever(
api_key=os.environ["SEIZN_API_KEY"],
dataset="my-docs",
top_k=5,
threshold=0.7,
)
# Create a query engine with the retriever
llm = OpenAI(model="gpt-4")
query_engine = RetrieverQueryEngine.from_args(
retriever=retriever,
llm=llm,
)
# Query your documents
response = query_engine.query(
"How do I configure rate limiting?"
)
print(response.response)
# Access the trace for debugging
print("Trace:", response.metadata.get("seizn_trace"))Abilita lo streaming per una migliore esperienza utente con risposte lunghe.
const queryEngine = new RetrieverQueryEngine(retriever, llm);
// Enable streaming response
const stream = await queryEngine.query(
'Explain the authentication flow',
{ streaming: true }
);
for await (const chunk of stream) {
process.stdout.write(chunk.response);
}Combina ricerca vettoriale e per parole chiave per un migliore recall.
const retriever = new SeiznRetriever({
apiKey: process.env.SEIZN_API_KEY,
dataset: 'my-docs',
searchMode: 'hybrid', // vector + keyword
hybridAlpha: 0.7, // 70% vector, 30% keyword
});Concatena i postprocessor per filtraggio e reranking avanzati.
import { SimilarityPostprocessor, KeywordNodePostprocessor } from 'llamaindex';
const queryEngine = new RetrieverQueryEngine(retriever, llm, {
nodePostprocessors: [
new SimilarityPostprocessor({ similarityCutoff: 0.7 }),
new KeywordNodePostprocessor({
requiredKeywords: ['authentication'],
excludeKeywords: ['deprecated'],
}),
],
});| Errore | Causa | Soluzione |
|---|---|---|
SEIZN_AUTH_ERROR | Chiave API non valida o mancante | Verifica la variabile d'ambiente SEIZN_API_KEY |
SEIZN_DATASET_NOT_FOUND | Nome dataset non trovato | Verifica che il dataset esista nel pannello |
Low relevance scores | Discrepanza query-documento | Prova la ricerca ibrida o regola la soglia |