Class: Assistant::TechnicalSupport::ResponseGroundingCitationUrls
- Inherits:
-
Object
- Object
- Assistant::TechnicalSupport::ResponseGroundingCitationUrls
- Defined in:
- app/services/assistant/technical_support/response_grounding_citation_urls.rb
Overview
Normalizes URLs from an answer and, separately, extracts only explicit URL
or citation fields from a successful structured tool payload.
Constant Summary collapse
- URL_PATTERN =
CaseReplayEvidence::URL_PATTERN
- URL_FIELD_PATTERN =
/(?:\A|_)(?:url|uri|href)s?\z/- CITATION_FIELDS =
%w[citation citations].freeze
Class Method Summary collapse
-
.from_payload(payload) ⇒ Array<String>
Extracts URLs only from explicit URL/citation payload fields.
-
.in_text(text) ⇒ Array<String>
Extracts and normalizes every URL present in answer text.
Class Method Details
.from_payload(payload) ⇒ Array<String>
Extracts URLs only from explicit URL/citation payload fields.
27 28 29 |
# File 'app/services/assistant/technical_support/response_grounding_citation_urls.rb', line 27 def from_payload(payload) extract(payload).uniq end |
.in_text(text) ⇒ Array<String>
Extracts and normalizes every URL present in answer text.
19 20 21 |
# File 'app/services/assistant/technical_support/response_grounding_citation_urls.rb', line 19 def in_text(text) text.to_s.scan(URL_PATTERN).filter_map { |url| normalize(url) }.uniq end |