Class: Braintrust::Resources::Functions
- Inherits:
-
Object
- Object
- Braintrust::Resources::Functions
- Defined in:
- lib/braintrust/resources/functions.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Function
Create a new function.
-
#delete(function_id, opts = {}) ⇒ Braintrust::Models::Function
Delete a function object by its id.
-
#initialize(client:) ⇒ Functions
constructor
A new instance of Functions.
-
#invoke(function_id, params = {}, opts = {}) ⇒ Object
Invoke a function.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Function>
List out all functions.
-
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Function
Create or replace function.
-
#retrieve(function_id, opts = {}) ⇒ Braintrust::Models::Function
Get a function object by its id.
-
#update(function_id, params = {}, opts = {}) ⇒ Braintrust::Models::Function
Partially update a function object.
Constructor Details
#initialize(client:) ⇒ Functions
Returns a new instance of Functions.
6 7 8 |
# File 'lib/braintrust/resources/functions.rb', line 6 def initialize(client:) @client = client end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Function
Create a new function. If there is an existing function in the project with the same slug as the one specified in the request, will return the existing function unmodified
29 30 31 32 33 34 35 36 |
# File 'lib/braintrust/resources/functions.rb', line 29 def create(params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/function" req[:body] = params req[:model] = Braintrust::Models::Function @client.request(req, opts) end |
#delete(function_id, opts = {}) ⇒ Braintrust::Models::Function
Delete a function object by its id
123 124 125 126 127 128 129 |
# File 'lib/braintrust/resources/functions.rb', line 123 def delete(function_id, opts = {}) req = {} req[:method] = :delete req[:path] = "/v1/function/#{function_id}" req[:model] = Braintrust::Models::Function @client.request(req, opts) end |
#invoke(function_id, params = {}, opts = {}) ⇒ Object
Invoke a function.
147 148 149 150 151 152 153 154 |
# File 'lib/braintrust/resources/functions.rb', line 147 def invoke(function_id, params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/function/#{function_id}/invoke" req[:body] = params req[:model] = Braintrust::Unknown @client.request(req, opts) end |
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Function>
List out all functions. The functions are sorted by creation date, with the most recently-created functions coming first
107 108 109 110 111 112 113 114 115 |
# File 'lib/braintrust/resources/functions.rb', line 107 def list(params = {}, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/function" req[:query] = params req[:page] = Braintrust::ListObjects req[:model] = Braintrust::Models::Function @client.request(req, opts) end |
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Function
Create or replace function. If there is an existing function in the project with the same slug as the one specified in the request, will replace the existing function with the provided fields
175 176 177 178 179 180 181 182 |
# File 'lib/braintrust/resources/functions.rb', line 175 def replace(params = {}, opts = {}) req = {} req[:method] = :put req[:path] = "/v1/function" req[:body] = params req[:model] = Braintrust::Models::Function @client.request(req, opts) end |
#retrieve(function_id, opts = {}) ⇒ Braintrust::Models::Function
Get a function object by its id
44 45 46 47 48 49 50 |
# File 'lib/braintrust/resources/functions.rb', line 44 def retrieve(function_id, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/function/#{function_id}" req[:model] = Braintrust::Models::Function @client.request(req, opts) end |
#update(function_id, params = {}, opts = {}) ⇒ Braintrust::Models::Function
Partially update a function object. Specify the fields to update in the payload. Any object-type fields will be deep-merged with existing content. Currently we do not support removing fields or setting them to null.
68 69 70 71 72 73 74 75 |
# File 'lib/braintrust/resources/functions.rb', line 68 def update(function_id, params = {}, opts = {}) req = {} req[:method] = :patch req[:path] = "/v1/function/#{function_id}" req[:body] = params req[:model] = Braintrust::Models::Function @client.request(req, opts) end |