Class: Abliteration::ModelsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/abliteration/api/models_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ModelsApi

Returns a new instance of ModelsApi.



19
20
21
# File 'lib/abliteration/api/models_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



17
18
19
# File 'lib/abliteration/api/models_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#get_historical_deletion_summary(opts = {}) ⇒ GetHistoricalDeletionSummary200Response

Historical deletions — aggregate summary Cost: 20 credits, flat. Aggregates from the 24-month HF snapshot analysis: total ever seen, total deleted, deletion rate, average months alive, monthly timeline of losses, top-10 by peak downloads. One call replaces half a dozen separate queries.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:



26
27
28
29
# File 'lib/abliteration/api/models_api.rb', line 26

def get_historical_deletion_summary(opts = {})
  data, _status_code, _headers = get_historical_deletion_summary_with_http_info(opts)
  data
end

#get_historical_deletion_summary_with_http_info(opts = {}) ⇒ Array<(GetHistoricalDeletionSummary200Response, Integer, Hash)>

Historical deletions — aggregate summary Cost: 20 credits, flat. Aggregates from the 24-month HF snapshot analysis: total ever seen, total deleted, deletion rate, average months alive, monthly timeline of losses, top-10 by peak downloads. One call replaces half a dozen separate queries.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/abliteration/api/models_api.rb', line 35

def get_historical_deletion_summary_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.get_historical_deletion_summary ...'
  end
  # resource path
  local_var_path = '/api/v1/models/historical-deletions/summary'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetHistoricalDeletionSummary200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.get_historical_deletion_summary",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#get_historical_deletion_summary\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_model(id, opts = {}) ⇒ GetModel200Response

Get one model Cost: 10 credits. Priced above /authors/[id], /methods/[id] and /datasets/[id] because iterating over model ids is functionally a slow dump. The id is author/name and must be percent-encoded. Delisted models are served here even though they are hidden from the default catalog list; the response then carries is_delisted=1 and days_since_gone.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:



84
85
86
87
# File 'lib/abliteration/api/models_api.rb', line 84

def get_model(id, opts = {})
  data, _status_code, _headers = get_model_with_http_info(id, opts)
  data
end

#get_model_download_history(id, opts = {}) ⇒ GetModelDownloadHistory200Response

Per-model download timeline Cost: 5 credits, flat. Raw signal that /market/anomalies scans over. Callers with a chart or their own anomaly detector pull it once per model.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :days (Integer) —

    Window in days (max 365). Pass 0 for full history. (default to 90)

Returns:



148
149
150
151
# File 'lib/abliteration/api/models_api.rb', line 148

def get_model_download_history(id, opts = {})
  data, _status_code, _headers = get_model_download_history_with_http_info(id, opts)
  data
end

#get_model_download_history_with_http_info(id, opts = {}) ⇒ Array<(GetModelDownloadHistory200Response, Integer, Hash)>

Per-model download timeline Cost: 5 credits, flat. Raw signal that /market/anomalies scans over. Callers with a chart or their own anomaly detector pull it once per model.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :days (Integer) —

    Window in days (max 365). Pass 0 for full history. (default to 90)

Returns:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/abliteration/api/models_api.rb', line 159

