View Source Lightning.AiAssistant (Lightning v2.10.4)

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)

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

project_has_any_session?(project_id)

View Source
@spec project_has_any_session?(Ecto.UUID.t()) :: boolean()
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, Ecto.Changeset.t() | :apollo_unavailable}

Queries the AI assistant with the given content.

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

Example

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

save_message(session, message)

View Source
@spec save_message(Lightning.AiAssistant.ChatSession.t(), %{required(any()) => any()}) ::
  {:ok, Lightning.AiAssistant.ChatSession.t()} | {:error, Ecto.Changeset.t()}