View Source AI behaviour (fnord v0.4.8)

AI is a behavior module that defines the interface for interacting with OpenAI's API. It provides a common interface for the various OpenAI-powered operations used by the application.

Summary

Functions

Get embeddings for the given text. The text is split into chunks of 8192 tokens to avoid exceeding the model's input limit. Returns a list of embeddings for each chunk.

Get a summary of the given text. The text is truncated to 128k tokens to avoid exceeding the model's input limit. Returns a summary of the text.

Create a new AI instance. Instances share the same client connection.

Callbacks

Link to this callback

get_embeddings(struct, t)

View Source
@callback get_embeddings(
  struct(),
  String.t()
) :: {:ok, [String.t()]} | {:error, term()}
Link to this callback

get_summary(struct, t, t)

View Source
@callback get_summary(struct(), String.t(), String.t()) ::
  {:ok, String.t()} | {:error, term()}
@callback new() :: struct()

Functions

Link to this function

add_user_message(ai, thread_id, message)

View Source
Link to this function

create_assistant(ai, request)

View Source
Link to this function

get_assistant(ai, assistant_id)

View Source
Link to this function

get_embeddings(ai, text)

View Source

Get embeddings for the given text. The text is split into chunks of 8192 tokens to avoid exceeding the model's input limit. Returns a list of embeddings for each chunk.

Link to this function

get_messages(ai, thread_id)

View Source
Link to this function

get_run_status(ai, thread_id, run_id)

View Source
Link to this function

get_summary(ai, file, text)

View Source

Get a summary of the given text. The text is truncated to 128k tokens to avoid exceeding the model's input limit. Returns a summary of the text.

Create a new AI instance. Instances share the same client connection.

Link to this function

run_thread(ai, assistant_id, thread_id)

View Source
Link to this function

split_text(input, max_tokens)

View Source
Link to this function

submit_tool_outputs(ai, thread_id, run_id, outputs)

View Source
Link to this function

update_assistant(ai, assistant_id, request)

View Source