Markov.Prompt (markov v4.1.3)

Thin wrapper around Markov to make the chain respond to prompts assuming it's been trained on the appropriate data

Link to this section Summary

Functions

Generates the text from a prompt

Assuming your application receives a stream of strings, call this function instead of Markov.train/3 with the current and last string

Trains the model on a list of consecutive strings

Link to this section Functions

Link to this function

generate_prompted(model, prompt, query \\ %{})

@spec generate_prompted(
  model :: Markov.model_reference(),
  prompt :: String.t(),
  query :: Markov.tag_query()
) :: {:ok, String.t()} | {:error, term()}

Generates the text from a prompt

Link to this function

train(model, new_text, last_text \\ nil, tags \\ [])

@spec train(
  model :: Markov.model_reference(),
  new_text :: String.t(),
  last_text :: String.t() | nil,
  tags :: [term()]
) :: {:ok, :done | :deferred} | {:error, term()}

Assuming your application receives a stream of strings, call this function instead of Markov.train/3 with the current and last string

Link to this function

train_on_list(model, list)

@spec train_on_list(model :: Markov.model_reference(), list :: [String.t()]) :: :ok

Trains the model on a list of consecutive strings