Class: LlmCostTracker::Parsers::Base
- Inherits:
-
Object
- Object
- LlmCostTracker::Parsers::Base
show all
- Extended by:
- UrlMatchers
- Includes:
- UrlMatchers
- Defined in:
- lib/llm_cost_tracker/parsers/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
match_uri?, parsed_uri, path_matches?, uri_matches?
Class Method Details
.match?(_url) ⇒ Boolean
59
60
61
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 59
def match?(_url)
raise NotImplementedError
end
|
.provider_names ⇒ Object
63
64
65
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 63
def provider_names
[]
end
|
Instance Method Details
#auto_enable_stream_usage?(_request_url) ⇒ Boolean
84
85
86
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 84
def auto_enable_stream_usage?(_request_url)
false
end
|
#model_for(_request_url, request_parsed) ⇒ Object
76
77
78
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 76
def model_for(_request_url, request_parsed)
request_parsed["model"] if request_parsed.is_a?(Hash)
end
|
#parse ⇒ Object
68
69
70
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 68
def parse(**)
raise NotImplementedError
end
|
#parse_stream ⇒ Object
80
81
82
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 80
def parse_stream(**)
nil
end
|
#safe_json_parse(body) ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 88
def safe_json_parse(body)
return {} if body.blank?
JSON.parse(body)
rescue JSON::ParserError
{}
end
|
#streaming_request?(_request_url, request_parsed) ⇒ Boolean
72
73
74
|
# File 'lib/llm_cost_tracker/parsers/base.rb', line 72
def streaming_request?(_request_url, request_parsed)
request_parsed.is_a?(Hash) && request_parsed["stream"] == true
end
|