Class: Braintrust::Resources::Prompts
- Inherits:
-
Object
- Object
- Braintrust::Resources::Prompts
- Defined in:
- lib/braintrust/resources/prompts.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.
-
#initialize(client:) ⇒ Prompts
constructor
A new instance of Prompts.
-
#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::Prompt>
List out all prompts.
-
#replace(params = {}, opts = {}) ⇒ Braintrust::Models::Prompt
Create or replace prompt.
-
#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:) ⇒ Prompts
Returns a new instance of Prompts.
6 7 8 |
# File 'lib/braintrust/resources/prompts.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
26 27 28 29 30 31 32 33 |
# File 'lib/braintrust/resources/prompts.rb', line 26 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
120 121 122 123 124 125 126 |
# File 'lib/braintrust/resources/prompts.rb', line 120 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 |
#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
104 105 106 107 108 109 110 111 112 |
# File 'lib/braintrust/resources/prompts.rb', line 104 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
Create or replace prompt. If there is an existing prompt in the project with the same slug as the one specified in the request, will replace the existing prompt with the provided fields
144 145 146 147 148 149 150 151 |
# File 'lib/braintrust/resources/prompts.rb', line 144 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
41 42 43 44 45 46 47 |
# File 'lib/braintrust/resources/prompts.rb', line 41 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.
65 66 67 68 69 70 71 72 |
# File 'lib/braintrust/resources/prompts.rb', line 65 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 |