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.
- weave/weaveapi/auth/v1/service_pb2.py +184 -88
- weave/weaveapi/auth/v1/service_pb2.pyi +1288 -1134
- weave/weaveapi/auth/v1/service_pb2_grpc.pyi +248 -335
- weave/weaveapi/auth/v1/session_pb2.py +12 -4
- weave/weaveapi/auth/v1/session_pb2.pyi +109 -89
- weave/weaveapi/auth/v1/session_pb2_grpc.pyi +11 -10
- weave/weaveapi/auth/v1/usage_pb2.py +16 -12
- weave/weaveapi/auth/v1/usage_pb2.pyi +251 -197
- weave/weaveapi/auth/v1/usage_pb2_grpc.pyi +11 -10
- weave/weaveapi/auth/v1/user_pb2.py +58 -16
- weave/weaveapi/auth/v1/user_pb2.pyi +588 -505
- weave/weaveapi/auth/v1/user_pb2_grpc.pyi +11 -10
- weave/weaveapi/generate/v1/configuration_pb2.py +29 -17
- weave/weaveapi/generate/v1/configuration_pb2.pyi +277 -241
- weave/weaveapi/generate/v1/configuration_pb2_grpc.pyi +11 -10
- weave/weaveapi/generate/v1/generate_pb2.py +30 -4
- weave/weaveapi/generate/v1/generate_pb2.pyi +138 -40
- weave/weaveapi/generate/v1/generate_pb2_grpc.pyi +11 -10
- weave/weaveapi/generate/v1/service_pb2.py +50 -20
- weave/weaveapi/generate/v1/service_pb2.pyi +264 -135
- weave/weaveapi/generate/v1/service_pb2_grpc.py +47 -0
- weave/weaveapi/generate/v1/service_pb2_grpc.pyi +89 -78
- weave/weaveapi/llmx/v1/architecture_pb2.py +3 -3
- weave/weaveapi/llmx/v1/architecture_pb2.pyi +664 -555
- weave/weaveapi/llmx/v1/architecture_pb2_grpc.pyi +11 -10
- weave/weaveapi/llmx/v1/capabilities_pb2.py +86 -54
- weave/weaveapi/llmx/v1/capabilities_pb2.pyi +967 -852
- weave/weaveapi/llmx/v1/capabilities_pb2_grpc.pyi +11 -10
- weave/weaveapi/llmx/v1/model_pb2.py +54 -18
- weave/weaveapi/llmx/v1/model_pb2.pyi +533 -455
- weave/weaveapi/llmx/v1/model_pb2_grpc.pyi +11 -10
- weave/weaveapi/llmx/v1/pricing_pb2.py +22 -18
- weave/weaveapi/llmx/v1/pricing_pb2.pyi +194 -172
- weave/weaveapi/llmx/v1/pricing_pb2_grpc.pyi +11 -10
- weave/weaveapi/llmx/v1/provider_pb2.py +3 -3
- weave/weaveapi/llmx/v1/provider_pb2.pyi +84 -59
- weave/weaveapi/llmx/v1/provider_pb2_grpc.pyi +11 -10
- weave/weaveapi/llmx/v1/service_pb2.py +224 -86
- weave/weaveapi/llmx/v1/service_pb2.pyi +1651 -1403
- weave/weaveapi/llmx/v1/service_pb2_grpc.pyi +160 -203
- weave/weaveapi/mcpregistry/v1/server_pb2.py +14 -8
- weave/weaveapi/mcpregistry/v1/server_pb2.pyi +143 -121
- weave/weaveapi/mcpregistry/v1/server_pb2_grpc.pyi +11 -10
- weave/weaveapi/mcpregistry/v1/service_pb2.py +47 -27
- weave/weaveapi/mcpregistry/v1/service_pb2.pyi +132 -122
- weave/weaveapi/mcpregistry/v1/service_pb2_grpc.pyi +87 -112
- weave/weaveapi/payment/v1/invoice_pb2.py +36 -10
- weave/weaveapi/payment/v1/invoice_pb2.pyi +352 -291
- weave/weaveapi/payment/v1/invoice_pb2_grpc.pyi +11 -10
- weave/weaveapi/payment/v1/service_pb2.py +256 -90
- weave/weaveapi/payment/v1/service_pb2.pyi +1381 -1242
- weave/weaveapi/payment/v1/service_pb2_grpc.pyi +229 -319
- weave/weaveapi/payment/v1/subscription_pb2.py +97 -21
- weave/weaveapi/payment/v1/subscription_pb2.pyi +727 -611
- weave/weaveapi/payment/v1/subscription_pb2_grpc.pyi +11 -10
- weave/weaveapi/storage/v1/auth_pb2.py +3 -3
- weave/weaveapi/storage/v1/auth_pb2.pyi +42 -29
- weave/weaveapi/storage/v1/auth_pb2_grpc.pyi +11 -10
- weave/weaveapi/storage/v1/nosql_database_pb2.py +45 -21
- weave/weaveapi/storage/v1/nosql_database_pb2.pyi +438 -372
- weave/weaveapi/storage/v1/nosql_database_pb2_grpc.pyi +11 -10
- weave/weaveapi/storage/v1/object_store_pb2.py +25 -11
- weave/weaveapi/storage/v1/object_store_pb2.pyi +203 -187
- weave/weaveapi/storage/v1/object_store_pb2_grpc.pyi +11 -10
- weave/weaveapi/storage/v1/service_pb2.py +94 -34
- weave/weaveapi/storage/v1/service_pb2.pyi +414 -357
- weave/weaveapi/storage/v1/service_pb2_grpc.pyi +88 -107
- weave/weaveapi/storage/v1/sql_database_pb2.py +37 -21
- weave/weaveapi/storage/v1/sql_database_pb2.pyi +481 -400
- weave/weaveapi/storage/v1/sql_database_pb2_grpc.pyi +11 -10
- weave/weaveapi/storage/v1/storage_pb2.py +18 -4
- weave/weaveapi/storage/v1/storage_pb2.pyi +79 -70
- weave/weaveapi/storage/v1/storage_pb2_grpc.pyi +11 -10
- weave/weaveapi/synthesize/v1/dataset_pb2.py +10 -8
- weave/weaveapi/synthesize/v1/dataset_pb2.pyi +158 -128
- weave/weaveapi/synthesize/v1/dataset_pb2_grpc.pyi +11 -10
- weave/weaveapi/synthesize/v1/inline_data_pb2.py +4 -4
- weave/weaveapi/synthesize/v1/inline_data_pb2.pyi +31 -27
- weave/weaveapi/synthesize/v1/inline_data_pb2_grpc.pyi +11 -10
- weave/weaveapi/synthesize/v1/relationship_pb2.py +17 -9
- weave/weaveapi/synthesize/v1/relationship_pb2.pyi +67 -64
- weave/weaveapi/synthesize/v1/relationship_pb2_grpc.pyi +11 -10
- weave/weaveapi/synthesize/v1/service_pb2.py +40 -22
- weave/weaveapi/synthesize/v1/service_pb2.pyi +202 -168
- weave/weaveapi/synthesize/v1/service_pb2_grpc.pyi +67 -79
- weave/weaveapi/synthesize/v1/training_pb2.py +17 -11
- weave/weaveapi/synthesize/v1/training_pb2.pyi +119 -106
- weave/weaveapi/synthesize/v1/training_pb2_grpc.pyi +11 -10
- weave/weavesql/llmxdb/capabilities.py +487 -0
- weave/weavesql/llmxdb/changes.py +297 -0
- weave/weavesql/llmxdb/models.py +594 -0
- weave/weavesql/llmxdb/providers.py +348 -0
- weave/weavesql/llmxdb/scraper_runs.py +287 -0
- weave/weavesql/llmxdb/search.py +721 -0
- weave/weavesql/weavedb/dataset.py +75 -0
- weave/weavesql/weavedb/models.py +135 -0
- weave/weavesql/weavedb/relationships.py +72 -0
- weave/weavesql/weavedb/storage.py +113 -0
- weave/weavesql/weavedb/synthesizer.py +107 -0
- {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/METADATA +3 -3
- weave_python-0.30.4.dist-info/RECORD +131 -0
- {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/WHEEL +1 -1
- weave_python-0.28.2.dist-info/RECORD +0 -120
- {weave_python-0.28.2.dist-info → weave_python-0.30.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
# Code generated by sqlc. DO NOT EDIT.
|
|
2
|
+
# versions:
|
|
3
|
+
# sqlc v1.28.0
|
|
4
|
+
# source: capabilities.sql
|
|
5
|
+
import dataclasses
|
|
6
|
+
import datetime
|
|
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
|
+
CHECK_MODEL_HAS_CAPABILITY = """-- name: check_model_has_capability \\:one
|
|
17
|
+
SELECT EXISTS (
|
|
18
|
+
SELECT 1
|
|
19
|
+
FROM llm_models
|
|
20
|
+
WHERE id = :p1
|
|
21
|
+
AND capabilities->'configs' ? :p2
|
|
22
|
+
) as has_capability
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
GET_CAPABILITY_CONFIG = """-- name: get_capability_config \\:one
|
|
27
|
+
SELECT capabilities->'configs'->@capability_type as config
|
|
28
|
+
FROM llm_models
|
|
29
|
+
WHERE slug = :p1
|
|
30
|
+
AND is_active = true
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
GET_MODEL_CAPABILITIES = """-- name: get_model_capabilities \\:one
|
|
35
|
+
SELECT capabilities
|
|
36
|
+
FROM llm_models
|
|
37
|
+
WHERE slug = :p1
|
|
38
|
+
AND is_active = true
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
GET_MODEL_CAPABILITY_TYPES = """-- name: get_model_capability_types \\:many
|
|
43
|
+
SELECT jsonb_object_keys(capabilities->'configs') as capability_type
|
|
44
|
+
FROM llm_models
|
|
45
|
+
WHERE id = :p1
|
|
46
|
+
ORDER BY 1
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
GET_MODELS_WITH_CAPABILITY = """-- name: get_models_with_capability \\:many
|
|
51
|
+
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
|
|
52
|
+
FROM llm_models
|
|
53
|
+
WHERE is_active = true
|
|
54
|
+
AND capabilities->'configs' ? :p1
|
|
55
|
+
AND (:p2\\:\\:uuid IS NULL OR provider_id = :p2)
|
|
56
|
+
ORDER BY provider_id, name
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
GET_MODELS_WITH_STRUCTURED_RESPONSE = """-- name: get_models_with_structured_response \\:many
|
|
61
|
+
SELECT m.id, m.provider_id, m.model_id, m.slug, m.name, m.display_name, m.description, m.version, m.capabilities, m.classification, m.architecture, m.performance, m.token_info, m.pricing, m.api_details, m.training, m.licensing, m.safety, m.availability, m.technical_specs, m.release_date, m.training_data_cutoff, m.deprecation_date, m.metadata, m.last_scraped_at, m.is_active, m.is_deprecated, m.created_at, m.updated_at,
|
|
62
|
+
c.config->>'max_schema_depth' as max_schema_depth,
|
|
63
|
+
c.config->>'requires_json_mode' as requires_json_mode
|
|
64
|
+
FROM llm_models m,
|
|
65
|
+
LATERAL (
|
|
66
|
+
SELECT capabilities->'configs'->'CAPABILITY_TYPE_STRUCTURED_RESPONSE' as config
|
|
67
|
+
) c
|
|
68
|
+
WHERE m.is_active = true
|
|
69
|
+
AND m.capabilities->'configs' ? 'CAPABILITY_TYPE_STRUCTURED_RESPONSE'
|
|
70
|
+
AND (:p1\\:\\:uuid IS NULL OR m.provider_id = :p1)
|
|
71
|
+
ORDER BY m.provider_id, m.name
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
@dataclasses.dataclass()
|
|
76
|
+
class GetModelsWithStructuredResponseRow:
|
|
77
|
+
id: uuid.UUID
|
|
78
|
+
provider_id: uuid.UUID
|
|
79
|
+
model_id: str
|
|
80
|
+
slug: str
|
|
81
|
+
name: str
|
|
82
|
+
display_name: Optional[str]
|
|
83
|
+
description: Optional[str]
|
|
84
|
+
version: Optional[str]
|
|
85
|
+
capabilities: Any
|
|
86
|
+
classification: Any
|
|
87
|
+
architecture: Any
|
|
88
|
+
performance: Any
|
|
89
|
+
token_info: Any
|
|
90
|
+
pricing: Any
|
|
91
|
+
api_details: Any
|
|
92
|
+
training: Any
|
|
93
|
+
licensing: Any
|
|
94
|
+
safety: Any
|
|
95
|
+
availability: Any
|
|
96
|
+
technical_specs: Any
|
|
97
|
+
release_date: Optional[datetime.datetime]
|
|
98
|
+
training_data_cutoff: Optional[datetime.datetime]
|
|
99
|
+
deprecation_date: Optional[datetime.datetime]
|
|
100
|
+
metadata: Any
|
|
101
|
+
last_scraped_at: Optional[datetime.datetime]
|
|
102
|
+
is_active: Optional[bool]
|
|
103
|
+
is_deprecated: Optional[bool]
|
|
104
|
+
created_at: Optional[datetime.datetime]
|
|
105
|
+
updated_at: Optional[datetime.datetime]
|
|
106
|
+
max_schema_depth: Optional[Any]
|
|
107
|
+
requires_json_mode: Optional[Any]
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
GET_MODELS_WITH_VISION = """-- name: get_models_with_vision \\:many
|
|
111
|
+
SELECT m.id, m.provider_id, m.model_id, m.slug, m.name, m.display_name, m.description, m.version, m.capabilities, m.classification, m.architecture, m.performance, m.token_info, m.pricing, m.api_details, m.training, m.licensing, m.safety, m.availability, m.technical_specs, m.release_date, m.training_data_cutoff, m.deprecation_date, m.metadata, m.last_scraped_at, m.is_active, m.is_deprecated, m.created_at, m.updated_at,
|
|
112
|
+
c.config->>'max_images_per_request' as max_images,
|
|
113
|
+
c.config->>'supported_formats' as formats
|
|
114
|
+
FROM llm_models m,
|
|
115
|
+
LATERAL (
|
|
116
|
+
SELECT capabilities->'configs'->'CAPABILITY_TYPE_VISION' as config
|
|
117
|
+
) c
|
|
118
|
+
WHERE m.is_active = true
|
|
119
|
+
AND m.capabilities->'configs' ? 'CAPABILITY_TYPE_VISION'
|
|
120
|
+
AND (:p1\\:\\:boolean IS NULL OR (c.config->>'supports_ocr')\\:\\:boolean = :p1)
|
|
121
|
+
ORDER BY m.provider_id, m.name
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@dataclasses.dataclass()
|
|
126
|
+
class GetModelsWithVisionRow:
|
|
127
|
+
id: uuid.UUID
|
|
128
|
+
provider_id: uuid.UUID
|
|
129
|
+
model_id: str
|
|
130
|
+
slug: str
|
|
131
|
+
name: str
|
|
132
|
+
display_name: Optional[str]
|
|
133
|
+
description: Optional[str]
|
|
134
|
+
version: Optional[str]
|
|
135
|
+
capabilities: Any
|
|
136
|
+
classification: Any
|
|
137
|
+
architecture: Any
|
|
138
|
+
performance: Any
|
|
139
|
+
token_info: Any
|
|
140
|
+
pricing: Any
|
|
141
|
+
api_details: Any
|
|
142
|
+
training: Any
|
|
143
|
+
licensing: Any
|
|
144
|
+
safety: Any
|
|
145
|
+
availability: Any
|
|
146
|
+
technical_specs: Any
|
|
147
|
+
release_date: Optional[datetime.datetime]
|
|
148
|
+
training_data_cutoff: Optional[datetime.datetime]
|
|
149
|
+
deprecation_date: Optional[datetime.datetime]
|
|
150
|
+
metadata: Any
|
|
151
|
+
last_scraped_at: Optional[datetime.datetime]
|
|
152
|
+
is_active: Optional[bool]
|
|
153
|
+
is_deprecated: Optional[bool]
|
|
154
|
+
created_at: Optional[datetime.datetime]
|
|
155
|
+
updated_at: Optional[datetime.datetime]
|
|
156
|
+
max_images: Optional[Any]
|
|
157
|
+
formats: Optional[Any]
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class Querier:
|
|
161
|
+
def __init__(self, conn: sqlalchemy.engine.Connection):
|
|
162
|
+
self._conn = conn
|
|
163
|
+
|
|
164
|
+
def check_model_has_capability(
|
|
165
|
+
self, *, model_id: uuid.UUID, capability_type: Any
|
|
166
|
+
) -> Optional[bool]:
|
|
167
|
+
row = self._conn.execute(
|
|
168
|
+
sqlalchemy.text(CHECK_MODEL_HAS_CAPABILITY),
|
|
169
|
+
{"p1": model_id, "p2": capability_type},
|
|
170
|
+
).first()
|
|
171
|
+
if row is None:
|
|
172
|
+
return None
|
|
173
|
+
return row[0]
|
|
174
|
+
|
|
175
|
+
def get_capability_config(self, *, slug: str) -> Optional[Optional[Any]]:
|
|
176
|
+
row = self._conn.execute(
|
|
177
|
+
sqlalchemy.text(GET_CAPABILITY_CONFIG), {"p1": slug}
|
|
178
|
+
).first()
|
|
179
|
+
if row is None:
|
|
180
|
+
return None
|
|
181
|
+
return row[0]
|
|
182
|
+
|
|
183
|
+
def get_model_capabilities(self, *, slug: str) -> Optional[Any]:
|
|
184
|
+
row = self._conn.execute(
|
|
185
|
+
sqlalchemy.text(GET_MODEL_CAPABILITIES), {"p1": slug}
|
|
186
|
+
).first()
|
|
187
|
+
if row is None:
|
|
188
|
+
return None
|
|
189
|
+
return row[0]
|
|
190
|
+
|
|
191
|
+
def get_model_capability_types(self, *, model_id: uuid.UUID) -> Iterator[str]:
|
|
192
|
+
result = self._conn.execute(
|
|
193
|
+
sqlalchemy.text(GET_MODEL_CAPABILITY_TYPES), {"p1": model_id}
|
|
194
|
+
)
|
|
195
|
+
for row in result:
|
|
196
|
+
yield row[0]
|
|
197
|
+
|
|
198
|
+
def get_models_with_capability(
|
|
199
|
+
self, *, capability_type: Any, provider_id: uuid.UUID
|
|
200
|
+
) -> Iterator[models.LlmModel]:
|
|
201
|
+
result = self._conn.execute(
|
|
202
|
+
sqlalchemy.text(GET_MODELS_WITH_CAPABILITY),
|
|
203
|
+
{"p1": capability_type, "p2": provider_id},
|
|
204
|
+
)
|
|
205
|
+
for row in result:
|
|
206
|
+
yield models.LlmModel(
|
|
207
|
+
id=row[0],
|
|
208
|
+
provider_id=row[1],
|
|
209
|
+
model_id=row[2],
|
|
210
|
+
slug=row[3],
|
|
211
|
+
name=row[4],
|
|
212
|
+
display_name=row[5],
|
|
213
|
+
description=row[6],
|
|
214
|
+
version=row[7],
|
|
215
|
+
capabilities=row[8],
|
|
216
|
+
classification=row[9],
|
|
217
|
+
architecture=row[10],
|
|
218
|
+
performance=row[11],
|
|
219
|
+
token_info=row[12],
|
|
220
|
+
pricing=row[13],
|
|
221
|
+
api_details=row[14],
|
|
222
|
+
training=row[15],
|
|
223
|
+
licensing=row[16],
|
|
224
|
+
safety=row[17],
|
|
225
|
+
availability=row[18],
|
|
226
|
+
technical_specs=row[19],
|
|
227
|
+
release_date=row[20],
|
|
228
|
+
training_data_cutoff=row[21],
|
|
229
|
+
deprecation_date=row[22],
|
|
230
|
+
metadata=row[23],
|
|
231
|
+
last_scraped_at=row[24],
|
|
232
|
+
is_active=row[25],
|
|
233
|
+
is_deprecated=row[26],
|
|
234
|
+
created_at=row[27],
|
|
235
|
+
updated_at=row[28],
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
def get_models_with_structured_response(
|
|
239
|
+
self, *, provider_id: uuid.UUID
|
|
240
|
+
) -> Iterator[GetModelsWithStructuredResponseRow]:
|
|
241
|
+
result = self._conn.execute(
|
|
242
|
+
sqlalchemy.text(GET_MODELS_WITH_STRUCTURED_RESPONSE), {"p1": provider_id}
|
|
243
|
+
)
|
|
244
|
+
for row in result:
|
|
245
|
+
yield GetModelsWithStructuredResponseRow(
|
|
246
|
+
id=row[0],
|
|
247
|
+
provider_id=row[1],
|
|
248
|
+
model_id=row[2],
|
|
249
|
+
slug=row[3],
|
|
250
|
+
name=row[4],
|
|
251
|
+
display_name=row[5],
|
|
252
|
+
description=row[6],
|
|
253
|
+
version=row[7],
|
|
254
|
+
capabilities=row[8],
|
|
255
|
+
classification=row[9],
|
|
256
|
+
architecture=row[10],
|
|
257
|
+
performance=row[11],
|
|
258
|
+
token_info=row[12],
|
|
259
|
+
pricing=row[13],
|
|
260
|
+
api_details=row[14],
|
|
261
|
+
training=row[15],
|
|
262
|
+
licensing=row[16],
|
|
263
|
+
safety=row[17],
|
|
264
|
+
availability=row[18],
|
|
265
|
+
technical_specs=row[19],
|
|
266
|
+
release_date=row[20],
|
|
267
|
+
training_data_cutoff=row[21],
|
|
268
|
+
deprecation_date=row[22],
|
|
269
|
+
metadata=row[23],
|
|
270
|
+
last_scraped_at=row[24],
|
|
271
|
+
is_active=row[25],
|
|
272
|
+
is_deprecated=row[26],
|
|
273
|
+
created_at=row[27],
|
|
274
|
+
updated_at=row[28],
|
|
275
|
+
max_schema_depth=row[29],
|
|
276
|
+
requires_json_mode=row[30],
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
def get_models_with_vision(
|
|
280
|
+
self, *, supports_ocr: bool
|
|
281
|
+
) -> Iterator[GetModelsWithVisionRow]:
|
|
282
|
+
result = self._conn.execute(
|
|
283
|
+
sqlalchemy.text(GET_MODELS_WITH_VISION), {"p1": supports_ocr}
|
|
284
|
+
)
|
|
285
|
+
for row in result:
|
|
286
|
+
yield GetModelsWithVisionRow(
|
|
287
|
+
id=row[0],
|
|
288
|
+
provider_id=row[1],
|
|
289
|
+
model_id=row[2],
|
|
290
|
+
slug=row[3],
|
|
291
|
+
name=row[4],
|
|
292
|
+
display_name=row[5],
|
|
293
|
+
description=row[6],
|
|
294
|
+
version=row[7],
|
|
295
|
+
capabilities=row[8],
|
|
296
|
+
classification=row[9],
|
|
297
|
+
architecture=row[10],
|
|
298
|
+
performance=row[11],
|
|
299
|
+
token_info=row[12],
|
|
300
|
+
pricing=row[13],
|
|
301
|
+
api_details=row[14],
|
|
302
|
+
training=row[15],
|
|
303
|
+
licensing=row[16],
|
|
304
|
+
safety=row[17],
|
|
305
|
+
availability=row[18],
|
|
306
|
+
technical_specs=row[19],
|
|
307
|
+
release_date=row[20],
|
|
308
|
+
training_data_cutoff=row[21],
|
|
309
|
+
deprecation_date=row[22],
|
|
310
|
+
metadata=row[23],
|
|
311
|
+
last_scraped_at=row[24],
|
|
312
|
+
is_active=row[25],
|
|
313
|
+
is_deprecated=row[26],
|
|
314
|
+
created_at=row[27],
|
|
315
|
+
updated_at=row[28],
|
|
316
|
+
max_images=row[29],
|
|
317
|
+
formats=row[30],
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class AsyncQuerier:
|
|
322
|
+
def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
|
|
323
|
+
self._conn = conn
|
|
324
|
+
|
|
325
|
+
async def check_model_has_capability(
|
|
326
|
+
self, *, model_id: uuid.UUID, capability_type: Any
|
|
327
|
+
) -> Optional[bool]:
|
|
328
|
+
row = (
|
|
329
|
+
await self._conn.execute(
|
|
330
|
+
sqlalchemy.text(CHECK_MODEL_HAS_CAPABILITY),
|
|
331
|
+
{"p1": model_id, "p2": capability_type},
|
|
332
|
+
)
|
|
333
|
+
).first()
|
|
334
|
+
if row is None:
|
|
335
|
+
return None
|
|
336
|
+
return row[0]
|
|
337
|
+
|
|
338
|
+
async def get_capability_config(self, *, slug: str) -> Optional[Optional[Any]]:
|
|
339
|
+
row = (
|
|
340
|
+
await self._conn.execute(
|
|
341
|
+
sqlalchemy.text(GET_CAPABILITY_CONFIG), {"p1": slug}
|
|
342
|
+
)
|
|
343
|
+
).first()
|
|
344
|
+
if row is None:
|
|
345
|
+
return None
|
|
346
|
+
return row[0]
|
|
347
|
+
|
|
348
|
+
async def get_model_capabilities(self, *, slug: str) -> Optional[Any]:
|
|
349
|
+
row = (
|
|
350
|
+
await self._conn.execute(
|
|
351
|
+
sqlalchemy.text(GET_MODEL_CAPABILITIES), {"p1": slug}
|
|
352
|
+
)
|
|
353
|
+
).first()
|
|
354
|
+
if row is None:
|
|
355
|
+
return None
|
|
356
|
+
return row[0]
|
|
357
|
+
|
|
358
|
+
async def get_model_capability_types(
|
|
359
|
+
self, *, model_id: uuid.UUID
|
|
360
|
+
) -> AsyncIterator[str]:
|
|
361
|
+
result = await self._conn.stream(
|
|
362
|
+
sqlalchemy.text(GET_MODEL_CAPABILITY_TYPES), {"p1": model_id}
|
|
363
|
+
)
|
|
364
|
+
async for row in result:
|
|
365
|
+
yield row[0]
|
|
366
|
+
|
|
367
|
+
async def get_models_with_capability(
|
|
368
|
+
self, *, capability_type: Any, provider_id: uuid.UUID
|
|
369
|
+
) -> AsyncIterator[models.LlmModel]:
|
|
370
|
+
result = await self._conn.stream(
|
|
371
|
+
sqlalchemy.text(GET_MODELS_WITH_CAPABILITY),
|
|
372
|
+
{"p1": capability_type, "p2": provider_id},
|
|
373
|
+
)
|
|
374
|
+
async for row in result:
|
|
375
|
+
yield models.LlmModel(
|
|
376
|
+
id=row[0],
|
|
377
|
+
provider_id=row[1],
|
|
378
|
+
model_id=row[2],
|
|
379
|
+
slug=row[3],
|
|
380
|
+
name=row[4],
|
|
381
|
+
display_name=row[5],
|
|
382
|
+
description=row[6],
|
|
383
|
+
version=row[7],
|
|
384
|
+
capabilities=row[8],
|
|
385
|
+
classification=row[9],
|
|
386
|
+
architecture=row[10],
|
|
387
|
+
performance=row[11],
|
|
388
|
+
token_info=row[12],
|
|
389
|
+
pricing=row[13],
|
|
390
|
+
api_details=row[14],
|
|
391
|
+
training=row[15],
|
|
392
|
+
licensing=row[16],
|
|
393
|
+
safety=row[17],
|
|
394
|
+
availability=row[18],
|
|
395
|
+
technical_specs=row[19],
|
|
396
|
+
release_date=row[20],
|
|
397
|
+
training_data_cutoff=row[21],
|
|
398
|
+
deprecation_date=row[22],
|
|
399
|
+
metadata=row[23],
|
|
400
|
+
last_scraped_at=row[24],
|
|
401
|
+
is_active=row[25],
|
|
402
|
+
is_deprecated=row[26],
|
|
403
|
+
created_at=row[27],
|
|
404
|
+
updated_at=row[28],
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
async def get_models_with_structured_response(
|
|
408
|
+
self, *, provider_id: uuid.UUID
|
|
409
|
+
) -> AsyncIterator[GetModelsWithStructuredResponseRow]:
|
|
410
|
+
result = await self._conn.stream(
|
|
411
|
+
sqlalchemy.text(GET_MODELS_WITH_STRUCTURED_RESPONSE), {"p1": provider_id}
|
|
412
|
+
)
|
|
413
|
+
async for row in result:
|
|
414
|
+
yield GetModelsWithStructuredResponseRow(
|
|
415
|
+
id=row[0],
|
|
416
|
+
provider_id=row[1],
|
|
417
|
+
model_id=row[2],
|
|
418
|
+
slug=row[3],
|
|
419
|
+
name=row[4],
|
|
420
|
+
display_name=row[5],
|
|
421
|
+
description=row[6],
|
|
422
|
+
version=row[7],
|
|
423
|
+
capabilities=row[8],
|
|
424
|
+
classification=row[9],
|
|
425
|
+
architecture=row[10],
|
|
426
|
+
performance=row[11],
|
|
427
|
+
token_info=row[12],
|
|
428
|
+
pricing=row[13],
|
|
429
|
+
api_details=row[14],
|
|
430
|
+
training=row[15],
|
|
431
|
+
licensing=row[16],
|
|
432
|
+
safety=row[17],
|
|
433
|
+
availability=row[18],
|
|
434
|
+
technical_specs=row[19],
|
|
435
|
+
release_date=row[20],
|
|
436
|
+
training_data_cutoff=row[21],
|
|
437
|
+
deprecation_date=row[22],
|
|
438
|
+
metadata=row[23],
|
|
439
|
+
last_scraped_at=row[24],
|
|
440
|
+
is_active=row[25],
|
|
441
|
+
is_deprecated=row[26],
|
|
442
|
+
created_at=row[27],
|
|
443
|
+
updated_at=row[28],
|
|
444
|
+
max_schema_depth=row[29],
|
|
445
|
+
requires_json_mode=row[30],
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
async def get_models_with_vision(
|
|
449
|
+
self, *, supports_ocr: bool
|
|
450
|
+
) -> AsyncIterator[GetModelsWithVisionRow]:
|
|
451
|
+
result = await self._conn.stream(
|
|
452
|
+
sqlalchemy.text(GET_MODELS_WITH_VISION), {"p1": supports_ocr}
|
|
453
|
+
)
|
|
454
|
+
async for row in result:
|
|
455
|
+
yield GetModelsWithVisionRow(
|
|
456
|
+
id=row[0],
|
|
457
|
+
provider_id=row[1],
|
|
458
|
+
model_id=row[2],
|
|
459
|
+
slug=row[3],
|
|
460
|
+
name=row[4],
|
|
461
|
+
display_name=row[5],
|
|
462
|
+
description=row[6],
|
|
463
|
+
version=row[7],
|
|
464
|
+
capabilities=row[8],
|
|
465
|
+
classification=row[9],
|
|
466
|
+
architecture=row[10],
|
|
467
|
+
performance=row[11],
|
|
468
|
+
token_info=row[12],
|
|
469
|
+
pricing=row[13],
|
|
470
|
+
api_details=row[14],
|
|
471
|
+
training=row[15],
|
|
472
|
+
licensing=row[16],
|
|
473
|
+
safety=row[17],
|
|
474
|
+
availability=row[18],
|
|
475
|
+
technical_specs=row[19],
|
|
476
|
+
release_date=row[20],
|
|
477
|
+
training_data_cutoff=row[21],
|
|
478
|
+
deprecation_date=row[22],
|
|
479
|
+
metadata=row[23],
|
|
480
|
+
last_scraped_at=row[24],
|
|
481
|
+
is_active=row[25],
|
|
482
|
+
is_deprecated=row[26],
|
|
483
|
+
created_at=row[27],
|
|
484
|
+
updated_at=row[28],
|
|
485
|
+
max_images=row[29],
|
|
486
|
+
formats=row[30],
|
|
487
|
+
)
|