Class: NewRelic::Agent::Llm::Embedding

Inherits:
LlmEvent
  • Object
show all
Includes:
ResponseHeaders
Defined in:
lib/new_relic/agent/llm/embedding.rb

Constant Summary collapse

ATTRIBUTES =
%i[input request_model token_count duration error].freeze
ATTRIBUTE_NAME_EXCEPTIONS =
{
  request_model: 'request.model'
}.freeze
ERROR_EMBEDDING_ID =
'embedding_id'
EVENT_NAME =
'LlmEmbedding'

Constants included from ResponseHeaders

ResponseHeaders::OPENAI_ORGANIZATION, ResponseHeaders::OPENAI_VERSION, ResponseHeaders::X_RATELIMIT_LIMIT_REQUESTS, ResponseHeaders::X_RATELIMIT_LIMIT_TOKENS, ResponseHeaders::X_RATELIMIT_LIMIT_TOKENS_USAGE_BASED, ResponseHeaders::X_RATELIMIT_REMAINING_REQUESTS, ResponseHeaders::X_RATELIMIT_REMAINING_TOKENS, ResponseHeaders::X_RATELIMIT_REMAINING_TOKENS_USAGE_BASED, ResponseHeaders::X_RATELIMIT_RESET_REQUESTS, ResponseHeaders::X_RATELIMIT_RESET_TOKENS, ResponseHeaders::X_RATELIMIT_RESET_TOKENS_USAGE_BASED, ResponseHeaders::X_REQUEST_ID

Constants inherited from LlmEvent

LlmEvent::AGENT_DEFINED_ATTRIBUTES, LlmEvent::CODE_STRING, LlmEvent::ERROR_ATTRIBUTE_CODE, LlmEvent::ERROR_ATTRIBUTE_PARAM, LlmEvent::ERROR_ATTRIBUTE_STATUS_CODE, LlmEvent::ERROR_STRING, LlmEvent::INGEST_SOURCE, LlmEvent::PARAM_STRING

Instance Method Summary collapse

Methods included from ResponseHeaders

#populate_openai_response_headers

Methods inherited from LlmEvent

#event_attributes, #initialize, #record, set_llm_agent_attribute_on_transaction

Constructor Details

This class inherits a constructor from NewRelic::Agent::Llm::LlmEvent

Instance Method Details

#attribute_name_exceptionsObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/new_relic/agent/llm/embedding.rb', line 24

def attribute_name_exceptions
  # TODO: OLD RUBIES < 2.6
  # Hash#merge accepts multiple arguments in 2.6
  # Remove condition once support for Ruby <2.6 is dropped
  if RUBY_VERSION >= '2.6.0'
    LlmEvent::ATTRIBUTE_NAME_EXCEPTIONS.merge(ResponseHeaders::ATTRIBUTE_NAME_EXCEPTIONS, ATTRIBUTE_NAME_EXCEPTIONS)
  else
    LlmEvent::ATTRIBUTE_NAME_EXCEPTIONS.merge(ResponseHeaders::ATTRIBUTE_NAME_EXCEPTIONS).merge(ATTRIBUTE_NAME_EXCEPTIONS)
  end
end

#attributesObject



20
21
22
# File 'lib/new_relic/agent/llm/embedding.rb', line 20

def attributes
  LlmEvent::ATTRIBUTES + ResponseHeaders::ATTRIBUTES + ATTRIBUTES
end

#error_attributes(exception) ⇒ Object



39
40
41
42
43
44
# File 'lib/new_relic/agent/llm/embedding.rb', line 39

def error_attributes(exception)
  attrs = {}
  attrs[ERROR_EMBEDDING_ID] = id

  error_attributes_from_response(exception, attrs)
end

#event_nameObject



35
36
37
# File 'lib/new_relic/agent/llm/embedding.rb', line 35

def event_name
  EVENT_NAME
end