Module: Anthropic::Helpers::StainlessHelperHeader Private
- Defined in:
- lib/anthropic/helpers/stainless_helper_header.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.
Single source of truth for the x-stainless-helper telemetry header — the
key, the closed value vocabulary shared across SDKs, and the comma-append
merge.
Constant Summary collapse
- HEADER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Telemetry header naming the SDK helper(s) a request came from. Always this lowercase form; header lookups are case-insensitive but a single canonical casing keeps every call site greppable.
"x-stainless-helper"- BETA_TOOL_RUNNER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Closed value vocabulary. Existing values keep their original spellings — telemetry consumers match on them, so renames lose history. New tags are hyphenated lowercase.
"BetaToolRunner"
Class Method Summary collapse
-
.merged_value(headers, value) ⇒ String
private
The HEADER value to set after appending
valueto whatever is already present inheaders— existing tags keep their position, the new tag goes at the end, duplicates are dropped, joined as one comma-separated string.
Class Method Details
.merged_value(headers, value) ⇒ String
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.
The HEADER value to set after appending value to whatever is
already present in headers — existing tags keep their position, the
new tag goes at the end, duplicates are dropped, joined as one
comma-separated string. The backend logs the header as one opaque
string, so a second header line or a clobbered value loses data.
31 32 33 34 35 36 37 38 39 |
# File 'lib/anthropic/helpers/stainless_helper_header.rb', line 31 def merged_value(headers, value) existing = headers .filter_map { |k, v| v if k.to_s.casecmp?(HEADER) } .flat_map { _1.to_s.split(",") } .map(&:strip) .reject(&:empty?) (existing + [value]).uniq.join(", ") end |