def get_model_download_history_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.get_model_download_history ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.get_model_download_history"
  end
  if @api_client.config.client_side_validation && !opts[:'days'].nil? && opts[:'days'] > 365
    fail ArgumentError, 'invalid value for "opts[:"days"]" when calling ModelsApi.get_model_download_history, must be smaller than or equal to 365.'
  end

  if @api_client.config.client_side_validation && !opts[:'days'].nil? && opts[:'days'] < 0
    fail ArgumentError, 'invalid value for "opts[:"days"]" when calling ModelsApi.get_model_download_history, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/models/{id}/download-history'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'days'] = opts[:'days'] if !opts[:'days'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetModelDownloadHistory200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.get_model_download_history",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#get_model_download_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_model_readme_at(id, commit, opts = {}) ⇒ GetModelReadmeAt200Response

README content at one commit (wayback) Cost: 10 credits, flat. The wayback-machine leg of the change-stream. Returns the exact README content for one model at one commit sha — used after spotting a suspicious drift on GET /api/v1/models/id/drifts.

Parameters:

  • id (String)
  • commit (String) —

    HF commit sha for the README, from /drifts.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:



222
223
224
225
# File 'lib/abliteration/api/models_api.rb', line 222

def get_model_readme_at(id, commit, opts = {})
  data, _status_code, _headers = get_model_readme_at_with_http_info(id, commit, opts)
  data
end

#get_model_readme_at_with_http_info(id, commit, opts = {}) ⇒ Array<(GetModelReadmeAt200Response, Integer, Hash)>

README content at one commit (wayback) Cost: 10 credits, flat. The wayback-machine leg of the change-stream. Returns the exact README content for one model at one commit sha — used after spotting a suspicious drift on GET /api/v1/models/id/drifts.

Parameters:

  • id (String)
  • commit (String) —

    HF commit sha for the README, from /drifts.

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:

  • (Array<(GetModelReadmeAt200Response, Integer, Hash)>) —

    GetModelReadmeAt200Response data, response status code and response headers



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/abliteration/api/models_api.rb', line 233

def get_model_readme_at_with_http_info(id, commit, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.get_model_readme_at ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.get_model_readme_at"
  end
  # verify the required parameter 'commit' is set
  if @api_client.config.client_side_validation && commit.nil?
    fail ArgumentError, "Missing the required parameter 'commit' when calling ModelsApi.get_model_readme_at"
  end
  # resource path
  local_var_path = '/api/v1/models/{id}/readme-at/{commit}'.sub('{id}', CGI.escape(id.to_s)).sub('{commit}', CGI.escape(commit.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetModelReadmeAt200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.get_model_readme_at",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#get_model_readme_at\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_model_with_http_info(id, opts = {}) ⇒ Array<(GetModel200Response, Integer, Hash)>

Get one model Cost: 10 credits. Priced above /authors/[id], /methods/[id] and /datasets/[id] because iterating over model ids is functionally a slow dump. The id is author/name and must be percent-encoded. Delisted models are served here even though they are hidden from the default catalog list; the response then carries `is_delisted=1` and `days_since_gone`.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Returns:

  • (Array<(GetModel200Response, Integer, Hash)>) —

    GetModel200Response data, response status code and response headers



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/abliteration/api/models_api.rb', line 94

def get_model_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.get_model ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.get_model"
  end
  # resource path
  local_var_path = '/api/v1/models/{id}'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'GetModel200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.get_model",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#get_model\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_anomalies(opts = {}) ⇒ ListAnomalies200Response

Anomalies in the download counter (change stream) Cost: 15 credits, flat. Every row is a model whose downloads-per-window has crossed a threshold: 2× jump = spike, 0.5× fall = drop. Sorted by absolute delta so biggest movers surface first. Consumers get "what is happening in the field right now" without re-implementing the ETL over download_history.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :window_days (Integer) —

    Baseline distance in days. Default 7, min 1, max 365. (default to 7)

  • :min_baseline (Integer) —

    Only rows where baseline downloads >= this. Filters `0→10` noise. Default 1000. (default to 1000)

  • :kind (String) —

    Filter to one class. Omit for both.

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



294
295
296
297
# File 'lib/abliteration/api/models_api.rb', line 294

def list_anomalies(opts = {})
  data, _status_code, _headers = list_anomalies_with_http_info(opts)
  data
end

#list_anomalies_with_http_info(opts = {}) ⇒ Array<(ListAnomalies200Response, Integer, Hash)>

Anomalies in the download counter (change stream) Cost: 15 credits, flat. Every row is a model whose downloads-per-window has crossed a threshold: 2× jump = `spike`, 0.5× fall = `drop`. Sorted by absolute delta so biggest movers surface first. Consumers get &quot;what is happening in the field right now&quot; without re-implementing the ETL over `download_history`.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :window_days (Integer) —

    Baseline distance in days. Default 7, min 1, max 365. (default to 7)

  • :min_baseline (Integer) —

    Only rows where baseline downloads >= this. Filters `0→10` noise. Default 1000. (default to 1000)

  • :kind (String) —

    Filter to one class. Omit for both.

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:

  • (Array<(ListAnomalies200Response, Integer, Hash)>) —

    ListAnomalies200Response data, response status code and response headers



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/abliteration/api/models_api.rb', line 308

def list_anomalies_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.list_anomalies ...'
  end
  if @api_client.config.client_side_validation && !opts[:'window_days'].nil? && opts[:'window_days'] > 365
    fail ArgumentError, 'invalid value for "opts[:"window_days"]" when calling ModelsApi.list_anomalies, must be smaller than or equal to 365.'
  end

  if @api_client.config.client_side_validation && !opts[:'window_days'].nil? && opts[:'window_days'] < 1
    fail ArgumentError, 'invalid value for "opts[:"window_days"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'min_baseline'].nil? && opts[:'min_baseline'] < 1
    fail ArgumentError, 'invalid value for "opts[:"min_baseline"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
  end

  allowable_values = ["spike", "drop"]
  if @api_client.config.client_side_validation && opts[:'kind'] && !allowable_values.include?(opts[:'kind'])
    fail ArgumentError, "invalid value for \"kind\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_anomalies, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_anomalies, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/market/anomalies'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'window_days'] = opts[:'window_days'] if !opts[:'window_days'].nil?
  query_params[:'min_baseline'] = opts[:'min_baseline'] if !opts[:'min_baseline'].nil?
  query_params[:'kind'] = opts[:'kind'] if !opts[:'kind'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListAnomalies200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.list_anomalies",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#list_anomalies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_delisted_models(opts = {}) ⇒ ListDelistedModels200Response

List delisted models (change stream) Cost: 5 credits, flat. Change-stream companion to /models: every row is a tombstone — a model that HF no longer serves, preserved here at its final state. Poll with since=<last_seen_at of your previous run> to fetch only new casualties; callers building compliance dashboards, safety-research corpora, or "wayback" tools live on this endpoint. See /api#change-stream.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since (String) —

    ISO-8601 date or timestamp. Rows with last_seen_at >= since only. Use your previous poll's newest last_seen_at to build an incremental feed.

  • :sort (String) —

    `recent` (default, newest disappearance first) or `downloads` (biggest casualties first — best for post-mortem coverage). (default to 'recent')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



393
394
395
396
# File 'lib/abliteration/api/models_api.rb', line 393

def list_delisted_models(opts = {})
  data, _status_code, _headers = list_delisted_models_with_http_info(opts)
  data
end

#list_delisted_models_with_http_info(opts = {}) ⇒ Array<(ListDelistedModels200Response, Integer, Hash)>

List delisted models (change stream) Cost: 5 credits, flat. Change-stream companion to /models: every row is a tombstone — a model that HF no longer serves, preserved here at its final state. Poll with `since=<last_seen_at of your previous run>` to fetch only new casualties; callers building compliance dashboards, safety-research corpora, or &quot;wayback&quot; tools live on this endpoint. See /api#change-stream.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since (String) —

    ISO-8601 date or timestamp. Rows with last_seen_at >= since only. Use your previous poll's newest last_seen_at to build an incremental feed.

  • :sort (String) —

    `recent` (default, newest disappearance first) or `downloads` (biggest casualties first — best for post-mortem coverage). (default to 'recent')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/abliteration/api/models_api.rb', line 406

def list_delisted_models_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.list_delisted_models ...'
  end
  allowable_values = ["recent", "downloads"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_delisted_models, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_delisted_models, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_delisted_models, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/models/delisted'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListDelistedModels200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.list_delisted_models",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#list_delisted_models\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_historical_deletions(opts = {}) ⇒ ListHistoricalDeletions200Response

Historical deletions — paged list Cost: 5 credits, flat. Paged/filterable window on the 24-month deletion backlog. Rows are frozen at the moment the model was last seen on the Hub — peak_downloads and total_months_alive never change after death. Sort by size (downloads, default), recency (recent, newest deaths first) or lifespan (lifespan, longest-lived first — surprising deaths).

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since_month (String) —

    ISO YYYY-MM. Rows with last_seen_month >= it only.

  • :min_peak_downloads (Integer) —

    Only rows whose peak downloads >= this. `casualties over N` queries.

  • :sort (String) —

    `downloads` (default, biggest first), `recent` (newest last_seen_month first), `lifespan` (longest-lived first). (default to 'downloads')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



479
480
481
482
# File 'lib/abliteration/api/models_api.rb', line 479

def list_historical_deletions(opts = {})
  data, _status_code, _headers = list_historical_deletions_with_http_info(opts)
  data
end

#list_historical_deletions_with_http_info(opts = {}) ⇒ Array<(ListHistoricalDeletions200Response, Integer, Hash)>

Historical deletions — paged list Cost: 5 credits, flat. Paged/filterable window on the 24-month deletion backlog. Rows are frozen at the moment the model was last seen on the Hub — peak_downloads and total_months_alive never change after death. Sort by size (`downloads`, default), recency (`recent`, newest deaths first) or lifespan (`lifespan`, longest-lived first — surprising deaths).

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since_month (String) —

    ISO YYYY-MM. Rows with last_seen_month >= it only.

  • :min_peak_downloads (Integer) —

    Only rows whose peak downloads >= this. `casualties over N` queries.

  • :sort (String) —

    `downloads` (default, biggest first), `recent` (newest last_seen_month first), `lifespan` (longest-lived first). (default to 'downloads')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/abliteration/api/models_api.rb', line 493

def list_historical_deletions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.list_historical_deletions ...'
  end
  if @api_client.config.client_side_validation && !opts[:'min_peak_downloads'].nil? && opts[:'min_peak_downloads'] < 0
    fail ArgumentError, 'invalid value for "opts[:"min_peak_downloads"]" when calling ModelsApi.list_historical_deletions, must be greater than or equal to 0.'
  end

  allowable_values = ["downloads", "recent", "lifespan"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_historical_deletions, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_historical_deletions, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_historical_deletions, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/models/historical-deletions/list'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since_month'] = opts[:'since_month'] if !opts[:'since_month'].nil?
  query_params[:'min_peak_downloads'] = opts[:'min_peak_downloads'] if !opts[:'min_peak_downloads'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListHistoricalDeletions200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.list_historical_deletions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#list_historical_deletions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_model_readme_drifts(id, opts = {}) ⇒ ListModelReadmeDrifts200Response

README drift stream for one model Cost: 5 credits, flat. Every commit that changed the model's README on HF, with size_delta between commits so a consumer spots growth spurts and hard prunes without fetching each version. Poll with since_ts=<max commit_ts of your previous run> for an incremental drift feed.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since_ts (Integer) —

    Unix epoch seconds. Rows with commit_ts >= it only.

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



570
571
572
573
# File 'lib/abliteration/api/models_api.rb', line 570

def list_model_readme_drifts(id, opts = {})
  data, _status_code, _headers = list_model_readme_drifts_with_http_info(id, opts)
  data
end

#list_model_readme_drifts_with_http_info(id, opts = {}) ⇒ Array<(ListModelReadmeDrifts200Response, Integer, Hash)>

README drift stream for one model Cost: 5 credits, flat. Every commit that changed the model's README on HF, with `size_delta` between commits so a consumer spots growth spurts and hard prunes without fetching each version. Poll with `since_ts=<max commit_ts of your previous run>` for an incremental drift feed.

Parameters:

  • id (String)
  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :since_ts (Integer) —

    Unix epoch seconds. Rows with commit_ts >= it only.

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
# File 'lib/abliteration/api/models_api.rb', line 583

def list_model_readme_drifts_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.list_model_readme_drifts ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ModelsApi.list_model_readme_drifts"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_model_readme_drifts, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_model_readme_drifts, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_model_readme_drifts, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/models/{id}/drifts'.sub('{id}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'since_ts'] = opts[:'since_ts'] if !opts[:'since_ts'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListModelReadmeDrifts200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.list_model_readme_drifts",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#list_model_readme_drifts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_models(opts = {}) ⇒ ListModels200Response

List models Cost: 5-300+ credits, stepped by returned rows and multiplied by 1 + (offset/2500)². A filtered lookup up to 200 rows costs 5; a 1000-row page on the first page costs 300; on offset=10000, 5100. Filter cheap, dump expensive. See /api#pricing. Delisted models are excluded by default (delisted=live); pass delisted=dead|all to include tombstoned records. A dedicated change-stream endpoint is at GET /api/v1/models/delisted.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :method (String) —

    M-code, case-insensitive. See GET /api/v1/methods.

  • :family (String) —

    Base family, for example qwen or llama.

  • :author (String) —

    Publisher handle, case-insensitive.

  • :license (String) —

    SPDX-ish license string as published.

  • :downloads_gte (Integer)
  • :downloads_lte (Integer)
  • :created_after (String) —

    ISO-8601 date or timestamp, inclusive.

  • :created_before (String) —

    ISO-8601 date or timestamp, inclusive.

  • :delisted (String) —

    Tombstone filter. `live` (default): HF-visible models only. `dead`: delisted-only (same shape as this endpoint plus is_delisted=1 and last_seen_at). `all`: both, in one page. For a purpose-built change-stream feed, prefer GET /api/v1/models/delisted. (default to 'live')

  • :sort (String) —

    Bare key is the natural direction (downloads/likes = most first, dates = newest first). A leading `-` flips it. `created` and `first_seen` are aliases for the full column names. (default to 'downloads')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:



662
663
664
665
# File 'lib/abliteration/api/models_api.rb', line 662

def list_models(opts = {})
  data, _status_code, _headers = list_models_with_http_info(opts)
  data
end

#list_models_with_http_info(opts = {}) ⇒ Array<(ListModels200Response, Integer, Hash)>

List models Cost: 5-300+ credits, stepped by returned rows and multiplied by `1 + (offset/2500)²`. A filtered lookup up to 200 rows costs 5; a 1000-row page on the first page costs 300; on offset=10000, 5100. Filter cheap, dump expensive. See /api#pricing. Delisted models are excluded by default (`delisted=live`); pass `delisted=dead|all` to include tombstoned records. A dedicated change-stream endpoint is at GET /api/v1/models/delisted.

Parameters:

  • opts (Hash) (defaults to: {}) —

    the optional parameters

Options Hash (opts):

  • :method (String) —

    M-code, case-insensitive. See GET /api/v1/methods.

  • :family (String) —

    Base family, for example qwen or llama.

  • :author (String) —

    Publisher handle, case-insensitive.

  • :license (String) —

    SPDX-ish license string as published.

  • :downloads_gte (Integer)
  • :downloads_lte (Integer)
  • :created_after (String) —

    ISO-8601 date or timestamp, inclusive.

  • :created_before (String) —

    ISO-8601 date or timestamp, inclusive.

  • :delisted (String) —

    Tombstone filter. `live` (default): HF-visible models only. `dead`: delisted-only (same shape as this endpoint plus is_delisted=1 and last_seen_at). `all`: both, in one page. For a purpose-built change-stream feed, prefer GET /api/v1/models/delisted. (default to 'live')

  • :sort (String) —

    Bare key is the natural direction (downloads/likes = most first, dates = newest first). A leading `-` flips it. `created` and `first_seen` are aliases for the full column names. (default to 'downloads')

  • :limit (Integer) —

    Rows to return, 1 to 1000. Values outside the range are clamped, not rejected. (default to 50)

  • :offset (Integer) —

    Rows to skip. Negative and non-numeric values are treated as 0. (default to 0)

Returns:

  • (Array<(ListModels200Response, Integer, Hash)>) —

    ListModels200Response data, response status code and response headers



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
# File 'lib/abliteration/api/models_api.rb', line 683

def list_models_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ModelsApi.list_models ...'
  end
  allowable_values = ["live", "dead", "all"]
  if @api_client.config.client_side_validation && opts[:'delisted'] && !allowable_values.include?(opts[:'delisted'])
    fail ArgumentError, "invalid value for \"delisted\", must be one of #{allowable_values}"
  end
  allowable_values = ["downloads", "-downloads", "likes", "-likes", "created", "-created", "created_at", "-created_at", "first_seen", "-first_seen", "first_seen_at", "-first_seen_at"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_models, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling ModelsApi.list_models, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling ModelsApi.list_models, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/api/v1/models'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'method'] = opts[:'method'] if !opts[:'method'].nil?
  query_params[:'family'] = opts[:'family'] if !opts[:'family'].nil?
  query_params[:'author'] = opts[:'author'] if !opts[:'author'].nil?
  query_params[:'license'] = opts[:'license'] if !opts[:'license'].nil?
  query_params[:'downloads_gte'] = opts[:'downloads_gte'] if !opts[:'downloads_gte'].nil?
  query_params[:'downloads_lte'] = opts[:'downloads_lte'] if !opts[:'downloads_lte'].nil?
  query_params[:'created_after'] = opts[:'created_after'] if !opts[:'created_after'].nil?
  query_params[:'created_before'] = opts[:'created_before'] if !opts[:'created_before'].nil?
  query_params[:'delisted'] = opts[:'delisted'] if !opts[:'delisted'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ListModels200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"ModelsApi.list_models",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ModelsApi#list_models\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end