View Source Lightning.AiAssistant (Lightning v2.10.15)

The AI assistant module.

Summary

Functions

Link to this function

create_session(job, user, content)

View Source
@spec create_session(
  Lightning.Workflows.Job.t(),
  Lightning.Accounts.User.t(),
  String.t()
) ::
  {:ok, Lightning.AiAssistant.ChatSession.t()} | {:error, Ecto.Changeset.t()}
@spec enabled?() :: boolean()

Checks if the AI assistant is enabled.

@spec endpoint_available?() :: boolean()

Checks if the Apollo endpoint is available.

@spec get_session!(Ecto.UUID.t()) :: Lightning.AiAssistant.ChatSession.t()
Link to this function

list_sessions_for_job(job, sort_direction \\ :desc)

View Source
@spec list_sessions_for_job(Lightning.Workflows.Job.t(), :asc | :desc) ::
  [Lightning.AiAssistant.ChatSession.t(), ...] | []
Link to this function

mark_disclaimer_read(user)

View Source
@spec mark_disclaimer_read(Lightning.Accounts.User.t()) ::
  {:ok, Lightning.Accounts.User.t()}
Link to this function

put_expression_and_adaptor(session, expression, adaptor)

View Source
@spec put_expression_and_adaptor(
  Lightning.AiAssistant.ChatSession.t(),
  String.t(),
  String.t()
) ::
  Lightning.AiAssistant.ChatSession.t()
@spec query(Lightning.AiAssistant.ChatSession.t(), String.t()) ::
  {:ok, Lightning.AiAssistant.ChatSession.t()}
  | {:error, String.t() | Ecto.Changeset.t()}

Queries the AI assistant with the given content.

Returns {:ok, session} if the query was successful, otherwise {:error, reason}.

Example

iex> AiAssistant.query(session, "fn()")
{:ok, session}
Link to this function

save_message(session, message, usage \\ %{})

View Source
Link to this function

update_message_status(session, message, status)

View Source
@spec update_message_status(
  Lightning.AiAssistant.ChatSession.t(),
  Lightning.AiAssistant.ChatMessage.t(),
  atom()
) :: {:ok, Lightning.AiAssistant.ChatSession.t()} | {:error, Ecto.Changeset.t()}

Updates the status of a specific message within a chat session.

Returns {:ok, session} if the update is successful, otherwise {:error, changeset}.

Link to this function

user_has_read_disclaimer?(user)

View Source
@spec user_has_read_disclaimer?(Lightning.Accounts.User.t()) :: boolean()