Search documentation of Ragex

# Ragex.RAG.Pipeline (Ragex v0.4.0)

View Source

Orchestrates the RAG pipeline: Retrieval → Augmentation → Generation.

## Pipeline Steps

1. Retrieval: Query knowledge graph and vector store (hybrid search)
2. Context Building: Format retrieved code for AI consumption
3. Prompt Engineering: Apply templates and inject context
4. Generation: Call AI provider with augmented prompt
5. Post-processing: Parse response, add sources, format output

## Summary

### Functions

explain(target, aspect, opts \\ [])

Explain code using RAG.

query(user_query, opts \\ [])

Execute RAG query pipeline.

stream_explain(target, aspect, opts \\ [])

Explain code using RAG with streaming response.

stream_query(user_query, opts \\ [])

Execute RAG query pipeline with streaming response.

stream_suggest(target, focus, opts \\ [])

Suggest improvements using RAG with streaming response.

suggest(target, focus, opts \\ [])

Suggest improvements using RAG.

## Functions

# explain(target, aspect, opts \\ [])

Explain code using RAG.

# query(user_query, opts \\ [])

Execute RAG query pipeline.

## Options

- `:limit` - Max retrieval results (default: 10)
- `:threshold` - Similarity threshold (default: 0.7)
- `:strategy` - Retrieval strategy: :fusion, :semantic_first, :graph_first
- `:include_code` - Include full code snippets (default: true)
- `:provider` - Override AI provider
- `:system_prompt` - Custom system prompt
- `:temperature` - AI temperature (default: 0.7)

# stream_explain(target, aspect, opts \\ [])

Explain code using RAG with streaming response.

# stream_query(user_query, opts \\ [])

Execute RAG query pipeline with streaming response.

Returns `{:ok, stream}` where stream emits chunks as they arrive from the AI provider. The final chunk will include usage statistics and sources.

## Options

Same as `query/2` plus:

- `:stream_metadata` - Include sources in every chunk (default: false)

# stream_suggest(target, focus, opts \\ [])

Suggest improvements using RAG with streaming response.

# suggest(target, focus, opts \\ [])

Suggest improvements using RAG.