Class: Braintrust::API
- Inherits:
-
Object
- Object
- Braintrust::API
- Defined in:
- lib/braintrust/api.rb,
lib/braintrust/api/datasets.rb,
lib/braintrust/api/functions.rb,
lib/braintrust/api/internal/auth.rb,
lib/braintrust/api/internal/btql.rb,
lib/braintrust/api/internal/projects.rb,
lib/braintrust/api/internal/experiments.rb
Overview
API client for Braintrust REST API Provides namespaced access to different API resources
Defined Under Namespace
Modules: Internal Classes: Datasets, Functions
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#datasets ⇒ API::Datasets
Access to datasets API.
-
#functions ⇒ API::Functions
Access to functions API.
-
#initialize(state: nil) ⇒ API
constructor
A new instance of API.
-
#login ⇒ self
Login to Braintrust API (idempotent).
-
#object_permalink(object_type:, object_id:) ⇒ String
Generate a permalink URL to view an object in the Braintrust UI This is for the /object endpoint (experiments, datasets, etc.) For trace span permalinks, use Trace.permalink instead.
Constructor Details
#initialize(state: nil) ⇒ API
Returns a new instance of API.
12 13 14 15 |
# File 'lib/braintrust/api.rb', line 12 def initialize(state: nil) @state = state || Braintrust.current_state raise Error, "No state available" unless @state end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
10 11 12 |
# File 'lib/braintrust/api.rb', line 10 def state @state end |
Instance Method Details
#datasets ⇒ API::Datasets
Access to datasets API
19 20 21 |
# File 'lib/braintrust/api.rb', line 19 def datasets @datasets ||= API::Datasets.new(self) end |
#functions ⇒ API::Functions
Access to functions API
25 26 27 |
# File 'lib/braintrust/api.rb', line 25 def functions @functions ||= API::Functions.new(self) end |
#login ⇒ self
Login to Braintrust API (idempotent)
31 32 33 34 |
# File 'lib/braintrust/api.rb', line 31 def login @state.login self end |
#object_permalink(object_type:, object_id:) ⇒ String
Generate a permalink URL to view an object in the Braintrust UI This is for the /object endpoint (experiments, datasets, etc.) For trace span permalinks, use Trace.permalink instead.
42 43 44 |
# File 'lib/braintrust/api.rb', line 42 def object_permalink(object_type:, object_id:) @state.object_permalink(object_type: object_type, object_id: object_id) end |