Class: LlmDocsBuilder::Comparator
- Inherits:
-
Object
- Object
- LlmDocsBuilder::Comparator
- Defined in:
- lib/llm_docs_builder/comparator.rb
Overview
Compares content sizes between human and AI versions
Helps quantify context window savings by comparing:
-
Remote URL with different User-Agents (human vs AI bot)
-
Remote URL with local markdown file
Constant Summary collapse
- HUMAN_USER_AGENT =
Default User-Agent for simulating human browser
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120.0.0.0'- AI_USER_AGENT =
Default User-Agent for simulating AI bot
'Claude-Web/1.0 (Anthropic AI Assistant)'- MAX_REDIRECTS =
Maximum number of redirects to follow before raising an error
UrlFetcher::MAX_REDIRECTS
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Comparison options.
-
#url ⇒ String
readonly
URL to compare.
Instance Method Summary collapse
-
#compare ⇒ Hash
Compare content sizes and calculate reduction.
-
#initialize(url, options = {}) ⇒ Comparator
constructor
Initialize a new comparator.
Constructor Details
#initialize(url, options = {}) ⇒ Comparator
Initialize a new comparator
46 47 48 49 50 51 52 |
# File 'lib/llm_docs_builder/comparator.rb', line 46 def initialize(url, = {}) @url = url @options = { human_user_agent: HUMAN_USER_AGENT, ai_user_agent: AI_USER_AGENT }.merge() end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns comparison options.
36 37 38 |
# File 'lib/llm_docs_builder/comparator.rb', line 36 def @options end |
#url ⇒ String (readonly)
Returns URL to compare.
33 34 35 |
# File 'lib/llm_docs_builder/comparator.rb', line 33 def url @url end |
Instance Method Details
#compare ⇒ Hash
Compare content sizes and calculate reduction
68 69 70 71 72 73 74 |
# File 'lib/llm_docs_builder/comparator.rb', line 68 def compare if [:local_file] compare_with_local_file else compare_remote_versions end end |