Ragex.Analysis.Suggestions.RAGAdvisor (Ragex v0.3.1)

View Source

RAG-powered advice generation for refactoring suggestions.

Uses the RAG pipeline to generate context-aware, AI-powered advice for each refactoring suggestion, including:

  • Detailed explanations of why the refactoring is beneficial
  • Concrete implementation steps specific to the codebase
  • Code examples from similar patterns in the codebase
  • Potential pitfalls and risks to watch for

Usage

alias Ragex.Analysis.Suggestions.RAGAdvisor

{:ok, advice} = RAGAdvisor.generate_advice(suggestion)
IO.puts(advice)

Summary

Functions

Checks if RAG advice generation is available.

Generates AI-powered advice for a suggestion.

Generates advice for multiple suggestions in batch.

Functions

available?()

Checks if RAG advice generation is available.

Returns true if an AI provider is configured, false otherwise.

generate_advice(suggestion, opts \\ [])

Generates AI-powered advice for a suggestion.

Parameters

  • suggestion - Scored suggestion with pattern, target, and metrics
  • opts - Options:
    • :provider - AI provider to use (default: from config)
    • :temperature - AI temperature (default: 0.7)
    • :max_tokens - Max response tokens (default: 500)

Returns

  • {:ok, advice_text} - Generated advice string
  • {:error, reason} - Error if generation fails

generate_batch_advice(suggestions, opts \\ [])

Generates advice for multiple suggestions in batch.

More efficient than calling generate_advice/2 multiple times.

Parameters

  • suggestions - List of suggestions
  • opts - Options (same as generate_advice/2)

Returns

  • {:ok, suggestions_with_advice} - Suggestions with added :rag_advice field
  • {:error, reason} - Error if batch generation fails