Class: Langsmith::Feedback
- Inherits:
-
Object
- Object
- Langsmith::Feedback
- Defined in:
- lib/langsmith/feedback.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
-
#delete ⇒ Boolean
Delete this feedback.
-
#initialize(client, data) ⇒ Feedback
constructor
Initialize a new Feedback instance.
-
#update(score: nil, comment: nil) ⇒ Langsmith::Feedback
Update this feedback.
Constructor Details
#initialize(client, data) ⇒ Feedback
Initialize a new Feedback instance
11 12 13 14 15 16 17 18 19 |
# File 'lib/langsmith/feedback.rb', line 11 def initialize(client, data) @client = client @id = data["id"] @run_id = data["run_id"] @key = data["key"] @score = data["score"] @comment = data["comment"] @created_at = data["created_at"] ? Time.parse(data["created_at"]) : nil end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def comment @comment end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def id @id end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def key @key end |
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def run_id @run_id end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/langsmith/feedback.rb', line 5 def score @score end |
Instance Method Details
#delete ⇒ Boolean
Delete this feedback
38 39 40 41 |
# File 'lib/langsmith/feedback.rb', line 38 def delete response = @client.delete("/feedback/#{@id}") response["success"] == true end |
#update(score: nil, comment: nil) ⇒ Langsmith::Feedback
Update this feedback
26 27 28 29 30 31 32 33 |
# File 'lib/langsmith/feedback.rb', line 26 def update(score: nil, comment: nil) data = {} data[:score] = score if score data[:comment] = comment if comment response = @client.patch("/feedback/#{@id}", data) Langsmith::Feedback.new(@client, response) end |