View Source AI (fnord v0.4.30)

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.

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

Types

@type t() :: %AI{
  api_key: term(),
  client: %OpenaiEx{
    _ep_path_mapping: term(),
    _http_headers: term(),
    base_url: term(),
    beta: term(),
    finch_name: term(),
    organization: term(),
    receive_timeout: term(),
    stream_timeout: term(),
    token: term()
  }
}

Functions

Link to this function

get_completion(ai, options \\ [])

View Source
Link to this function

get_embeddings(ai, text, options \\ [])

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.

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