TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/georgeguimaraes/arcana/llms.txt
Use this file to discover all available pages before exploring further.
Arcana module is the primary interface for RAG (Retrieval Augmented Generation) operations in Elixir. It provides document ingestion, vector search, and question answering capabilities that integrate with any Phoenix/Ecto application.
Overview
Arcana provides a complete RAG pipeline:- Ingest documents and files with automatic chunking and embedding
- Search using semantic, fulltext, or hybrid modes
- Ask questions with context-aware LLM responses
- Delete documents and their associated chunks
Core Functions
ingest/2
Ingests text content, creating a document with embedded chunks.The text content to ingest
Options for ingestion:
The Ecto repo to use for database operations
Optional identifier for grouping/filtering documents
Optional metadata to store with the document
Maximum chunk size in characters
Overlap between chunks in characters
Collection name (string) or map with
:name and :description keysEnable GraphRAG entity/relationship extraction (overrides config default)
Returns the created document with fields:
id- UUID of the documentcontent- Original text contentsource_id- Optional source identifiermetadata- Document metadatastatus- Processing status (:completed,:failed, etc.)chunk_count- Number of chunks createdcollection_id- Associated collection UUID
Returns an error tuple if ingestion fails
ingest_file/2
Ingests a file by parsing its content and creating a document with embedded chunks.Path to the file to ingest. Supports plain text, markdown, and PDF formats.
Options (same as
ingest/2):The Ecto repo to use
Optional identifier for grouping/filtering
Optional metadata map
Maximum chunk size in characters
Overlap between chunks
Collection name to organize the document
search/2
Searches for chunks similar to the query using semantic, fulltext, or hybrid search.The search query text
Search options:
The Ecto repo to use (required for pgvector backend)
Maximum number of results to return
Search mode:
:semantic, :fulltext, or :hybridFilter results to a specific source
Minimum similarity score (0.0 to 1.0)
Filter results to a specific collection by name
Filter results to multiple collections
Weight for semantic scores in hybrid mode (0.0 to 1.0)
Weight for fulltext scores in hybrid mode (0.0 to 1.0)
Returns a list of result maps, each containing:
id- Chunk UUIDtext- The chunk text contentdocument_id- Parent document UUIDchunk_index- Position in the documentscore- Similarity/relevance score
rewrite_query/2
Rewrites a query using a provided rewriter function to improve retrieval.- Expanding abbreviations
- Adding synonyms
- Reformulating the query for better matching
- Correcting typos
The original query to rewrite
Rewrite options:
A function that takes a query and returns
{:ok, rewritten} or {:error, reason}.
The function should have the signature: (String.t()) -> {:ok, String.t()} | {:error, term()}For automatic query rewriting in the Agent pipeline, use
Agent.rewrite/2 which provides built-in LLM-based rewriting.ask/2
Ask questions using RAG (Retrieval Augmented Generation) with context from your knowledge base.The question to ask
Ask options:
The Ecto repo to use
LLM implementing the
Arcana.LLM protocol (e.g., "openai:gpt-4o-mini")Maximum number of context chunks to retrieve
Search mode for context retrieval:
:semantic, :fulltext, or :hybridFilter context to a specific source
Minimum similarity score for context chunks
Filter context to a specific collection
Filter context to multiple collections
Custom prompt function:
fn question, context -> system_prompt_string endReturns a tuple with:
answer- The LLM’s response stringcontext- List of context chunks used
delete/2
Deletes a document and all its associated chunks from the knowledge base.UUID of the document to delete
Returns
:ok if the document was successfully deletedReturns an error if the document doesn’t exist
Configuration Functions
config/0
Returns the current Arcana configuration.embedder/0
Returns the configured embedder as a{module, opts} tuple.
chunker/0
Returns the configured chunker as a{module, opts} tuple.
graph_enabled?/1
Checks whether GraphRAG is enabled for the given options.Related Modules
- Arcana.Ingest - Detailed ingestion documentation
- Arcana.Search - Detailed search documentation
- Arcana.Ask - Detailed RAG Q&A documentation