View Source Anthropic.Config (anthropic_community v0.4.0)

Module is responsible for holding default configuration on runtime.

Configuration

The following configuration options are available:

  • :api_key - The API key for authenticating requests to the Anthropic API (required).
  • :model - The name of the model to use for generating responses (default: "claude-3-opus-20240229").
  • :max_tokens - The maximum number of tokens allowed in the generated response (default: 1000).
  • :temperature - The sampling temperature for controlling response randomness (default: 1.0).
  • :top_p - The cumulative probability threshold for nucleus sampling (default: 1.0).
  • :top_k - The number of top tokens to consider for sampling (default: 1).
  • :anthropic_version - The version of the Anthropic API to use (default: "2023-06-01").
  • :api_url - The URL of the Anthropic API (default: "https://api.anthropic.com/v1").

These options can be set in your application's configuration file:

config :anthropic,
  api_key: "your_api_key",
  model: "claude-v1",
  max_tokens: 500,
  temperature: 0.7,
  top_p: 0.9,
  top_k: 5

Alternatively, you can update the configuration at runtime using Anthropic.Config.reset/1:

Anthropic.Config.reset(max_tokens: 750, temperature: 0.5)

Summary

Functions

Returns a specification to start this module under a supervisor.

Retrieves the current configuration options.

Resets specific configuration options.

Types

@type config_option() ::
  {:model, String.t()}
  | {:anthropic_version, String.t()}
  | {:api_url, String.t()}
  | {:max_tokens, non_neg_integer()}
  | {:temperature, float()}
  | {:top_p, float()}
  | {:top_k, non_neg_integer()}
  | {:api_key, String.t()}
@type config_options() :: [config_option()]
@type t() :: %Anthropic.Config{
  anthropic_version: String.t() | nil,
  api_key: String.t() | nil,
  api_url: String.t() | nil,
  max_tokens: non_neg_integer() | nil,
  model: String.t() | nil,
  temperature: float() | nil,
  top_k: non_neg_integer() | nil,
  top_p: float() | nil
}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Retrieves the current configuration options.

This function queries the GenServer to return the current state, which represents the active configuration.

Returns

Resets specific configuration options.

Allows dynamically updating the configuration by merging provided options with the current state. The updated configuration is then validated.

Parameters

  • keyword_list: A keyword list of configuration options to update.

Returns