Raxol.AI.ContentGeneration (Raxol v0.4.0)

View Source

Content generation capabilities for Raxol applications.

This module provides AI-powered content generation for various aspects of terminal UIs, including:

  • Text suggestions
  • Command completions
  • Help content generation
  • Documentation generation
  • Interactive tutorials
  • Contextual hints

The generation is configurable and can be adapted to different contexts within the application.

Summary

Functions

Generates content based on the specified type and prompt.

Generates a contextual help document based on application state.

Generates an interactive tutorial for a specific feature.

Generates text suggestions based on current input context.

Types

generation_options()

@type generation_options() :: %{
  max_length: integer(),
  style: atom(),
  tone: atom(),
  context: map(),
  model: atom()
}

generation_type()

@type generation_type() :: :text | :command | :help | :docs | :tutorial | :hint

Functions

generate(type, prompt, opts \\ [])

@spec generate(generation_type(), String.t(), keyword()) ::
  {:ok, String.t()} | {:error, String.t()}

Generates content based on the specified type and prompt.

Options

  • :max_length - Maximum length of the generated content (default: 100)
  • :style - Style of the generated content (default: :neutral)
  • :tone - Tone of the generated content (default: :neutral)
  • :context - Additional context for generation (default: %{})
  • :model - AI model to use for generation (default: :default)

Examples

iex> generate(:text, "Create a welcome message", max_length: 50)
{:ok, "Welcome to the terminal! How can I assist you today?"}

generate_help(context, opts \\ [])

@spec generate_help(
  map(),
  keyword()
) :: {:ok, map()} | {:error, String.t()}

Generates a contextual help document based on application state.

Examples

iex> generate_help(%{current_view: :editor, command_mode: true})
{:ok, %{title: "Editor Mode Commands", content: "..."}}

generate_tutorial(feature, opts \\ [])

@spec generate_tutorial(
  atom(),
  keyword()
) :: {:ok, map()} | {:error, String.t()}

Generates an interactive tutorial for a specific feature.

Examples

iex> generate_tutorial(:keyboard_shortcuts)
{:ok, %{steps: [...], interactive: true}}

suggest_text(input, opts \\ [])

@spec suggest_text(
  String.t(),
  keyword()
) :: {:ok, [String.t()]} | {:error, String.t()}

Generates text suggestions based on current input context.

Examples

iex> suggest_text("print(", context: %{language: :python})
{:ok, ["print("Hello, World!")", "print(value)", "print(f"Value: {value}")"]}