weave-python 0.28.2__py3-none-any.whl → 0.30.3__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 +194 -98
  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 +14 -6
  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 +18 -14
  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 +60 -18
  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 +31 -19
  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 +32 -6
  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 +52 -22
  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 +42 -42
  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 +88 -56
  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 +56 -20
  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 +24 -20
  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 +6 -6
  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 +228 -90
  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 +16 -10
  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 +51 -31
  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 +38 -12
  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 +264 -98
  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 +99 -23
  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 +6 -6
  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 +47 -23
  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 +27 -13
  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 +96 -36
  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 +39 -23
  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 +20 -6
  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 +14 -12
  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 +9 -9
  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 +19 -11
  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 +42 -24
  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 +19 -13
  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.3.dist-info}/METADATA +3 -3
  101. weave_python-0.30.3.dist-info/RECORD +131 -0
  102. {weave_python-0.28.2.dist-info → weave_python-0.30.3.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.3.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,594 @@
1
+ # Code generated by sqlc. DO NOT EDIT.
2
+ # versions:
3
+ # sqlc v1.28.0
4
+ # source: models.sql
5
+ import dataclasses
6
+ import datetime
7
+ from typing import Any, AsyncIterator, Iterator, List, Optional
8
+ import uuid
9
+
10
+ import sqlalchemy
11
+ import sqlalchemy.ext.asyncio
12
+
13
+ from weave.weavesql.llmxdb import models
14
+
15
+
16
+ BATCH_UPSERT_MODELS = """-- name: batch_upsert_models \\:copyfrom
17
+ INSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,
18
+ classification, architecture, capabilities, performance, token_info,
19
+ pricing, api_details, training, licensing, safety, availability,
20
+ technical_specs, metadata)
21
+ VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7,
22
+ :p8, :p9, :p10, :p11, :p12,
23
+ :p13, :p14, :p15, :p16, :p17, :p18,
24
+ :p19, :p20)
25
+ """
26
+
27
+
28
+ @dataclasses.dataclass()
29
+ class BatchUpsertModelsParams:
30
+ provider_id: uuid.UUID
31
+ model_id: str
32
+ slug: str
33
+ name: str
34
+ display_name: Optional[str]
35
+ description: Optional[str]
36
+ version: Optional[str]
37
+ classification: Any
38
+ architecture: Any
39
+ capabilities: Any
40
+ performance: Any
41
+ token_info: Any
42
+ pricing: Any
43
+ api_details: Any
44
+ training: Any
45
+ licensing: Any
46
+ safety: Any
47
+ availability: Any
48
+ technical_specs: Any
49
+ metadata: Any
50
+
51
+
52
+ GET_MODEL = """-- name: get_model \\:one
53
+ 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
54
+ FROM llm_models
55
+ WHERE slug = :p1
56
+ AND is_active = true
57
+ """
58
+
59
+
60
+ GET_MODELS = """-- name: get_models \\:many
61
+ 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
62
+ FROM llm_models
63
+ WHERE is_active = true
64
+ ORDER BY provider_id, name
65
+ """
66
+
67
+
68
+ GET_MODELS_BY_PROVIDER = """-- name: get_models_by_provider \\:many
69
+ 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
70
+ FROM llm_models
71
+ WHERE provider_id = :p1
72
+ AND is_active = true
73
+ ORDER BY name
74
+ """
75
+
76
+
77
+ UPDATE_MODEL_DEPRECATION = """-- name: update_model_deprecation \\:exec
78
+ UPDATE llm_models
79
+ SET is_deprecated = true,
80
+ deprecation_date = :p1,
81
+ metadata = jsonb_set(metadata, '{replacement_model_id}', to_jsonb(:p2\\:\\:text))
82
+ WHERE slug = :p3
83
+ """
84
+
85
+
86
+ @dataclasses.dataclass()
87
+ class UpdateModelDeprecationParams:
88
+ deprecation_date: Optional[datetime.datetime]
89
+ replacement_model_id: str
90
+ slug: str
91
+
92
+
93
+ UPSERT_MODEL = """-- name: upsert_model \\:one
94
+ INSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,
95
+ classification, architecture, capabilities, performance, token_info,
96
+ pricing, api_details, training, licensing, safety, availability,
97
+ technical_specs, release_date, training_data_cutoff, deprecation_date,
98
+ metadata, last_scraped_at)
99
+ VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7,
100
+ :p8, :p9, :p10, :p11, :p12,
101
+ :p13, :p14, :p15, :p16, :p17, :p18,
102
+ :p19, :p20, :p21, :p22,
103
+ :p23, NOW())
104
+ ON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name,
105
+ display_name = EXCLUDED.display_name,
106
+ description = EXCLUDED.description,
107
+ version = EXCLUDED.version,
108
+ classification = EXCLUDED.classification,
109
+ architecture = EXCLUDED.architecture,
110
+ capabilities = EXCLUDED.capabilities,
111
+ performance = EXCLUDED.performance,
112
+ token_info = EXCLUDED.token_info,
113
+ pricing = EXCLUDED.pricing,
114
+ api_details = EXCLUDED.api_details,
115
+ training = EXCLUDED.training,
116
+ licensing = EXCLUDED.licensing,
117
+ safety = EXCLUDED.safety,
118
+ availability = EXCLUDED.availability,
119
+ technical_specs = EXCLUDED.technical_specs,
120
+ release_date = EXCLUDED.release_date,
121
+ training_data_cutoff = EXCLUDED.training_data_cutoff,
122
+ deprecation_date = EXCLUDED.deprecation_date,
123
+ metadata = EXCLUDED.metadata,
124
+ last_scraped_at = NOW(),
125
+ updated_at = NOW()
126
+ RETURNING 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
127
+ """
128
+
129
+
130
+ @dataclasses.dataclass()
131
+ class UpsertModelParams:
132
+ provider_id: uuid.UUID
133
+ model_id: str
134
+ slug: str
135
+ name: str
136
+ display_name: Optional[str]
137
+ description: Optional[str]
138
+ version: Optional[str]
139
+ classification: Any
140
+ architecture: Any
141
+ capabilities: Any
142
+ performance: Any
143
+ token_info: Any
144
+ pricing: Any
145
+ api_details: Any
146
+ training: Any
147
+ licensing: Any
148
+ safety: Any
149
+ availability: Any
150
+ technical_specs: Any
151
+ release_date: Optional[datetime.datetime]
152
+ training_data_cutoff: Optional[datetime.datetime]
153
+ deprecation_date: Optional[datetime.datetime]
154
+ metadata: Any
155
+
156
+
157
+ class Querier:
158
+ def __init__(self, conn: sqlalchemy.engine.Connection):
159
+ self._conn = conn
160
+
161
+ def batch_upsert_models(self, arg_list: List[BatchUpsertModelsParams]) -> int:
162
+ data = list()
163
+ for item in arg_list:
164
+ data.append(
165
+ {
166
+ "p1": item.provider_id,
167
+ "p2": item.model_id,
168
+ "p3": item.slug,
169
+ "p4": item.name,
170
+ "p5": item.display_name,
171
+ "p6": item.description,
172
+ "p7": item.version,
173
+ "p8": item.classification,
174
+ "p9": item.architecture,
175
+ "p10": item.capabilities,
176
+ "p11": item.performance,
177
+ "p12": item.token_info,
178
+ "p13": item.pricing,
179
+ "p14": item.api_details,
180
+ "p15": item.training,
181
+ "p16": item.licensing,
182
+ "p17": item.safety,
183
+ "p18": item.availability,
184
+ "p19": item.technical_specs,
185
+ "p20": item.metadata,
186
+ }
187
+ )
188
+ result = self._conn.execute(sqlalchemy.text(BATCH_UPSERT_MODELS), data)
189
+ return result.rowcount
190
+
191
+ def get_model(self, *, slug: str) -> Optional[models.LlmModel]:
192
+ row = self._conn.execute(sqlalchemy.text(GET_MODEL), {"p1": slug}).first()
193
+ if row is None:
194
+ return None
195
+ return models.LlmModel(
196
+ id=row[0],
197
+ provider_id=row[1],
198
+ model_id=row[2],
199
+ slug=row[3],
200
+ name=row[4],
201
+ display_name=row[5],
202
+ description=row[6],
203
+ version=row[7],
204
+ capabilities=row[8],
205
+ classification=row[9],
206
+ architecture=row[10],
207
+ performance=row[11],
208
+ token_info=row[12],
209
+ pricing=row[13],
210
+ api_details=row[14],
211
+ training=row[15],
212
+ licensing=row[16],
213
+ safety=row[17],
214
+ availability=row[18],
215
+ technical_specs=row[19],
216
+ release_date=row[20],
217
+ training_data_cutoff=row[21],
218
+ deprecation_date=row[22],
219
+ metadata=row[23],
220
+ last_scraped_at=row[24],
221
+ is_active=row[25],
222
+ is_deprecated=row[26],
223
+ created_at=row[27],
224
+ updated_at=row[28],
225
+ )
226
+
227
+ def get_models(self) -> Iterator[models.LlmModel]:
228
+ result = self._conn.execute(sqlalchemy.text(GET_MODELS))
229
+ for row in result:
230
+ yield models.LlmModel(
231
+ id=row[0],
232
+ provider_id=row[1],
233
+ model_id=row[2],
234
+ slug=row[3],
235
+ name=row[4],
236
+ display_name=row[5],
237
+ description=row[6],
238
+ version=row[7],
239
+ capabilities=row[8],
240
+ classification=row[9],
241
+ architecture=row[10],
242
+ performance=row[11],
243
+ token_info=row[12],
244
+ pricing=row[13],
245
+ api_details=row[14],
246
+ training=row[15],
247
+ licensing=row[16],
248
+ safety=row[17],
249
+ availability=row[18],
250
+ technical_specs=row[19],
251
+ release_date=row[20],
252
+ training_data_cutoff=row[21],
253
+ deprecation_date=row[22],
254
+ metadata=row[23],
255
+ last_scraped_at=row[24],
256
+ is_active=row[25],
257
+ is_deprecated=row[26],
258
+ created_at=row[27],
259
+ updated_at=row[28],
260
+ )
261
+
262
+ def get_models_by_provider(
263
+ self, *, provider_id: uuid.UUID
264
+ ) -> Iterator[models.LlmModel]:
265
+ result = self._conn.execute(
266
+ sqlalchemy.text(GET_MODELS_BY_PROVIDER), {"p1": provider_id}
267
+ )
268
+ for row in result:
269
+ yield models.LlmModel(
270
+ id=row[0],
271
+ provider_id=row[1],
272
+ model_id=row[2],
273
+ slug=row[3],
274
+ name=row[4],
275
+ display_name=row[5],
276
+ description=row[6],
277
+ version=row[7],
278
+ capabilities=row[8],
279
+ classification=row[9],
280
+ architecture=row[10],
281
+ performance=row[11],
282
+ token_info=row[12],
283
+ pricing=row[13],
284
+ api_details=row[14],
285
+ training=row[15],
286
+ licensing=row[16],
287
+ safety=row[17],
288
+ availability=row[18],
289
+ technical_specs=row[19],
290
+ release_date=row[20],
291
+ training_data_cutoff=row[21],
292
+ deprecation_date=row[22],
293
+ metadata=row[23],
294
+ last_scraped_at=row[24],
295
+ is_active=row[25],
296
+ is_deprecated=row[26],
297
+ created_at=row[27],
298
+ updated_at=row[28],
299
+ )
300
+
301
+ def update_model_deprecation(self, arg: UpdateModelDeprecationParams) -> None:
302
+ self._conn.execute(
303
+ sqlalchemy.text(UPDATE_MODEL_DEPRECATION),
304
+ {
305
+ "p1": arg.deprecation_date,
306
+ "p2": arg.replacement_model_id,
307
+ "p3": arg.slug,
308
+ },
309
+ )
310
+
311
+ def upsert_model(self, arg: UpsertModelParams) -> Optional[models.LlmModel]:
312
+ row = self._conn.execute(
313
+ sqlalchemy.text(UPSERT_MODEL),
314
+ {
315
+ "p1": arg.provider_id,
316
+ "p2": arg.model_id,
317
+ "p3": arg.slug,
318
+ "p4": arg.name,
319
+ "p5": arg.display_name,
320
+ "p6": arg.description,
321
+ "p7": arg.version,
322
+ "p8": arg.classification,
323
+ "p9": arg.architecture,
324
+ "p10": arg.capabilities,
325
+ "p11": arg.performance,
326
+ "p12": arg.token_info,
327
+ "p13": arg.pricing,
328
+ "p14": arg.api_details,
329
+ "p15": arg.training,
330
+ "p16": arg.licensing,
331
+ "p17": arg.safety,
332
+ "p18": arg.availability,
333
+ "p19": arg.technical_specs,
334
+ "p20": arg.release_date,
335
+ "p21": arg.training_data_cutoff,
336
+ "p22": arg.deprecation_date,
337
+ "p23": arg.metadata,
338
+ },
339
+ ).first()
340
+ if row is None:
341
+ return None
342
+ return models.LlmModel(
343
+ id=row[0],
344
+ provider_id=row[1],
345
+ model_id=row[2],
346
+ slug=row[3],
347
+ name=row[4],
348
+ display_name=row[5],
349
+ description=row[6],
350
+ version=row[7],
351
+ capabilities=row[8],
352
+ classification=row[9],
353
+ architecture=row[10],
354
+ performance=row[11],
355
+ token_info=row[12],
356
+ pricing=row[13],
357
+ api_details=row[14],
358
+ training=row[15],
359
+ licensing=row[16],
360
+ safety=row[17],
361
+ availability=row[18],
362
+ technical_specs=row[19],
363
+ release_date=row[20],
364
+ training_data_cutoff=row[21],
365
+ deprecation_date=row[22],
366
+ metadata=row[23],
367
+ last_scraped_at=row[24],
368
+ is_active=row[25],
369
+ is_deprecated=row[26],
370
+ created_at=row[27],
371
+ updated_at=row[28],
372
+ )
373
+
374
+
375
+ class AsyncQuerier:
376
+ def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
377
+ self._conn = conn
378
+
379
+ async def batch_upsert_models(self, arg_list: List[BatchUpsertModelsParams]) -> int:
380
+ data = list()
381
+ for item in arg_list:
382
+ data.append(
383
+ {
384
+ "p1": item.provider_id,
385
+ "p2": item.model_id,
386
+ "p3": item.slug,
387
+ "p4": item.name,
388
+ "p5": item.display_name,
389
+ "p6": item.description,
390
+ "p7": item.version,
391
+ "p8": item.classification,
392
+ "p9": item.architecture,
393
+ "p10": item.capabilities,
394
+ "p11": item.performance,
395
+ "p12": item.token_info,
396
+ "p13": item.pricing,
397
+ "p14": item.api_details,
398
+ "p15": item.training,
399
+ "p16": item.licensing,
400
+ "p17": item.safety,
401
+ "p18": item.availability,
402
+ "p19": item.technical_specs,
403
+ "p20": item.metadata,
404
+ }
405
+ )
406
+ result = await self._conn.execute(sqlalchemy.text(BATCH_UPSERT_MODELS), data)
407
+ return result.rowcount
408
+
409
+ async def get_model(self, *, slug: str) -> Optional[models.LlmModel]:
410
+ row = (
411
+ await self._conn.execute(sqlalchemy.text(GET_MODEL), {"p1": slug})
412
+ ).first()
413
+ if row is None:
414
+ return None
415
+ return models.LlmModel(
416
+ id=row[0],
417
+ provider_id=row[1],
418
+ model_id=row[2],
419
+ slug=row[3],
420
+ name=row[4],
421
+ display_name=row[5],
422
+ description=row[6],
423
+ version=row[7],
424
+ capabilities=row[8],
425
+ classification=row[9],
426
+ architecture=row[10],
427
+ performance=row[11],
428
+ token_info=row[12],
429
+ pricing=row[13],
430
+ api_details=row[14],
431
+ training=row[15],
432
+ licensing=row[16],
433
+ safety=row[17],
434
+ availability=row[18],
435
+ technical_specs=row[19],
436
+ release_date=row[20],
437
+ training_data_cutoff=row[21],
438
+ deprecation_date=row[22],
439
+ metadata=row[23],
440
+ last_scraped_at=row[24],
441
+ is_active=row[25],
442
+ is_deprecated=row[26],
443
+ created_at=row[27],
444
+ updated_at=row[28],
445
+ )
446
+
447
+ async def get_models(self) -> AsyncIterator[models.LlmModel]:
448
+ result = await self._conn.stream(sqlalchemy.text(GET_MODELS))
449
+ async for row in result:
450
+ yield models.LlmModel(
451
+ id=row[0],
452
+ provider_id=row[1],
453
+ model_id=row[2],
454
+ slug=row[3],
455
+ name=row[4],
456
+ display_name=row[5],
457
+ description=row[6],
458
+ version=row[7],
459
+ capabilities=row[8],
460
+ classification=row[9],
461
+ architecture=row[10],
462
+ performance=row[11],
463
+ token_info=row[12],
464
+ pricing=row[13],
465
+ api_details=row[14],
466
+ training=row[15],
467
+ licensing=row[16],
468
+ safety=row[17],
469
+ availability=row[18],
470
+ technical_specs=row[19],
471
+ release_date=row[20],
472
+ training_data_cutoff=row[21],
473
+ deprecation_date=row[22],
474
+ metadata=row[23],
475
+ last_scraped_at=row[24],
476
+ is_active=row[25],
477
+ is_deprecated=row[26],
478
+ created_at=row[27],
479
+ updated_at=row[28],
480
+ )
481
+
482
+ async def get_models_by_provider(
483
+ self, *, provider_id: uuid.UUID
484
+ ) -> AsyncIterator[models.LlmModel]:
485
+ result = await self._conn.stream(
486
+ sqlalchemy.text(GET_MODELS_BY_PROVIDER), {"p1": provider_id}
487
+ )
488
+ async for row in result:
489
+ yield models.LlmModel(
490
+ id=row[0],
491
+ provider_id=row[1],
492
+ model_id=row[2],
493
+ slug=row[3],
494
+ name=row[4],
495
+ display_name=row[5],
496
+ description=row[6],
497
+ version=row[7],
498
+ capabilities=row[8],
499
+ classification=row[9],
500
+ architecture=row[10],
501
+ performance=row[11],
502
+ token_info=row[12],
503
+ pricing=row[13],
504
+ api_details=row[14],
505
+ training=row[15],
506
+ licensing=row[16],
507
+ safety=row[17],
508
+ availability=row[18],
509
+ technical_specs=row[19],
510
+ release_date=row[20],
511
+ training_data_cutoff=row[21],
512
+ deprecation_date=row[22],
513
+ metadata=row[23],
514
+ last_scraped_at=row[24],
515
+ is_active=row[25],
516
+ is_deprecated=row[26],
517
+ created_at=row[27],
518
+ updated_at=row[28],
519
+ )
520
+
521
+ async def update_model_deprecation(self, arg: UpdateModelDeprecationParams) -> None:
522
+ await self._conn.execute(
523
+ sqlalchemy.text(UPDATE_MODEL_DEPRECATION),
524
+ {
525
+ "p1": arg.deprecation_date,
526
+ "p2": arg.replacement_model_id,
527
+ "p3": arg.slug,
528
+ },
529
+ )
530
+
531
+ async def upsert_model(self, arg: UpsertModelParams) -> Optional[models.LlmModel]:
532
+ row = (
533
+ await self._conn.execute(
534
+ sqlalchemy.text(UPSERT_MODEL),
535
+ {
536
+ "p1": arg.provider_id,
537
+ "p2": arg.model_id,
538
+ "p3": arg.slug,
539
+ "p4": arg.name,
540
+ "p5": arg.display_name,
541
+ "p6": arg.description,
542
+ "p7": arg.version,
543
+ "p8": arg.classification,
544
+ "p9": arg.architecture,
545
+ "p10": arg.capabilities,
546
+ "p11": arg.performance,
547
+ "p12": arg.token_info,
548
+ "p13": arg.pricing,
549
+ "p14": arg.api_details,
550
+ "p15": arg.training,
551
+ "p16": arg.licensing,
552
+ "p17": arg.safety,
553
+ "p18": arg.availability,
554
+ "p19": arg.technical_specs,
555
+ "p20": arg.release_date,
556
+ "p21": arg.training_data_cutoff,
557
+ "p22": arg.deprecation_date,
558
+ "p23": arg.metadata,
559
+ },
560
+ )
561
+ ).first()
562
+ if row is None:
563
+ return None
564
+ return models.LlmModel(
565
+ id=row[0],
566
+ provider_id=row[1],
567
+ model_id=row[2],
568
+ slug=row[3],
569
+ name=row[4],
570
+ display_name=row[5],
571
+ description=row[6],
572
+ version=row[7],
573
+ capabilities=row[8],
574
+ classification=row[9],
575
+ architecture=row[10],
576
+ performance=row[11],
577
+ token_info=row[12],
578
+ pricing=row[13],
579
+ api_details=row[14],
580
+ training=row[15],
581
+ licensing=row[16],
582
+ safety=row[17],
583
+ availability=row[18],
584
+ technical_specs=row[19],
585
+ release_date=row[20],
586
+ training_data_cutoff=row[21],
587
+ deprecation_date=row[22],
588
+ metadata=row[23],
589
+ last_scraped_at=row[24],
590
+ is_active=row[25],
591
+ is_deprecated=row[26],
592
+ created_at=row[27],
593
+ updated_at=row[28],
594
+ )