View Source AI behaviour (fnord v0.4.1)

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

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_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.