Class: Braintrust::Resources::Prompt
- Inherits:
-
Object
- Object
- Braintrust::Resources::Prompt
- Defined in:
- lib/braintrust/resources/prompt.rb
Instance Method Summary collapse
-
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
Create a new prompt.
-
#delete(prompt_id, opts = {}) ⇒ Braintrust::Models::Prompt
Delete a prompt object by its id.
-
#feedback(prompt_id, params = {}, opts = {}) ⇒ nil
Log feedback for a set of prompt events.
-
#initialize(client:) ⇒ Prompt
constructor
A new instance of Prompt.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Prompt>
List out all prompts.
-
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
NOTE: This operation is deprecated and will be removed in a future revision of the API.
-
#retrieve(prompt_id, opts = {}) ⇒ Braintrust::Models::Prompt
Get a prompt object by its id.
-
#update(prompt_id, params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
Partially update a prompt object.
Constructor Details
#initialize(client:) ⇒ Prompt
Returns a new instance of Prompt.
6 7 8 |
# File 'lib/braintrust/resources/prompt.rb', line 6 def initialize(client:) @client = client end |
Instance Method Details
#create(params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
Create a new prompt. If there is an existing prompt in the project with the same slug as the one specified in the request, will return the existing prompt unmodified
25 26 27 28 29 30 31 32 |
# File 'lib/braintrust/resources/prompt.rb', line 25 def create(params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/prompt" req[:body] = params req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |
#delete(prompt_id, opts = {}) ⇒ Braintrust::Models::Prompt
Delete a prompt object by its id
118 119 120 121 122 123 124 |
# File 'lib/braintrust/resources/prompt.rb', line 118 def delete(prompt_id, opts = {}) req = {} req[:method] = :delete req[:path] = "/v1/prompt/#{prompt_id}" req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |
#feedback(prompt_id, params = {}, opts = {}) ⇒ nil
Log feedback for a set of prompt events
136 137 138 139 140 141 142 143 |
# File 'lib/braintrust/resources/prompt.rb', line 136 def feedback(prompt_id, params = {}, opts = {}) req = {} req[:method] = :post req[:path] = "/v1/prompt/#{prompt_id}/feedback" req[:body] = params req[:model] = NilClass @client.request(req, opts) end |
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Prompt>
List out all prompts. The prompts are sorted by creation date, with the most recently-created prompts coming first
102 103 104 105 106 107 108 109 110 |
# File 'lib/braintrust/resources/prompt.rb', line 102 def list(params = {}, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/prompt" req[:query] = params req[:page] = Braintrust::ListObjects req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
NOTE: This operation is deprecated and will be removed in a future revision of the API. Create or replace a new prompt. If there is an existing prompt in the project with the same slug as the one specified in the request, will return the existing prompt unmodified, will replace the existing prompt with the provided fields
162 163 164 165 166 167 168 169 |
# File 'lib/braintrust/resources/prompt.rb', line 162 def replace(params = {}, opts = {}) req = {} req[:method] = :put req[:path] = "/v1/prompt" req[:body] = params req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |
#retrieve(prompt_id, opts = {}) ⇒ Braintrust::Models::Prompt
Get a prompt object by its id
40 41 42 43 44 45 46 |
# File 'lib/braintrust/resources/prompt.rb', line 40 def retrieve(prompt_id, opts = {}) req = {} req[:method] = :get req[:path] = "/v1/prompt/#{prompt_id}" req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |
#update(prompt_id, params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
Partially update a prompt 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.
63 64 65 66 67 68 69 70 |
# File 'lib/braintrust/resources/prompt.rb', line 63 def update(prompt_id, params = {}, opts = {}) req = {} req[:method] = :patch req[:path] = "/v1/prompt/#{prompt_id}" req[:body] = params req[:model] = Braintrust::Models::Prompt @client.request(req, opts) end |