weave-python 0.28.2__py3-none-any.whl → 0.30.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. weave/weaveapi/auth/v1/service_pb2.py +184 -88
  2. weave/weaveapi/auth/v1/service_pb2.pyi +1288 -1134
  3. weave/weaveapi/auth/v1/service_pb2_grpc.pyi +248 -335
  4. weave/weaveapi/auth/v1/session_pb2.py +12 -4
  5. weave/weaveapi/auth/v1/session_pb2.pyi +109 -89
  6. weave/weaveapi/auth/v1/session_pb2_grpc.pyi +11 -10
  7. weave/weaveapi/auth/v1/usage_pb2.py +16 -12
  8. weave/weaveapi/auth/v1/usage_pb2.pyi +251 -197
  9. weave/weaveapi/auth/v1/usage_pb2_grpc.pyi +11 -10
  10. weave/weaveapi/auth/v1/user_pb2.py +58 -16
  11. weave/weaveapi/auth/v1/user_pb2.pyi +588 -505
  12. weave/weaveapi/auth/v1/user_pb2_grpc.pyi +11 -10
  13. weave/weaveapi/generate/v1/configuration_pb2.py +29 -17
  14. weave/weaveapi/generate/v1/configuration_pb2.pyi +277 -241
  15. weave/weaveapi/generate/v1/configuration_pb2_grpc.pyi +11 -10
  16. weave/weaveapi/generate/v1/generate_pb2.py +30 -4
  17. weave/weaveapi/generate/v1/generate_pb2.pyi +138 -40
  18. weave/weaveapi/generate/v1/generate_pb2_grpc.pyi +11 -10
  19. weave/weaveapi/generate/v1/service_pb2.py +50 -20
  20. weave/weaveapi/generate/v1/service_pb2.pyi +264 -135
  21. weave/weaveapi/generate/v1/service_pb2_grpc.py +47 -0
  22. weave/weaveapi/generate/v1/service_pb2_grpc.pyi +89 -78
  23. weave/weaveapi/llmx/v1/architecture_pb2.py +3 -3
  24. weave/weaveapi/llmx/v1/architecture_pb2.pyi +664 -555
  25. weave/weaveapi/llmx/v1/architecture_pb2_grpc.pyi +11 -10
  26. weave/weaveapi/llmx/v1/capabilities_pb2.py +86 -54
  27. weave/weaveapi/llmx/v1/capabilities_pb2.pyi +967 -852
  28. weave/weaveapi/llmx/v1/capabilities_pb2_grpc.pyi +11 -10
  29. weave/weaveapi/llmx/v1/model_pb2.py +54 -18
  30. weave/weaveapi/llmx/v1/model_pb2.pyi +533 -455
  31. weave/weaveapi/llmx/v1/model_pb2_grpc.pyi +11 -10
  32. weave/weaveapi/llmx/v1/pricing_pb2.py +22 -18
  33. weave/weaveapi/llmx/v1/pricing_pb2.pyi +194 -172
  34. weave/weaveapi/llmx/v1/pricing_pb2_grpc.pyi +11 -10
  35. weave/weaveapi/llmx/v1/provider_pb2.py +3 -3
  36. weave/weaveapi/llmx/v1/provider_pb2.pyi +84 -59
  37. weave/weaveapi/llmx/v1/provider_pb2_grpc.pyi +11 -10
  38. weave/weaveapi/llmx/v1/service_pb2.py +224 -86
  39. weave/weaveapi/llmx/v1/service_pb2.pyi +1651 -1403
  40. weave/weaveapi/llmx/v1/service_pb2_grpc.pyi +160 -203
  41. weave/weaveapi/mcpregistry/v1/server_pb2.py +14 -8
  42. weave/weaveapi/mcpregistry/v1/server_pb2.pyi +143 -121
  43. weave/weaveapi/mcpregistry/v1/server_pb2_grpc.pyi +11 -10
  44. weave/weaveapi/mcpregistry/v1/service_pb2.py +47 -27
  45. weave/weaveapi/mcpregistry/v1/service_pb2.pyi +132 -122
  46. weave/weaveapi/mcpregistry/v1/service_pb2_grpc.pyi +87 -112
  47. weave/weaveapi/payment/v1/invoice_pb2.py +36 -10
  48. weave/weaveapi/payment/v1/invoice_pb2.pyi +352 -291
  49. weave/weaveapi/payment/v1/invoice_pb2_grpc.pyi +11 -10
  50. weave/weaveapi/payment/v1/service_pb2.py +256 -90
  51. weave/weaveapi/payment/v1/service_pb2.pyi +1381 -1242
  52. weave/weaveapi/payment/v1/service_pb2_grpc.pyi +229 -319
  53. weave/weaveapi/payment/v1/subscription_pb2.py +97 -21
  54. weave/weaveapi/payment/v1/subscription_pb2.pyi +727 -611
  55. weave/weaveapi/payment/v1/subscription_pb2_grpc.pyi +11 -10
  56. weave/weaveapi/storage/v1/auth_pb2.py +3 -3
  57. weave/weaveapi/storage/v1/auth_pb2.pyi +42 -29
  58. weave/weaveapi/storage/v1/auth_pb2_grpc.pyi +11 -10
  59. weave/weaveapi/storage/v1/nosql_database_pb2.py +45 -21
  60. weave/weaveapi/storage/v1/nosql_database_pb2.pyi +438 -372
  61. weave/weaveapi/storage/v1/nosql_database_pb2_grpc.pyi +11 -10
  62. weave/weaveapi/storage/v1/object_store_pb2.py +25 -11
  63. weave/weaveapi/storage/v1/object_store_pb2.pyi +203 -187
  64. weave/weaveapi/storage/v1/object_store_pb2_grpc.pyi +11 -10
  65. weave/weaveapi/storage/v1/service_pb2.py +94 -34
  66. weave/weaveapi/storage/v1/service_pb2.pyi +414 -357
  67. weave/weaveapi/storage/v1/service_pb2_grpc.pyi +88 -107
  68. weave/weaveapi/storage/v1/sql_database_pb2.py +37 -21
  69. weave/weaveapi/storage/v1/sql_database_pb2.pyi +481 -400
  70. weave/weaveapi/storage/v1/sql_database_pb2_grpc.pyi +11 -10
  71. weave/weaveapi/storage/v1/storage_pb2.py +18 -4
  72. weave/weaveapi/storage/v1/storage_pb2.pyi +79 -70
  73. weave/weaveapi/storage/v1/storage_pb2_grpc.pyi +11 -10
  74. weave/weaveapi/synthesize/v1/dataset_pb2.py +10 -8
  75. weave/weaveapi/synthesize/v1/dataset_pb2.pyi +158 -128
  76. weave/weaveapi/synthesize/v1/dataset_pb2_grpc.pyi +11 -10
  77. weave/weaveapi/synthesize/v1/inline_data_pb2.py +4 -4
  78. weave/weaveapi/synthesize/v1/inline_data_pb2.pyi +31 -27
  79. weave/weaveapi/synthesize/v1/inline_data_pb2_grpc.pyi +11 -10
  80. weave/weaveapi/synthesize/v1/relationship_pb2.py +17 -9
  81. weave/weaveapi/synthesize/v1/relationship_pb2.pyi +67 -64
  82. weave/weaveapi/synthesize/v1/relationship_pb2_grpc.pyi +11 -10
  83. weave/weaveapi/synthesize/v1/service_pb2.py +40 -22
  84. weave/weaveapi/synthesize/v1/service_pb2.pyi +202 -168
  85. weave/weaveapi/synthesize/v1/service_pb2_grpc.pyi +67 -79
  86. weave/weaveapi/synthesize/v1/training_pb2.py +17 -11
  87. weave/weaveapi/synthesize/v1/training_pb2.pyi +119 -106
  88. weave/weaveapi/synthesize/v1/training_pb2_grpc.pyi +11 -10
  89. weave/weavesql/llmxdb/capabilities.py +487 -0
  90. weave/weavesql/llmxdb/changes.py +297 -0
  91. weave/weavesql/llmxdb/models.py +594 -0
  92. weave/weavesql/llmxdb/providers.py +348 -0
  93. weave/weavesql/llmxdb/scraper_runs.py +287 -0
  94. weave/weavesql/llmxdb/search.py +721 -0
  95. weave/weavesql/weavedb/dataset.py +75 -0
  96. weave/weavesql/weavedb/models.py +135 -0
  97. weave/weavesql/weavedb/relationships.py +72 -0
  98. weave/weavesql/weavedb/storage.py +113 -0
  99. weave/weavesql/weavedb/synthesizer.py +107 -0
  100. {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/METADATA +3 -3
  101. weave_python-0.30.4.dist-info/RECORD +131 -0
  102. {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/WHEEL +1 -1
  103. weave_python-0.28.2.dist-info/RECORD +0 -120
  104. {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,721 @@
1
+ # Code generated by sqlc. DO NOT EDIT.
2
+ # versions:
3
+ # sqlc v1.28.0
4
+ # source: search.sql
5
+ import dataclasses
6
+ import decimal
7
+ from typing import Any, AsyncIterator, Iterator, Optional
8
+ import uuid
9
+
10
+ import sqlalchemy
11
+ import sqlalchemy.ext.asyncio
12
+
13
+ from weave.weavesql.llmxdb import models
14
+
15
+
16
+ GET_MODELS_BY_CONTEXT_WINDOW = """-- name: get_models_by_context_window \\:many
17
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
18
+ FROM llm_models
19
+ WHERE is_active = true
20
+ AND (:p1\\:\\:int IS NULL OR (token_info->>'context_window')\\:\\:int >= :p1)
21
+ AND (:p2\\:\\:int IS NULL OR (token_info->>'context_window')\\:\\:int <= :p2)
22
+ ORDER BY (token_info->>'context_window')\\:\\:int DESC
23
+ """
24
+
25
+
26
+ GET_MODELS_BY_PARAMETER_COUNT = """-- name: get_models_by_parameter_count \\:many
27
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
28
+ FROM llm_models
29
+ WHERE is_active = true
30
+ AND (:p1\\:\\:bigint IS NULL OR (architecture->>'parameter_count')\\:\\:bigint >= :p1)
31
+ AND (:p2\\:\\:bigint IS NULL OR (architecture->>'parameter_count')\\:\\:bigint <= :p2)
32
+ ORDER BY (architecture->>'parameter_count')\\:\\:bigint DESC
33
+ """
34
+
35
+
36
+ GET_MODELS_BY_PRICE_RANGE = """-- name: get_models_by_price_range \\:many
37
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
38
+ FROM llm_models
39
+ WHERE is_active = true
40
+ AND (:p1\\:\\:numeric IS NULL OR (pricing->>'input_price')\\:\\:numeric <= :p1)
41
+ AND (:p2\\:\\:numeric IS NULL OR (pricing->>'output_price')\\:\\:numeric <= :p2)
42
+ ORDER BY (pricing->>'input_price')\\:\\:numeric ASC
43
+ """
44
+
45
+
46
+ GET_MODELS_BY_SAFETY = """-- name: get_models_by_safety \\:many
47
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
48
+ FROM llm_models
49
+ WHERE is_active = true
50
+ AND (:p1\\:\\:text IS NULL OR safety->>'moderation_level' = :p1)
51
+ AND (:p2\\:\\:boolean IS NULL OR (safety->>'gdpr_compliant')\\:\\:boolean = :p2)
52
+ AND (:p3\\:\\:boolean IS NULL OR (safety->>'hipaa_compliant')\\:\\:boolean = :p3)
53
+ ORDER BY provider_id, name
54
+ """
55
+
56
+
57
+ @dataclasses.dataclass()
58
+ class GetModelsBySafetyParams:
59
+ moderation_level: str
60
+ gdpr_compliant: bool
61
+ hipaa_compliant: bool
62
+
63
+
64
+ GET_OPEN_SOURCE_MODELS = """-- name: get_open_source_models \\:many
65
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
66
+ FROM llm_models
67
+ WHERE is_active = true
68
+ AND (licensing->>'is_open_source')\\:\\:boolean = true
69
+ AND (:p1\\:\\:boolean IS NULL OR (licensing->>'commercial_use')\\:\\:boolean = :p1)
70
+ ORDER BY provider_id, name
71
+ """
72
+
73
+
74
+ SEARCH_MODELS = """-- name: search_models \\:many
75
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
76
+ FROM llm_models
77
+ WHERE is_active = true
78
+ AND (:p1\\:\\:uuid IS NULL OR provider_id = :p1)
79
+ AND (:p2\\:\\:text IS NULL OR classification ->> 'model_type' = :p2)
80
+ AND (:p3\\:\\:int IS NULL OR (token_info ->> 'context_window')\\:\\:int >= :p3)
81
+ AND (:p4\\:\\:numeric IS NULL OR (pricing ->> 'input_price')\\:\\:numeric <= :p4)
82
+ AND (:p5\\:\\:text IS NULL OR capabilities->'configs' ? :p5)
83
+ ORDER BY CASE WHEN :p6 = 'price' THEN (pricing ->> 'input_price')\\:\\:numeric END ASC,
84
+ CASE WHEN :p6 = 'context' THEN (token_info ->> 'context_window')\\:\\:int END DESC,
85
+ name ASC
86
+ LIMIT :p8 OFFSET :p7
87
+ """
88
+
89
+
90
+ @dataclasses.dataclass()
91
+ class SearchModelsParams:
92
+ provider_id: uuid.UUID
93
+ model_type: str
94
+ min_context: int
95
+ max_input_price: decimal.Decimal
96
+ has_capability: str
97
+ order_by: Optional[Any]
98
+ offset_count: int
99
+ limit_count: int
100
+
101
+
102
+ SEARCH_MODELS_BY_ARCHITECTURE = """-- name: search_models_by_architecture \\:many
103
+ SELECT id, provider_id, model_id, slug, name, display_name, description, version, capabilities, classification, architecture, performance, token_info, pricing, api_details, training, licensing, safety, availability, technical_specs, release_date, training_data_cutoff, deprecation_date, metadata, last_scraped_at, is_active, is_deprecated, created_at, updated_at
104
+ FROM llm_models
105
+ WHERE is_active = true
106
+ AND (:p1\\:\\:text IS NULL OR architecture->>'base_architecture' = :p1)
107
+ AND (:p2\\:\\:bigint IS NULL OR (architecture->>'parameter_count')\\:\\:bigint >= :p2)
108
+ AND (:p3\\:\\:bigint IS NULL OR (architecture->>'parameter_count')\\:\\:bigint <= :p3)
109
+ AND (:p4\\:\\:boolean IS NULL OR (architecture->>'is_mixture_of_experts')\\:\\:boolean = :p4)
110
+ ORDER BY (architecture->>'parameter_count')\\:\\:bigint DESC
111
+ """
112
+
113
+
114
+ @dataclasses.dataclass()
115
+ class SearchModelsByArchitectureParams:
116
+ base_architecture: str
117
+ min_params: int
118
+ max_params: int
119
+ is_moe: bool
120
+
121
+
122
+ class Querier:
123
+ def __init__(self, conn: sqlalchemy.engine.Connection):
124
+ self._conn = conn
125
+
126
+ def get_models_by_context_window(
127
+ self, *, min_context: int, max_context: int
128
+ ) -> Iterator[models.LlmModel]:
129
+ result = self._conn.execute(
130
+ sqlalchemy.text(GET_MODELS_BY_CONTEXT_WINDOW),
131
+ {"p1": min_context, "p2": max_context},
132
+ )
133
+ for row in result:
134
+ yield models.LlmModel(
135
+ id=row[0],
136
+ provider_id=row[1],
137
+ model_id=row[2],
138
+ slug=row[3],
139
+ name=row[4],
140
+ display_name=row[5],
141
+ description=row[6],
142
+ version=row[7],
143
+ capabilities=row[8],
144
+ classification=row[9],
145
+ architecture=row[10],
146
+ performance=row[11],
147
+ token_info=row[12],
148
+ pricing=row[13],
149
+ api_details=row[14],
150
+ training=row[15],
151
+ licensing=row[16],
152
+ safety=row[17],
153
+ availability=row[18],
154
+ technical_specs=row[19],
155
+ release_date=row[20],
156
+ training_data_cutoff=row[21],
157
+ deprecation_date=row[22],
158
+ metadata=row[23],
159
+ last_scraped_at=row[24],
160
+ is_active=row[25],
161
+ is_deprecated=row[26],
162
+ created_at=row[27],
163
+ updated_at=row[28],
164
+ )
165
+
166
+ def get_models_by_parameter_count(
167
+ self, *, min_params: int, max_params: int
168
+ ) -> Iterator[models.LlmModel]:
169
+ result = self._conn.execute(
170
+ sqlalchemy.text(GET_MODELS_BY_PARAMETER_COUNT),
171
+ {"p1": min_params, "p2": max_params},
172
+ )
173
+ for row in result:
174
+ yield models.LlmModel(
175
+ id=row[0],
176
+ provider_id=row[1],
177
+ model_id=row[2],
178
+ slug=row[3],
179
+ name=row[4],
180
+ display_name=row[5],
181
+ description=row[6],
182
+ version=row[7],
183
+ capabilities=row[8],
184
+ classification=row[9],
185
+ architecture=row[10],
186
+ performance=row[11],
187
+ token_info=row[12],
188
+ pricing=row[13],
189
+ api_details=row[14],
190
+ training=row[15],
191
+ licensing=row[16],
192
+ safety=row[17],
193
+ availability=row[18],
194
+ technical_specs=row[19],
195
+ release_date=row[20],
196
+ training_data_cutoff=row[21],
197
+ deprecation_date=row[22],
198
+ metadata=row[23],
199
+ last_scraped_at=row[24],
200
+ is_active=row[25],
201
+ is_deprecated=row[26],
202
+ created_at=row[27],
203
+ updated_at=row[28],
204
+ )
205
+
206
+ def get_models_by_price_range(
207
+ self, *, max_input_price: decimal.Decimal, max_output_price: decimal.Decimal
208
+ ) -> Iterator[models.LlmModel]:
209
+ result = self._conn.execute(
210
+ sqlalchemy.text(GET_MODELS_BY_PRICE_RANGE),
211
+ {"p1": max_input_price, "p2": max_output_price},
212
+ )
213
+ for row in result:
214
+ yield models.LlmModel(
215
+ id=row[0],
216
+ provider_id=row[1],
217
+ model_id=row[2],
218
+ slug=row[3],
219
+ name=row[4],
220
+ display_name=row[5],
221
+ description=row[6],
222
+ version=row[7],
223
+ capabilities=row[8],
224
+ classification=row[9],
225
+ architecture=row[10],
226
+ performance=row[11],
227
+ token_info=row[12],
228
+ pricing=row[13],
229
+ api_details=row[14],
230
+ training=row[15],
231
+ licensing=row[16],
232
+ safety=row[17],
233
+ availability=row[18],
234
+ technical_specs=row[19],
235
+ release_date=row[20],
236
+ training_data_cutoff=row[21],
237
+ deprecation_date=row[22],
238
+ metadata=row[23],
239
+ last_scraped_at=row[24],
240
+ is_active=row[25],
241
+ is_deprecated=row[26],
242
+ created_at=row[27],
243
+ updated_at=row[28],
244
+ )
245
+
246
+ def get_models_by_safety(
247
+ self, arg: GetModelsBySafetyParams
248
+ ) -> Iterator[models.LlmModel]:
249
+ result = self._conn.execute(
250
+ sqlalchemy.text(GET_MODELS_BY_SAFETY),
251
+ {
252
+ "p1": arg.moderation_level,
253
+ "p2": arg.gdpr_compliant,
254
+ "p3": arg.hipaa_compliant,
255
+ },
256
+ )
257
+ for row in result:
258
+ yield models.LlmModel(
259
+ id=row[0],
260
+ provider_id=row[1],
261
+ model_id=row[2],
262
+ slug=row[3],
263
+ name=row[4],
264
+ display_name=row[5],
265
+ description=row[6],
266
+ version=row[7],
267
+ capabilities=row[8],
268
+ classification=row[9],
269
+ architecture=row[10],
270
+ performance=row[11],
271
+ token_info=row[12],
272
+ pricing=row[13],
273
+ api_details=row[14],
274
+ training=row[15],
275
+ licensing=row[16],
276
+ safety=row[17],
277
+ availability=row[18],
278
+ technical_specs=row[19],
279
+ release_date=row[20],
280
+ training_data_cutoff=row[21],
281
+ deprecation_date=row[22],
282
+ metadata=row[23],
283
+ last_scraped_at=row[24],
284
+ is_active=row[25],
285
+ is_deprecated=row[26],
286
+ created_at=row[27],
287
+ updated_at=row[28],
288
+ )
289
+
290
+ def get_open_source_models(
291
+ self, *, commercial_use: bool
292
+ ) -> Iterator[models.LlmModel]:
293
+ result = self._conn.execute(
294
+ sqlalchemy.text(GET_OPEN_SOURCE_MODELS), {"p1": commercial_use}
295
+ )
296
+ for row in result:
297
+ yield models.LlmModel(
298
+ id=row[0],
299
+ provider_id=row[1],
300
+ model_id=row[2],
301
+ slug=row[3],
302
+ name=row[4],
303
+ display_name=row[5],
304
+ description=row[6],
305
+ version=row[7],
306
+ capabilities=row[8],
307
+ classification=row[9],
308
+ architecture=row[10],
309
+ performance=row[11],
310
+ token_info=row[12],
311
+ pricing=row[13],
312
+ api_details=row[14],
313
+ training=row[15],
314
+ licensing=row[16],
315
+ safety=row[17],
316
+ availability=row[18],
317
+ technical_specs=row[19],
318
+ release_date=row[20],
319
+ training_data_cutoff=row[21],
320
+ deprecation_date=row[22],
321
+ metadata=row[23],
322
+ last_scraped_at=row[24],
323
+ is_active=row[25],
324
+ is_deprecated=row[26],
325
+ created_at=row[27],
326
+ updated_at=row[28],
327
+ )
328
+
329
+ def search_models(self, arg: SearchModelsParams) -> Iterator[models.LlmModel]:
330
+ result = self._conn.execute(
331
+ sqlalchemy.text(SEARCH_MODELS),
332
+ {
333
+ "p1": arg.provider_id,
334
+ "p2": arg.model_type,
335
+ "p3": arg.min_context,
336
+ "p4": arg.max_input_price,
337
+ "p5": arg.has_capability,
338
+ "p6": arg.order_by,
339
+ "p7": arg.offset_count,
340
+ "p8": arg.limit_count,
341
+ },
342
+ )
343
+ for row in result:
344
+ yield models.LlmModel(
345
+ id=row[0],
346
+ provider_id=row[1],
347
+ model_id=row[2],
348
+ slug=row[3],
349
+ name=row[4],
350
+ display_name=row[5],
351
+ description=row[6],
352
+ version=row[7],
353
+ capabilities=row[8],
354
+ classification=row[9],
355
+ architecture=row[10],
356
+ performance=row[11],
357
+ token_info=row[12],
358
+ pricing=row[13],
359
+ api_details=row[14],
360
+ training=row[15],
361
+ licensing=row[16],
362
+ safety=row[17],
363
+ availability=row[18],
364
+ technical_specs=row[19],
365
+ release_date=row[20],
366
+ training_data_cutoff=row[21],
367
+ deprecation_date=row[22],
368
+ metadata=row[23],
369
+ last_scraped_at=row[24],
370
+ is_active=row[25],
371
+ is_deprecated=row[26],
372
+ created_at=row[27],
373
+ updated_at=row[28],
374
+ )
375
+
376
+ def search_models_by_architecture(
377
+ self, arg: SearchModelsByArchitectureParams
378
+ ) -> Iterator[models.LlmModel]:
379
+ result = self._conn.execute(
380
+ sqlalchemy.text(SEARCH_MODELS_BY_ARCHITECTURE),
381
+ {
382
+ "p1": arg.base_architecture,
383
+ "p2": arg.min_params,
384
+ "p3": arg.max_params,
385
+ "p4": arg.is_moe,
386
+ },
387
+ )
388
+ for row in result:
389
+ yield models.LlmModel(
390
+ id=row[0],
391
+ provider_id=row[1],
392
+ model_id=row[2],
393
+ slug=row[3],
394
+ name=row[4],
395
+ display_name=row[5],
396
+ description=row[6],
397
+ version=row[7],
398
+ capabilities=row[8],
399
+ classification=row[9],
400
+ architecture=row[10],
401
+ performance=row[11],
402
+ token_info=row[12],
403
+ pricing=row[13],
404
+ api_details=row[14],
405
+ training=row[15],
406
+ licensing=row[16],
407
+ safety=row[17],
408
+ availability=row[18],
409
+ technical_specs=row[19],
410
+ release_date=row[20],
411
+ training_data_cutoff=row[21],
412
+ deprecation_date=row[22],
413
+ metadata=row[23],
414
+ last_scraped_at=row[24],
415
+ is_active=row[25],
416
+ is_deprecated=row[26],
417
+ created_at=row[27],
418
+ updated_at=row[28],
419
+ )
420
+
421
+
422
+ class AsyncQuerier:
423
+ def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
424
+ self._conn = conn
425
+
426
+ async def get_models_by_context_window(
427
+ self, *, min_context: int, max_context: int
428
+ ) -> AsyncIterator[models.LlmModel]:
429
+ result = await self._conn.stream(
430
+ sqlalchemy.text(GET_MODELS_BY_CONTEXT_WINDOW),
431
+ {"p1": min_context, "p2": max_context},
432
+ )
433
+ async for row in result:
434
+ yield models.LlmModel(
435
+ id=row[0],
436
+ provider_id=row[1],
437
+ model_id=row[2],
438
+ slug=row[3],
439
+ name=row[4],
440
+ display_name=row[5],
441
+ description=row[6],
442
+ version=row[7],
443
+ capabilities=row[8],
444
+ classification=row[9],
445
+ architecture=row[10],
446
+ performance=row[11],
447
+ token_info=row[12],
448
+ pricing=row[13],
449
+ api_details=row[14],
450
+ training=row[15],
451
+ licensing=row[16],
452
+ safety=row[17],
453
+ availability=row[18],
454
+ technical_specs=row[19],
455
+ release_date=row[20],
456
+ training_data_cutoff=row[21],
457
+ deprecation_date=row[22],
458
+ metadata=row[23],
459
+ last_scraped_at=row[24],
460
+ is_active=row[25],
461
+ is_deprecated=row[26],
462
+ created_at=row[27],
463
+ updated_at=row[28],
464
+ )
465
+
466
+ async def get_models_by_parameter_count(
467
+ self, *, min_params: int, max_params: int
468
+ ) -> AsyncIterator[models.LlmModel]:
469
+ result = await self._conn.stream(
470
+ sqlalchemy.text(GET_MODELS_BY_PARAMETER_COUNT),
471
+ {"p1": min_params, "p2": max_params},
472
+ )
473
+ async for row in result:
474
+ yield models.LlmModel(
475
+ id=row[0],
476
+ provider_id=row[1],
477
+ model_id=row[2],
478
+ slug=row[3],
479
+ name=row[4],
480
+ display_name=row[5],
481
+ description=row[6],
482
+ version=row[7],
483
+ capabilities=row[8],
484
+ classification=row[9],
485
+ architecture=row[10],
486
+ performance=row[11],
487
+ token_info=row[12],
488
+ pricing=row[13],
489
+ api_details=row[14],
490
+ training=row[15],
491
+ licensing=row[16],
492
+ safety=row[17],
493
+ availability=row[18],
494
+ technical_specs=row[19],
495
+ release_date=row[20],
496
+ training_data_cutoff=row[21],
497
+ deprecation_date=row[22],
498
+ metadata=row[23],
499
+ last_scraped_at=row[24],
500
+ is_active=row[25],
501
+ is_deprecated=row[26],
502
+ created_at=row[27],
503
+ updated_at=row[28],
504
+ )
505
+
506
+ async def get_models_by_price_range(
507
+ self, *, max_input_price: decimal.Decimal, max_output_price: decimal.Decimal
508
+ ) -> AsyncIterator[models.LlmModel]:
509
+ result = await self._conn.stream(
510
+ sqlalchemy.text(GET_MODELS_BY_PRICE_RANGE),
511
+ {"p1": max_input_price, "p2": max_output_price},
512
+ )
513
+ async for row in result:
514
+ yield models.LlmModel(
515
+ id=row[0],
516
+ provider_id=row[1],
517
+ model_id=row[2],
518
+ slug=row[3],
519
+ name=row[4],
520
+ display_name=row[5],
521
+ description=row[6],
522
+ version=row[7],
523
+ capabilities=row[8],
524
+ classification=row[9],
525
+ architecture=row[10],
526
+ performance=row[11],
527
+ token_info=row[12],
528
+ pricing=row[13],
529
+ api_details=row[14],
530
+ training=row[15],
531
+ licensing=row[16],
532
+ safety=row[17],
533
+ availability=row[18],
534
+ technical_specs=row[19],
535
+ release_date=row[20],
536
+ training_data_cutoff=row[21],
537
+ deprecation_date=row[22],
538
+ metadata=row[23],
539
+ last_scraped_at=row[24],
540
+ is_active=row[25],
541
+ is_deprecated=row[26],
542
+ created_at=row[27],
543
+ updated_at=row[28],
544
+ )
545
+
546
+ async def get_models_by_safety(
547
+ self, arg: GetModelsBySafetyParams
548
+ ) -> AsyncIterator[models.LlmModel]:
549
+ result = await self._conn.stream(
550
+ sqlalchemy.text(GET_MODELS_BY_SAFETY),
551
+ {
552
+ "p1": arg.moderation_level,
553
+ "p2": arg.gdpr_compliant,
554
+ "p3": arg.hipaa_compliant,
555
+ },
556
+ )
557
+ async for row in result:
558
+ yield models.LlmModel(
559
+ id=row[0],
560
+ provider_id=row[1],
561
+ model_id=row[2],
562
+ slug=row[3],
563
+ name=row[4],
564
+ display_name=row[5],
565
+ description=row[6],
566
+ version=row[7],
567
+ capabilities=row[8],
568
+ classification=row[9],
569
+ architecture=row[10],
570
+ performance=row[11],
571
+ token_info=row[12],
572
+ pricing=row[13],
573
+ api_details=row[14],
574
+ training=row[15],
575
+ licensing=row[16],
576
+ safety=row[17],
577
+ availability=row[18],
578
+ technical_specs=row[19],
579
+ release_date=row[20],
580
+ training_data_cutoff=row[21],
581
+ deprecation_date=row[22],
582
+ metadata=row[23],
583
+ last_scraped_at=row[24],
584
+ is_active=row[25],
585
+ is_deprecated=row[26],
586
+ created_at=row[27],
587
+ updated_at=row[28],
588
+ )
589
+
590
+ async def get_open_source_models(
591
+ self, *, commercial_use: bool
592
+ ) -> AsyncIterator[models.LlmModel]:
593
+ result = await self._conn.stream(
594
+ sqlalchemy.text(GET_OPEN_SOURCE_MODELS), {"p1": commercial_use}
595
+ )
596
+ async for row in result:
597
+ yield models.LlmModel(
598
+ id=row[0],
599
+ provider_id=row[1],
600
+ model_id=row[2],
601
+ slug=row[3],
602
+ name=row[4],
603
+ display_name=row[5],
604
+ description=row[6],
605
+ version=row[7],
606
+ capabilities=row[8],
607
+ classification=row[9],
608
+ architecture=row[10],
609
+ performance=row[11],
610
+ token_info=row[12],
611
+ pricing=row[13],
612
+ api_details=row[14],
613
+ training=row[15],
614
+ licensing=row[16],
615
+ safety=row[17],
616
+ availability=row[18],
617
+ technical_specs=row[19],
618
+ release_date=row[20],
619
+ training_data_cutoff=row[21],
620
+ deprecation_date=row[22],
621
+ metadata=row[23],
622
+ last_scraped_at=row[24],
623
+ is_active=row[25],
624
+ is_deprecated=row[26],
625
+ created_at=row[27],
626
+ updated_at=row[28],
627
+ )
628
+
629
+ async def search_models(
630
+ self, arg: SearchModelsParams
631
+ ) -> AsyncIterator[models.LlmModel]:
632
+ result = await self._conn.stream(
633
+ sqlalchemy.text(SEARCH_MODELS),
634
+ {
635
+ "p1": arg.provider_id,
636
+ "p2": arg.model_type,
637
+ "p3": arg.min_context,
638
+ "p4": arg.max_input_price,
639
+ "p5": arg.has_capability,
640
+ "p6": arg.order_by,
641
+ "p7": arg.offset_count,
642
+ "p8": arg.limit_count,
643
+ },
644
+ )
645
+ async for row in result:
646
+ yield models.LlmModel(
647
+ id=row[0],
648
+ provider_id=row[1],
649
+ model_id=row[2],
650
+ slug=row[3],
651
+ name=row[4],
652
+ display_name=row[5],
653
+ description=row[6],
654
+ version=row[7],
655
+ capabilities=row[8],
656
+ classification=row[9],
657
+ architecture=row[10],
658
+ performance=row[11],
659
+ token_info=row[12],
660
+ pricing=row[13],
661
+ api_details=row[14],
662
+ training=row[15],
663
+ licensing=row[16],
664
+ safety=row[17],
665
+ availability=row[18],
666
+ technical_specs=row[19],
667
+ release_date=row[20],
668
+ training_data_cutoff=row[21],
669
+ deprecation_date=row[22],
670
+ metadata=row[23],
671
+ last_scraped_at=row[24],
672
+ is_active=row[25],
673
+ is_deprecated=row[26],
674
+ created_at=row[27],
675
+ updated_at=row[28],
676
+ )
677
+
678
+ async def search_models_by_architecture(
679
+ self, arg: SearchModelsByArchitectureParams
680
+ ) -> AsyncIterator[models.LlmModel]:
681
+ result = await self._conn.stream(
682
+ sqlalchemy.text(SEARCH_MODELS_BY_ARCHITECTURE),
683
+ {
684
+ "p1": arg.base_architecture,
685
+ "p2": arg.min_params,
686
+ "p3": arg.max_params,
687
+ "p4": arg.is_moe,
688
+ },
689
+ )
690
+ async for row in result:
691
+ yield models.LlmModel(
692
+ id=row[0],
693
+ provider_id=row[1],
694
+ model_id=row[2],
695
+ slug=row[3],
696
+ name=row[4],
697
+ display_name=row[5],
698
+ description=row[6],
699
+ version=row[7],
700
+ capabilities=row[8],
701
+ classification=row[9],
702
+ architecture=row[10],
703
+ performance=row[11],
704
+ token_info=row[12],
705
+ pricing=row[13],
706
+ api_details=row[14],
707
+ training=row[15],
708
+ licensing=row[16],
709
+ safety=row[17],
710
+ availability=row[18],
711
+ technical_specs=row[19],
712
+ release_date=row[20],
713
+ training_data_cutoff=row[21],
714
+ deprecation_date=row[22],
715
+ metadata=row[23],
716
+ last_scraped_at=row[24],
717
+ is_active=row[25],
718
+ is_deprecated=row[26],
719
+ created_at=row[27],
720
+ updated_at=row[28],
721
+ )