Class: LlmCostTracker::Parsers::Base
- Inherits:
-
Object
- Object
- LlmCostTracker::Parsers::Base
show all
- Extended by:
- UrlMatchers
- Includes:
- UrlMatchers
- Defined in:
- lib/llm_cost_tracker/parsers.rb
Class Method Summary
collapse
Instance Method Summary
collapse
match_uri?, parsed_uri, path_matches?, uri_matches?
Class Method Details
.match?(_url) ⇒ Boolean
82
83
84
|
# File 'lib/llm_cost_tracker/parsers.rb', line 82
def match?(_url)
raise NotImplementedError
end
|
.provider_names ⇒ Object
86
87
88
|
# File 'lib/llm_cost_tracker/parsers.rb', line 86
def provider_names
[]
end
|
Instance Method Details
#auto_enable_stream_usage?(_request_url) ⇒ Boolean
107
108
109
|
# File 'lib/llm_cost_tracker/parsers.rb', line 107
def auto_enable_stream_usage?(_request_url)
false
end
|
#model_for(_request_url, request_parsed) ⇒ Object
99
100
101
|
# File 'lib/llm_cost_tracker/parsers.rb', line 99
def model_for(_request_url, request_parsed)
request_parsed["model"]
end
|
#parse ⇒ Object
91
92
93
|
# File 'lib/llm_cost_tracker/parsers.rb', line 91
def parse(**)
raise NotImplementedError
end
|
#parse_stream ⇒ Object
103
104
105
|
# File 'lib/llm_cost_tracker/parsers.rb', line 103
def parse_stream(**)
nil
end
|
#safe_json_parse(body) ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'lib/llm_cost_tracker/parsers.rb', line 111
def safe_json_parse(body)
return {} if body.blank?
parsed = JSON.parse(body)
parsed.is_a?(Hash) ? parsed : {}
rescue JSON::ParserError
{}
end
|
#streaming_request?(_request_url, request_parsed) ⇒ Boolean
95
96
97
|
# File 'lib/llm_cost_tracker/parsers.rb', line 95
def streaming_request?(_request_url, request_parsed)
request_parsed["stream"] == true
end
|