-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fe8a0c
commit dfd9c3c
Showing
8 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
require_relative 'llm_event/chat_completion' | ||
|
||
module NewRelic | ||
module Agent | ||
class LlmEvent | ||
|
||
# response_model looks like repsonse.model | ||
attr_accessor :id, :app_name, :request_id, :span_id, :transaction_id, :trace_id, :response_model, :vendor | ||
INGEST_SOURCE = 'Ruby' | ||
|
||
def initialize(id:, app_name:, request_id:, span_id:, transaction_id:, trace_id:, response_model:, vendor:, **args) | ||
@id = id | ||
@app_name = app_name | ||
@request_id = request_id | ||
@span_id = span_id | ||
@transaction_id = transaction_id | ||
@trace_id = trace_id | ||
@response_model = response_model | ||
@vendor = vendor | ||
end | ||
|
||
# Method for subclasses to override | ||
def record; end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
|
||
module NewRelic | ||
module Agent | ||
class LlmEvent | ||
class ChatCompletion < NewRelic::Agent::LlmEvent | ||
|
||
# Real metrics are written: request.max_tokens, response.number_of_messages | ||
attr_accessor :api_key_last_four_digits, :conversation_id, :request_max_tokens, :response_number_of_messages | ||
|
||
def initialize(api_key_last_four_digits:, conversation_id:, request_max_tokens:, response_number_of_messages:) | ||
@api_key_last_four_digits = api_key_last_four_digits | ||
@conversation_id = conversation_id | ||
@request_max_tokens = request_max_tokens | ||
@response_number_of_messages = response_number_of_messages | ||
super | ||
end | ||
|
||
# Method for subclasses to override | ||
def record; end | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
class NewRelic | ||
class Agent | ||
class LlmEvent | ||
class ChatCompletion | ||
class Message < NewRelic::Agent::LlmEvent::ChatCompletion | ||
|
||
attr_accessor :content, :role, :sequence, :completion_id, :is_response | ||
|
||
def initialize | ||
|
||
end | ||
|
||
def record | ||
|
||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
class NewRelic | ||
class Agent | ||
class LlmEvent | ||
class ChatCompletion | ||
|
||
attr_accessor | ||
:'request.model', | ||
:'response.organization', | ||
:'response.usage.total_tokens', | ||
:'response.usage.prompt_tokens', | ||
:'response.usage.completion_tokens', | ||
:'response.choices.finish_reason', | ||
:'response.headers.llmVersion', | ||
:'response.headers.ratelimitLimitRequests', | ||
:'response.headers.ratelimitLimitTokens', | ||
:'response.headers.ratelimitResetTokens', | ||
:'response.headers.ratelimitResetRequests', | ||
:'response.headers.ratelimitRemainingTokens', | ||
:'response.headers.ratelimitRemainingRequests', | ||
:duration, | ||
:'request.temperature', | ||
:error | ||
|
||
|
||
|
||
class Summary < NewRelic::Agent::LlmEvent::ChatCompletion | ||
|
||
def initialize | ||
|
||
end | ||
|
||
def record | ||
|
||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
class NewRelic | ||
class Agent | ||
class LlmEvent | ||
class Embedding < NewRelic::Agent::LlmEvent | ||
|
||
attr_accessor | ||
:input, | ||
:'request.model', | ||
:'response.organization', | ||
:'response.usage.total_tokens', | ||
:'response.usage.prompt_tokens', | ||
:'response.headers.llmVersion', | ||
:'response.headers.ratelimitLimitRequests' | ||
:'response.headers.ratelimitLimitTokens', | ||
:'response.headers.ratelimitResetTokens', | ||
:'response.headers.ratelimitResetRequests', | ||
:'response.headers.ratelimitRemainingTokens', | ||
:'response.headers.ratelimitRemainingRequests', | ||
:duration, | ||
:error | ||
|
||
def initialize | ||
|
||
end | ||
|
||
def record | ||
|
||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
|
||
class NewRelic | ||
class Agent | ||
class LlmEvent | ||
class Feedback < NewRelic::Agent::LlmEvent | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../test_helper' | ||
|
||
|
||
module NewRelic::Agent | ||
class LlmEventTest < Minitest::Test | ||
# def test_attributes | ||
# NewRelic::Agent::LlmEvent.new | ||
|
||
# end | ||
|
||
def test_attributes_chat | ||
NewRelic::Agent::LlmEvent::ChatCompletion.new | ||
end | ||
end | ||
end |