Module: Anthropic::Helpers::Tracing::Recorders::MessagesCreate Private
- Defined in:
- lib/anthropic/helpers/tracing/recorders.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
Class Method Details
.record(span, result) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/anthropic/helpers/tracing/recorders.rb', line 61 def record(span, result) data = result[:data] params = result[:req][:body] content = result[:client].open_telemetry_content? limit = result[:client].open_telemetry_max_content_bytes streamed = data.is_a?(Anthropic::Internal::Type::BaseStream) = data if data.is_a?(Anthropic::Internal::Type::BaseModel) Tracing.set_computed_usage_attributes(span, [:usage]) unless .nil? # A request whose content cannot be recorded still has its stream followed. if content Tracing.recording("the API call") do Tracing.(span, params, &.[](:content), limit: limit) end end return unless streamed result[:iterator], result[:streamed_message] = Tracing.( span, result[:iterator], params: params, start_time: result[:start_time], content: content, content_limit: limit ) end |
.start_attributes(_client, req) ⇒ Hash{String=>Object}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 |
# File 'lib/anthropic/helpers/tracing/recorders.rb', line 54 def start_attributes(_client, req) json = Tracing.json_output_format?(req[:body]) {GEN_AI_OUTPUT_TYPE => (GEN_AI_OUTPUT_TYPE_VALUE_JSON if json)} end |