12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/legion/llm/api/native/offerings.rb', line 12
def self.registered(app)
log.debug('[llm][api][offerings] registering offering inventory routes')
app.get '/api/llm/offerings' do
log.debug('[llm][api][offerings] action=list_offerings')
require_llm!
filters = Legion::LLM::API::Native::Offerings.request_filters(params)
offerings = Legion::LLM::Inventory.offerings(filters)
json_response({
offerings: offerings,
summary: Legion::LLM::API::Native::Offerings.summary(offerings, filters)
})
rescue StandardError => e
handle_exception(e, level: :error, handled: true, operation: 'llm.api.offerings.list')
json_error('offering_inventory_error', e.message, status_code: 500)
end
app.get '/api/llm/offerings/:id' do
offering_id = params[:id]
log.debug("[llm][api][offerings] action=get_offering id=#{offering_id}")
require_llm!
offering = Legion::LLM::Inventory.offerings(offering_id: offering_id).first
halt json_error('offering_not_found', "Offering '#{offering_id}' not found", status_code: 404) unless offering
json_response({ offering: offering })
rescue StandardError => e
handle_exception(e, level: :error, handled: true, operation: 'llm.api.offerings.get')
json_error('offering_inventory_error', e.message, status_code: 500)
end
log.debug('[llm][api][offerings] offering inventory routes registered')
end
|