AI Platform

RAG Pipeline

Retrieval-Augmented Generation.

1 min readDocumentationEdit this page

Setup#

typescript
import { RAGPipeline, VectorStore, loadFromText } from '@AxilJS/ai'
 
const rag = new RAGPipeline({ provider: ai, vectorStore: new VectorStore() })

Index#

typescript
await rag.index(loadFromText(['AxilJS supports PostgreSQL...']))

Query#

typescript
const result = await rag.query('What databases are supported?')
result.response  // generated answer
result.sources   // documents used

Stream#

typescript
for await (const event of rag.queryStream('Tell me about auth')) {
  if (event.type === 'sources') console.log(event.data)
  if (event.type === 'delta') process.stdout.write(event.data)
}

Help improve the documentation

AxilJS is open source and documentation improvements are welcome.

AxilJS DocumentationMIT License · Built by SyntaxilitY