Class: Braintrust::Client

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/braintrust/client.rb

Constant Summary collapse

DEFAULT_MAX_RETRIES =

Default max number of retries to attempt after a failed retryable request.

2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url: nil, api_key: nil, max_retries: nil) ⇒ Client

Creates and returns a new client for interacting with the API.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/braintrust/client.rb', line 71

def initialize(base_url: nil, api_key: nil, max_retries: nil)
  base_url ||= "https://api.braintrust.dev"

  max_retries ||= DEFAULT_MAX_RETRIES

  @api_key = [api_key, ENV["BRAINTRUST_API_KEY"]].find { |v| !v.nil? }

  super(base_url: base_url, max_retries: max_retries)

  @top_level = Braintrust::Resources::TopLevel.new(client: self)
  @projects = Braintrust::Resources::Projects.new(client: self)
  @experiments = Braintrust::Resources::Experiments.new(client: self)
  @datasets = Braintrust::Resources::Datasets.new(client: self)
  @prompts = Braintrust::Resources::Prompts.new(client: self)
  @roles = Braintrust::Resources::Roles.new(client: self)
  @groups = Braintrust::Resources::Groups.new(client: self)
  @acls = Braintrust::Resources::ACLs.new(client: self)
  @users = Braintrust::Resources::Users.new(client: self)
  @project_scores = Braintrust::Resources::ProjectScores.new(client: self)
  @project_tags = Braintrust::Resources::ProjectTags.new(client: self)
  @functions = Braintrust::Resources::Functions.new(client: self)
  @views = Braintrust::Resources::Views.new(client: self)
  @organizations = Braintrust::Resources::Organizations.new(client: self)
  @api_keys = Braintrust::Resources::APIKeys.new(client: self)
  @ai_secrets = Braintrust::Resources::AISecrets.new(client: self)
  @env_vars = Braintrust::Resources::EnvVars.new(client: self)
  @evals = Braintrust::Resources::Evals.new(client: self)
end

Instance Attribute Details

#aclsBraintrust::Resources::ACLs (readonly)



33
34
35
# File 'lib/braintrust/client.rb', line 33

def acls
  @acls
end

#ai_secretsBraintrust::Resources::AISecrets (readonly)



57
58
59
# File 'lib/braintrust/client.rb', line 57

def ai_secrets
  @ai_secrets
end

#api_keyObject (readonly)

Client options.



9
10
11
# File 'lib/braintrust/client.rb', line 9

def api_key
  @api_key
end

#api_keysBraintrust::Resources::APIKeys (readonly)



54
55
56
# File 'lib/braintrust/client.rb', line 54

def api_keys
  @api_keys
end

#datasetsBraintrust::Resources::Datasets (readonly)



21
22
23
# File 'lib/braintrust/client.rb', line 21

def datasets
  @datasets
end

#env_varsBraintrust::Resources::EnvVars (readonly)



60
61
62
# File 'lib/braintrust/client.rb', line 60

def env_vars
  @env_vars
end

#evalsBraintrust::Resources::Evals (readonly)



63
64
65
# File 'lib/braintrust/client.rb', line 63

def evals
  @evals
end

#experimentsBraintrust::Resources::Experiments (readonly)



18
19
20
# File 'lib/braintrust/client.rb', line 18

def experiments
  @experiments
end

#functionsBraintrust::Resources::Functions (readonly)



45
46
47
# File 'lib/braintrust/client.rb', line 45

def functions
  @functions
end

#groupsBraintrust::Resources::Groups (readonly)



30
31
32
# File 'lib/braintrust/client.rb', line 30

def groups
  @groups
end

#organizationsBraintrust::Resources::Organizations (readonly)



51
52
53
# File 'lib/braintrust/client.rb', line 51

def organizations
  @organizations
end

#project_scoresBraintrust::Resources::ProjectScores (readonly)



39
40
41
# File 'lib/braintrust/client.rb', line 39

def project_scores
  @project_scores
end

#project_tagsBraintrust::Resources::ProjectTags (readonly)



42
43
44
# File 'lib/braintrust/client.rb', line 42

def project_tags
  @project_tags
end

#projectsBraintrust::Resources::Projects (readonly)



15
16
17
# File 'lib/braintrust/client.rb', line 15

def projects
  @projects
end

#promptsBraintrust::Resources::Prompts (readonly)



24
25
26
# File 'lib/braintrust/client.rb', line 24

def prompts
  @prompts
end

#rolesBraintrust::Resources::Roles (readonly)



27
28
29
# File 'lib/braintrust/client.rb', line 27

def roles
  @roles
end

#top_levelBraintrust::Resources::TopLevel (readonly)



12
13
14
# File 'lib/braintrust/client.rb', line 12

def top_level
  @top_level
end

#usersBraintrust::Resources::Users (readonly)



36
37
38
# File 'lib/braintrust/client.rb', line 36

def users
  @users
end

#viewsBraintrust::Resources::Views (readonly)



48
49
50
# File 'lib/braintrust/client.rb', line 48

def views
  @views
end