ElixirScope.AI.LLM.Provider behaviour (elixir_scope v0.0.1)

Behaviour defining the common interface for all LLM providers in ElixirScope.

This ensures all providers (Gemini, Mock, future providers) implement the same API, allowing for easy switching and fallback between providers.

Summary

Callbacks

Analyzes code using the provider's LLM.

Checks if the provider is properly configured and ready to use.

Explains an error using the provider's LLM.

Returns the provider's name as an atom.

Suggests a fix for a problem using the provider's LLM.

Tests the provider's connectivity and basic functionality.

Callbacks

analyze_code(t, map)

@callback analyze_code(String.t(), map()) :: ElixirScope.AI.LLM.Response.t()

Analyzes code using the provider's LLM.

Parameters

  • code: The Elixir code to analyze
  • context: Additional context for the analysis (metadata, file info, etc.)

Returns

  • Response.t(): Standardized response with analysis results

configured?()

@callback configured?() :: boolean()

Checks if the provider is properly configured and ready to use.

Returns

  • boolean(): true if provider is configured, false otherwise

explain_error(t, map)

@callback explain_error(String.t(), map()) :: ElixirScope.AI.LLM.Response.t()

Explains an error using the provider's LLM.

Parameters

  • error_message: The error message to explain
  • context: Additional context (code, stack trace, etc.)

Returns

  • Response.t(): Standardized response with error explanation

provider_name()

@callback provider_name() :: atom()

Returns the provider's name as an atom.

Returns

  • atom(): Provider identifier (e.g., :gemini, :mock, :anthropic)

suggest_fix(t, map)

@callback suggest_fix(String.t(), map()) :: ElixirScope.AI.LLM.Response.t()

Suggests a fix for a problem using the provider's LLM.

Parameters

  • problem_description: Description of the problem to fix
  • context: Additional context (code, error details, etc.)

Returns

  • Response.t(): Standardized response with fix suggestions

test_connection()

@callback test_connection() :: ElixirScope.AI.LLM.Response.t()

Tests the provider's connectivity and basic functionality.

Returns

  • Response.t(): Response indicating success or failure of connection test