Class: Braintrust::Resources::ProjectScores

Inherits:
Object
  • Object
show all
Defined in:
lib/braintrust/resources/project_scores.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ProjectScores

Returns a new instance of ProjectScores.



6
7
8
# File 'lib/braintrust/resources/project_scores.rb', line 6

def initialize(client:)
  @client = client
end

Instance Method Details

#create(params = {}, opts = {}) ⇒ Braintrust::Models::ProjectScore

Create a new project_score. If there is an existing project_score in the project with the same name as the one specified in the request, will return the existing project_score unmodified

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    Name of the project score

  • :project_id (String)

    Unique identifier for the project that the project score belongs under

  • :score_type (Symbol)

    The type of the configured score

  • :categories (Array<Braintrust::Models::ProjectScoreCategory>|Array<String>|Categories::UnnamedTypeWithunionParent18|Hash)

    For categorical-type project scores, the list of all categories

  • :config (Braintrust::Models::ProjectScoreConfig)
  • :description (String)

    Textual description of the project score

Returns:



25
26
27
28
29
30
31
32
# File 'lib/braintrust/resources/project_scores.rb', line 25

def create(params = {}, opts = {})
  req = {}
  req[:method] = :post
  req[:path] = "/v1/project_score"
  req[:body] = params
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end

#delete(project_score_id, opts = {}) ⇒ Braintrust::Models::ProjectScore

Delete a project_score object by its id

Parameters:

  • project_score_id (String)

    ProjectScore id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



115
116
117
118
119
120
121
# File 'lib/braintrust/resources/project_scores.rb', line 115

def delete(project_score_id, opts = {})
  req = {}
  req[:method] = :delete
  req[:path] = "/v1/project_score/#{project_score_id}"
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end

#list(params = {}, opts = {}) ⇒ Braintrust::ListObjects<Braintrust::Models::ProjectScore>

List out all project_scores. The project_scores are sorted by creation date, with the most recently-created project_scores coming first

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :ending_before (String)

    Pagination cursor id.

    For example, if the initial item in the last page you fetched had an id of foo, pass ending_before=foo to fetch the previous page. Note: you may only pass one of starting_after and ending_before

  • :ids (Array<String>|String)

    Filter search results to a particular set of object IDs. To specify a list of IDs, include the query param multiple times

  • :limit (Integer)

    Limit the number of objects to return

  • :org_name (String)

    Filter search results to within a particular organization

  • :project_id (String)

    Project id

  • :project_name (String)

    Name of the project to search for

  • :project_score_name (String)

    Name of the project_score to search for

  • :score_type (Array<Symbol>|Symbol)

    The type of the configured score

  • :starting_after (String)

    Pagination cursor id.

    For example, if the final item in the last page you fetched had an id of foo, pass starting_after=foo to fetch the next page. Note: you may only pass one of starting_after and ending_before

Returns:



99
100
101
102
103
104
105
106
107
# File 'lib/braintrust/resources/project_scores.rb', line 99

def list(params = {}, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/project_score"
  req[:query] = params
  req[:page] = Braintrust::ListObjects
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end

#replace(params = {}, opts = {}) ⇒ Braintrust::Models::ProjectScore

Create or replace project_score. If there is an existing project_score in the project with the same name as the one specified in the request, will replace the existing project_score with the provided fields

Parameters:

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :name (String)

    Name of the project score

  • :project_id (String)

    Unique identifier for the project that the project score belongs under

  • :score_type (Symbol)

    The type of the configured score

  • :categories (Array<Braintrust::Models::ProjectScoreCategory>|Array<String>|Categories::UnnamedTypeWithunionParent20|Hash)

    For categorical-type project scores, the list of all categories

  • :config (Braintrust::Models::ProjectScoreConfig)
  • :description (String)

    Textual description of the project score

Returns:



138
139
140
141
142
143
144
145
# File 'lib/braintrust/resources/project_scores.rb', line 138

def replace(params = {}, opts = {})
  req = {}
  req[:method] = :put
  req[:path] = "/v1/project_score"
  req[:body] = params
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end

#retrieve(project_score_id, opts = {}) ⇒ Braintrust::Models::ProjectScore

Get a project_score object by its id

Parameters:

  • project_score_id (String)

    ProjectScore id

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Returns:



40
41
42
43
44
45
46
# File 'lib/braintrust/resources/project_scores.rb', line 40

def retrieve(project_score_id, opts = {})
  req = {}
  req[:method] = :get
  req[:path] = "/v1/project_score/#{project_score_id}"
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end

#update(project_score_id, params = {}, opts = {}) ⇒ Braintrust::Models::ProjectScore

Partially update a project_score 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.

Parameters:

  • project_score_id (String)

    ProjectScore id

  • params (Hash) (defaults to: {})

    Attributes to send in this request.

  • opts (Hash|RequestOptions) (defaults to: {})

    Options to specify HTTP behaviour for this request.

Options Hash (params):

  • :categories (Array<Braintrust::Models::ProjectScoreCategory>|Array<String>|Categories::UnnamedTypeWithunionParent19|Hash)

    For categorical-type project scores, the list of all categories

  • :config (Braintrust::Models::ProjectScoreConfig)
  • :description (String)

    Textual description of the project score

  • :name (String)

    Name of the project score

  • :score_type (Symbol)

    The type of the configured score

Returns:



64
65
66
67
68
69
70
71
# File 'lib/braintrust/resources/project_scores.rb', line 64

def update(project_score_id, params = {}, opts = {})
  req = {}
  req[:method] = :patch
  req[:path] = "/v1/project_score/#{project_score_id}"
  req[:body] = params
  req[:model] = Braintrust::Models::ProjectScore
  @client.request(req, opts)
end