weave-typescript 0.5.1 → 0.9.0
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.
- package/dist/weaveapi/llmx/v1/architecture.pb.d.ts +377 -0
- package/dist/weaveapi/llmx/v1/architecture.pb.js +2756 -0
- package/dist/weaveapi/llmx/v1/capabilities.pb.d.ts +491 -0
- package/dist/weaveapi/llmx/v1/capabilities.pb.js +3159 -0
- package/dist/weaveapi/{modex → llmx}/v1/model.pb.d.ts +86 -42
- package/dist/weaveapi/{modex → llmx}/v1/model.pb.js +119 -442
- package/dist/weaveapi/llmx/v1/pricing.pb.d.ts +142 -0
- package/dist/weaveapi/llmx/v1/pricing.pb.js +825 -0
- package/dist/weaveapi/{modex → llmx}/v1/provider.pb.d.ts +1 -3
- package/dist/weaveapi/{modex → llmx}/v1/provider.pb.js +3 -57
- package/dist/weaveapi/{modex → llmx}/v1/service.pb.d.ts +20 -20
- package/dist/weaveapi/{modex → llmx}/v1/service.pb.js +17 -17
- package/dist/weavesql/llmxdb/capabilities_sql.d.ts +151 -0
- package/dist/weavesql/llmxdb/capabilities_sql.js +241 -0
- package/dist/weavesql/llmxdb/changes_sql.d.ts +81 -0
- package/dist/weavesql/llmxdb/changes_sql.js +118 -0
- package/dist/weavesql/llmxdb/models_sql.d.ts +198 -0
- package/dist/weavesql/llmxdb/models_sql.js +244 -0
- package/dist/weavesql/llmxdb/providers_sql.d.ts +122 -0
- package/dist/weavesql/llmxdb/providers_sql.js +179 -0
- package/dist/weavesql/llmxdb/scraper_runs_sql.d.ts +83 -0
- package/dist/weavesql/llmxdb/scraper_runs_sql.js +137 -0
- package/dist/weavesql/llmxdb/search_sql.d.ts +272 -0
- package/dist/weavesql/llmxdb/search_sql.js +348 -0
- package/dist/weavesql/weavedb/dataset_sql.d.ts +17 -0
- package/dist/weavesql/weavedb/dataset_sql.js +21 -0
- package/dist/weavesql/weavedb/relationships_sql.d.ts +16 -0
- package/dist/weavesql/weavedb/relationships_sql.js +32 -0
- package/dist/weavesql/weavedb/storage_sql.d.ts +33 -0
- package/dist/weavesql/weavedb/storage_sql.js +54 -0
- package/dist/weavesql/weavedb/synthesizer_sql.d.ts +28 -0
- package/dist/weavesql/weavedb/synthesizer_sql.js +42 -0
- package/package.json +4 -1
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModelsWithVisionQuery = exports.getModelsWithStructuredResponseQuery = exports.getModelCapabilityTypesQuery = exports.checkModelHasCapabilityQuery = exports.getCapabilityConfigQuery = exports.getModelCapabilitiesQuery = exports.getModelsWithCapabilityQuery = void 0;
|
|
4
|
+
exports.getModelsWithCapability = getModelsWithCapability;
|
|
5
|
+
exports.getModelCapabilities = getModelCapabilities;
|
|
6
|
+
exports.getCapabilityConfig = getCapabilityConfig;
|
|
7
|
+
exports.checkModelHasCapability = checkModelHasCapability;
|
|
8
|
+
exports.getModelCapabilityTypes = getModelCapabilityTypes;
|
|
9
|
+
exports.getModelsWithStructuredResponse = getModelsWithStructuredResponse;
|
|
10
|
+
exports.getModelsWithVision = getModelsWithVision;
|
|
11
|
+
exports.getModelsWithCapabilityQuery = `-- name: GetModelsWithCapability :many
|
|
12
|
+
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
|
|
13
|
+
FROM llm_models
|
|
14
|
+
WHERE is_active = true
|
|
15
|
+
AND capabilities->'configs' ? $1
|
|
16
|
+
AND ($2::uuid IS NULL OR provider_id = $2)
|
|
17
|
+
ORDER BY provider_id, name`;
|
|
18
|
+
async function getModelsWithCapability(client, args) {
|
|
19
|
+
const result = await client.query({
|
|
20
|
+
text: exports.getModelsWithCapabilityQuery,
|
|
21
|
+
values: [args.capabilityType, args.providerId],
|
|
22
|
+
rowMode: "array"
|
|
23
|
+
});
|
|
24
|
+
return result.rows.map(row => {
|
|
25
|
+
return {
|
|
26
|
+
id: row[0],
|
|
27
|
+
providerId: row[1],
|
|
28
|
+
modelId: row[2],
|
|
29
|
+
slug: row[3],
|
|
30
|
+
name: row[4],
|
|
31
|
+
displayName: row[5],
|
|
32
|
+
description: row[6],
|
|
33
|
+
version: row[7],
|
|
34
|
+
capabilities: row[8],
|
|
35
|
+
classification: row[9],
|
|
36
|
+
architecture: row[10],
|
|
37
|
+
performance: row[11],
|
|
38
|
+
tokenInfo: row[12],
|
|
39
|
+
pricing: row[13],
|
|
40
|
+
apiDetails: row[14],
|
|
41
|
+
training: row[15],
|
|
42
|
+
licensing: row[16],
|
|
43
|
+
safety: row[17],
|
|
44
|
+
availability: row[18],
|
|
45
|
+
technicalSpecs: row[19],
|
|
46
|
+
releaseDate: row[20],
|
|
47
|
+
trainingDataCutoff: row[21],
|
|
48
|
+
deprecationDate: row[22],
|
|
49
|
+
metadata: row[23],
|
|
50
|
+
lastScrapedAt: row[24],
|
|
51
|
+
isActive: row[25],
|
|
52
|
+
isDeprecated: row[26],
|
|
53
|
+
createdAt: row[27],
|
|
54
|
+
updatedAt: row[28]
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.getModelCapabilitiesQuery = `-- name: GetModelCapabilities :one
|
|
59
|
+
SELECT capabilities
|
|
60
|
+
FROM llm_models
|
|
61
|
+
WHERE slug = $1
|
|
62
|
+
AND is_active = true`;
|
|
63
|
+
async function getModelCapabilities(client, args) {
|
|
64
|
+
const result = await client.query({
|
|
65
|
+
text: exports.getModelCapabilitiesQuery,
|
|
66
|
+
values: [args.slug],
|
|
67
|
+
rowMode: "array"
|
|
68
|
+
});
|
|
69
|
+
if (result.rows.length !== 1) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const row = result.rows[0];
|
|
73
|
+
return {
|
|
74
|
+
capabilities: row[0]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.getCapabilityConfigQuery = `-- name: GetCapabilityConfig :one
|
|
78
|
+
SELECT capabilities->'configs'->@capability_type as config
|
|
79
|
+
FROM llm_models
|
|
80
|
+
WHERE slug = $1
|
|
81
|
+
AND is_active = true`;
|
|
82
|
+
async function getCapabilityConfig(client, args) {
|
|
83
|
+
const result = await client.query({
|
|
84
|
+
text: exports.getCapabilityConfigQuery,
|
|
85
|
+
values: [args.slug],
|
|
86
|
+
rowMode: "array"
|
|
87
|
+
});
|
|
88
|
+
if (result.rows.length !== 1) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const row = result.rows[0];
|
|
92
|
+
return {
|
|
93
|
+
config: row[0]
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
exports.checkModelHasCapabilityQuery = `-- name: CheckModelHasCapability :one
|
|
97
|
+
SELECT EXISTS (
|
|
98
|
+
SELECT 1
|
|
99
|
+
FROM llm_models
|
|
100
|
+
WHERE id = $1
|
|
101
|
+
AND capabilities->'configs' ? $2
|
|
102
|
+
) as has_capability`;
|
|
103
|
+
async function checkModelHasCapability(client, args) {
|
|
104
|
+
const result = await client.query({
|
|
105
|
+
text: exports.checkModelHasCapabilityQuery,
|
|
106
|
+
values: [args.modelId, args.capabilityType],
|
|
107
|
+
rowMode: "array"
|
|
108
|
+
});
|
|
109
|
+
if (result.rows.length !== 1) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const row = result.rows[0];
|
|
113
|
+
return {
|
|
114
|
+
hasCapability: row[0]
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
exports.getModelCapabilityTypesQuery = `-- name: GetModelCapabilityTypes :many
|
|
118
|
+
SELECT jsonb_object_keys(capabilities->'configs') as capability_type
|
|
119
|
+
FROM llm_models
|
|
120
|
+
WHERE id = $1
|
|
121
|
+
ORDER BY 1`;
|
|
122
|
+
async function getModelCapabilityTypes(client, args) {
|
|
123
|
+
const result = await client.query({
|
|
124
|
+
text: exports.getModelCapabilityTypesQuery,
|
|
125
|
+
values: [args.modelId],
|
|
126
|
+
rowMode: "array"
|
|
127
|
+
});
|
|
128
|
+
return result.rows.map(row => {
|
|
129
|
+
return {
|
|
130
|
+
capabilityType: row[0]
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
exports.getModelsWithStructuredResponseQuery = `-- name: GetModelsWithStructuredResponse :many
|
|
135
|
+
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,
|
|
136
|
+
c.config->>'max_schema_depth' as max_schema_depth,
|
|
137
|
+
c.config->>'requires_json_mode' as requires_json_mode
|
|
138
|
+
FROM llm_models m,
|
|
139
|
+
LATERAL (
|
|
140
|
+
SELECT capabilities->'configs'->'CAPABILITY_TYPE_STRUCTURED_RESPONSE' as config
|
|
141
|
+
) c
|
|
142
|
+
WHERE m.is_active = true
|
|
143
|
+
AND m.capabilities->'configs' ? 'CAPABILITY_TYPE_STRUCTURED_RESPONSE'
|
|
144
|
+
AND ($1::uuid IS NULL OR m.provider_id = $1)
|
|
145
|
+
ORDER BY m.provider_id, m.name`;
|
|
146
|
+
async function getModelsWithStructuredResponse(client, args) {
|
|
147
|
+
const result = await client.query({
|
|
148
|
+
text: exports.getModelsWithStructuredResponseQuery,
|
|
149
|
+
values: [args.providerId],
|
|
150
|
+
rowMode: "array"
|
|
151
|
+
});
|
|
152
|
+
return result.rows.map(row => {
|
|
153
|
+
return {
|
|
154
|
+
id: row[0],
|
|
155
|
+
providerId: row[1],
|
|
156
|
+
modelId: row[2],
|
|
157
|
+
slug: row[3],
|
|
158
|
+
name: row[4],
|
|
159
|
+
displayName: row[5],
|
|
160
|
+
description: row[6],
|
|
161
|
+
version: row[7],
|
|
162
|
+
capabilities: row[8],
|
|
163
|
+
classification: row[9],
|
|
164
|
+
architecture: row[10],
|
|
165
|
+
performance: row[11],
|
|
166
|
+
tokenInfo: row[12],
|
|
167
|
+
pricing: row[13],
|
|
168
|
+
apiDetails: row[14],
|
|
169
|
+
training: row[15],
|
|
170
|
+
licensing: row[16],
|
|
171
|
+
safety: row[17],
|
|
172
|
+
availability: row[18],
|
|
173
|
+
technicalSpecs: row[19],
|
|
174
|
+
releaseDate: row[20],
|
|
175
|
+
trainingDataCutoff: row[21],
|
|
176
|
+
deprecationDate: row[22],
|
|
177
|
+
metadata: row[23],
|
|
178
|
+
lastScrapedAt: row[24],
|
|
179
|
+
isActive: row[25],
|
|
180
|
+
isDeprecated: row[26],
|
|
181
|
+
createdAt: row[27],
|
|
182
|
+
updatedAt: row[28],
|
|
183
|
+
maxSchemaDepth: row[29],
|
|
184
|
+
requiresJsonMode: row[30]
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
exports.getModelsWithVisionQuery = `-- name: GetModelsWithVision :many
|
|
189
|
+
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,
|
|
190
|
+
c.config->>'max_images_per_request' as max_images,
|
|
191
|
+
c.config->>'supported_formats' as formats
|
|
192
|
+
FROM llm_models m,
|
|
193
|
+
LATERAL (
|
|
194
|
+
SELECT capabilities->'configs'->'CAPABILITY_TYPE_VISION' as config
|
|
195
|
+
) c
|
|
196
|
+
WHERE m.is_active = true
|
|
197
|
+
AND m.capabilities->'configs' ? 'CAPABILITY_TYPE_VISION'
|
|
198
|
+
AND ($1::boolean IS NULL OR (c.config->>'supports_ocr')::boolean = $1)
|
|
199
|
+
ORDER BY m.provider_id, m.name`;
|
|
200
|
+
async function getModelsWithVision(client, args) {
|
|
201
|
+
const result = await client.query({
|
|
202
|
+
text: exports.getModelsWithVisionQuery,
|
|
203
|
+
values: [args.supportsOcr],
|
|
204
|
+
rowMode: "array"
|
|
205
|
+
});
|
|
206
|
+
return result.rows.map(row => {
|
|
207
|
+
return {
|
|
208
|
+
id: row[0],
|
|
209
|
+
providerId: row[1],
|
|
210
|
+
modelId: row[2],
|
|
211
|
+
slug: row[3],
|
|
212
|
+
name: row[4],
|
|
213
|
+
displayName: row[5],
|
|
214
|
+
description: row[6],
|
|
215
|
+
version: row[7],
|
|
216
|
+
capabilities: row[8],
|
|
217
|
+
classification: row[9],
|
|
218
|
+
architecture: row[10],
|
|
219
|
+
performance: row[11],
|
|
220
|
+
tokenInfo: row[12],
|
|
221
|
+
pricing: row[13],
|
|
222
|
+
apiDetails: row[14],
|
|
223
|
+
training: row[15],
|
|
224
|
+
licensing: row[16],
|
|
225
|
+
safety: row[17],
|
|
226
|
+
availability: row[18],
|
|
227
|
+
technicalSpecs: row[19],
|
|
228
|
+
releaseDate: row[20],
|
|
229
|
+
trainingDataCutoff: row[21],
|
|
230
|
+
deprecationDate: row[22],
|
|
231
|
+
metadata: row[23],
|
|
232
|
+
lastScrapedAt: row[24],
|
|
233
|
+
isActive: row[25],
|
|
234
|
+
isDeprecated: row[26],
|
|
235
|
+
createdAt: row[27],
|
|
236
|
+
updatedAt: row[28],
|
|
237
|
+
maxImages: row[29],
|
|
238
|
+
formats: row[30]
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const insertModelChangeQuery = "-- name: InsertModelChange :one\nINSERT INTO model_changes (model_id, field_name, old_value, new_value, change_type)\nVALUES ($1, $2, $3, $4, $5)\nRETURNING id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at";
|
|
6
|
+
export interface InsertModelChangeArgs {
|
|
7
|
+
modelId: string;
|
|
8
|
+
fieldName: string;
|
|
9
|
+
oldValue: string | null;
|
|
10
|
+
newValue: string | null;
|
|
11
|
+
changeType: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface InsertModelChangeRow {
|
|
14
|
+
id: string;
|
|
15
|
+
modelId: string;
|
|
16
|
+
fieldName: string;
|
|
17
|
+
oldValue: string | null;
|
|
18
|
+
newValue: string | null;
|
|
19
|
+
changeType: string | null;
|
|
20
|
+
detectedAt: Date | null;
|
|
21
|
+
createdAt: Date | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function insertModelChange(client: Client, args: InsertModelChangeArgs): Promise<InsertModelChangeRow | null>;
|
|
24
|
+
export declare const batchInsertChangesQuery = "-- name: BatchInsertChanges :copyfrom\nINSERT INTO model_changes (\n model_id, field_name, old_value, new_value, change_type\n) VALUES (\n $1, $2, $3, $4, $5\n)";
|
|
25
|
+
export interface BatchInsertChangesArgs {
|
|
26
|
+
modelId: string;
|
|
27
|
+
fieldName: string;
|
|
28
|
+
oldValue: string | null;
|
|
29
|
+
newValue: string | null;
|
|
30
|
+
changeType: string | null;
|
|
31
|
+
}
|
|
32
|
+
export declare const getRecentChangesQuery = "-- name: GetRecentChanges :many\nSELECT id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at\nFROM model_changes\nWHERE detected_at > NOW() - INTERVAL '24 hours'\nORDER BY detected_at DESC\nLIMIT $1";
|
|
33
|
+
export interface GetRecentChangesArgs {
|
|
34
|
+
limitCount: string;
|
|
35
|
+
}
|
|
36
|
+
export interface GetRecentChangesRow {
|
|
37
|
+
id: string;
|
|
38
|
+
modelId: string;
|
|
39
|
+
fieldName: string;
|
|
40
|
+
oldValue: string | null;
|
|
41
|
+
newValue: string | null;
|
|
42
|
+
changeType: string | null;
|
|
43
|
+
detectedAt: Date | null;
|
|
44
|
+
createdAt: Date | null;
|
|
45
|
+
}
|
|
46
|
+
export declare function getRecentChanges(client: Client, args: GetRecentChangesArgs): Promise<GetRecentChangesRow[]>;
|
|
47
|
+
export declare const getChangesByModelQuery = "-- name: GetChangesByModel :many\nSELECT id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at\nFROM model_changes\nWHERE model_id = $1\nORDER BY detected_at DESC\nLIMIT $2";
|
|
48
|
+
export interface GetChangesByModelArgs {
|
|
49
|
+
modelId: string;
|
|
50
|
+
limitCount: string;
|
|
51
|
+
}
|
|
52
|
+
export interface GetChangesByModelRow {
|
|
53
|
+
id: string;
|
|
54
|
+
modelId: string;
|
|
55
|
+
fieldName: string;
|
|
56
|
+
oldValue: string | null;
|
|
57
|
+
newValue: string | null;
|
|
58
|
+
changeType: string | null;
|
|
59
|
+
detectedAt: Date | null;
|
|
60
|
+
createdAt: Date | null;
|
|
61
|
+
}
|
|
62
|
+
export declare function getChangesByModel(client: Client, args: GetChangesByModelArgs): Promise<GetChangesByModelRow[]>;
|
|
63
|
+
export declare const getChangesByTypeQuery = "-- name: GetChangesByType :many\nSELECT mc.id, mc.model_id, mc.field_name, mc.old_value, mc.new_value, mc.change_type, mc.detected_at, mc.created_at,\n lm.slug as model_slug,\n lm.name as model_name\nFROM model_changes mc\n JOIN llm_models lm ON mc.model_id = lm.id\nWHERE mc.change_type = $1\n AND mc.detected_at > $2\nORDER BY mc.detected_at DESC";
|
|
64
|
+
export interface GetChangesByTypeArgs {
|
|
65
|
+
changeType: string | null;
|
|
66
|
+
since: Date | null;
|
|
67
|
+
}
|
|
68
|
+
export interface GetChangesByTypeRow {
|
|
69
|
+
id: string;
|
|
70
|
+
modelId: string;
|
|
71
|
+
fieldName: string;
|
|
72
|
+
oldValue: string | null;
|
|
73
|
+
newValue: string | null;
|
|
74
|
+
changeType: string | null;
|
|
75
|
+
detectedAt: Date | null;
|
|
76
|
+
createdAt: Date | null;
|
|
77
|
+
modelSlug: string;
|
|
78
|
+
modelName: string;
|
|
79
|
+
}
|
|
80
|
+
export declare function getChangesByType(client: Client, args: GetChangesByTypeArgs): Promise<GetChangesByTypeRow[]>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChangesByTypeQuery = exports.getChangesByModelQuery = exports.getRecentChangesQuery = exports.batchInsertChangesQuery = exports.insertModelChangeQuery = void 0;
|
|
4
|
+
exports.insertModelChange = insertModelChange;
|
|
5
|
+
exports.getRecentChanges = getRecentChanges;
|
|
6
|
+
exports.getChangesByModel = getChangesByModel;
|
|
7
|
+
exports.getChangesByType = getChangesByType;
|
|
8
|
+
exports.insertModelChangeQuery = `-- name: InsertModelChange :one
|
|
9
|
+
INSERT INTO model_changes (model_id, field_name, old_value, new_value, change_type)
|
|
10
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
11
|
+
RETURNING id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at`;
|
|
12
|
+
async function insertModelChange(client, args) {
|
|
13
|
+
const result = await client.query({
|
|
14
|
+
text: exports.insertModelChangeQuery,
|
|
15
|
+
values: [args.modelId, args.fieldName, args.oldValue, args.newValue, args.changeType],
|
|
16
|
+
rowMode: "array"
|
|
17
|
+
});
|
|
18
|
+
if (result.rows.length !== 1) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const row = result.rows[0];
|
|
22
|
+
return {
|
|
23
|
+
id: row[0],
|
|
24
|
+
modelId: row[1],
|
|
25
|
+
fieldName: row[2],
|
|
26
|
+
oldValue: row[3],
|
|
27
|
+
newValue: row[4],
|
|
28
|
+
changeType: row[5],
|
|
29
|
+
detectedAt: row[6],
|
|
30
|
+
createdAt: row[7]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.batchInsertChangesQuery = `-- name: BatchInsertChanges :copyfrom
|
|
34
|
+
INSERT INTO model_changes (
|
|
35
|
+
model_id, field_name, old_value, new_value, change_type
|
|
36
|
+
) VALUES (
|
|
37
|
+
$1, $2, $3, $4, $5
|
|
38
|
+
)`;
|
|
39
|
+
exports.getRecentChangesQuery = `-- name: GetRecentChanges :many
|
|
40
|
+
SELECT id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at
|
|
41
|
+
FROM model_changes
|
|
42
|
+
WHERE detected_at > NOW() - INTERVAL '24 hours'
|
|
43
|
+
ORDER BY detected_at DESC
|
|
44
|
+
LIMIT $1`;
|
|
45
|
+
async function getRecentChanges(client, args) {
|
|
46
|
+
const result = await client.query({
|
|
47
|
+
text: exports.getRecentChangesQuery,
|
|
48
|
+
values: [args.limitCount],
|
|
49
|
+
rowMode: "array"
|
|
50
|
+
});
|
|
51
|
+
return result.rows.map(row => {
|
|
52
|
+
return {
|
|
53
|
+
id: row[0],
|
|
54
|
+
modelId: row[1],
|
|
55
|
+
fieldName: row[2],
|
|
56
|
+
oldValue: row[3],
|
|
57
|
+
newValue: row[4],
|
|
58
|
+
changeType: row[5],
|
|
59
|
+
detectedAt: row[6],
|
|
60
|
+
createdAt: row[7]
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.getChangesByModelQuery = `-- name: GetChangesByModel :many
|
|
65
|
+
SELECT id, model_id, field_name, old_value, new_value, change_type, detected_at, created_at
|
|
66
|
+
FROM model_changes
|
|
67
|
+
WHERE model_id = $1
|
|
68
|
+
ORDER BY detected_at DESC
|
|
69
|
+
LIMIT $2`;
|
|
70
|
+
async function getChangesByModel(client, args) {
|
|
71
|
+
const result = await client.query({
|
|
72
|
+
text: exports.getChangesByModelQuery,
|
|
73
|
+
values: [args.modelId, args.limitCount],
|
|
74
|
+
rowMode: "array"
|
|
75
|
+
});
|
|
76
|
+
return result.rows.map(row => {
|
|
77
|
+
return {
|
|
78
|
+
id: row[0],
|
|
79
|
+
modelId: row[1],
|
|
80
|
+
fieldName: row[2],
|
|
81
|
+
oldValue: row[3],
|
|
82
|
+
newValue: row[4],
|
|
83
|
+
changeType: row[5],
|
|
84
|
+
detectedAt: row[6],
|
|
85
|
+
createdAt: row[7]
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.getChangesByTypeQuery = `-- name: GetChangesByType :many
|
|
90
|
+
SELECT mc.id, mc.model_id, mc.field_name, mc.old_value, mc.new_value, mc.change_type, mc.detected_at, mc.created_at,
|
|
91
|
+
lm.slug as model_slug,
|
|
92
|
+
lm.name as model_name
|
|
93
|
+
FROM model_changes mc
|
|
94
|
+
JOIN llm_models lm ON mc.model_id = lm.id
|
|
95
|
+
WHERE mc.change_type = $1
|
|
96
|
+
AND mc.detected_at > $2
|
|
97
|
+
ORDER BY mc.detected_at DESC`;
|
|
98
|
+
async function getChangesByType(client, args) {
|
|
99
|
+
const result = await client.query({
|
|
100
|
+
text: exports.getChangesByTypeQuery,
|
|
101
|
+
values: [args.changeType, args.since],
|
|
102
|
+
rowMode: "array"
|
|
103
|
+
});
|
|
104
|
+
return result.rows.map(row => {
|
|
105
|
+
return {
|
|
106
|
+
id: row[0],
|
|
107
|
+
modelId: row[1],
|
|
108
|
+
fieldName: row[2],
|
|
109
|
+
oldValue: row[3],
|
|
110
|
+
newValue: row[4],
|
|
111
|
+
changeType: row[5],
|
|
112
|
+
detectedAt: row[6],
|
|
113
|
+
createdAt: row[7],
|
|
114
|
+
modelSlug: row[8],
|
|
115
|
+
modelName: row[9]
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const getModelQuery = "-- name: GetModel :one\nSELECT 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\nFROM llm_models\nWHERE slug = $1\n AND is_active = true";
|
|
6
|
+
export interface GetModelArgs {
|
|
7
|
+
slug: string;
|
|
8
|
+
}
|
|
9
|
+
export interface GetModelRow {
|
|
10
|
+
id: string;
|
|
11
|
+
providerId: string;
|
|
12
|
+
modelId: string;
|
|
13
|
+
slug: string;
|
|
14
|
+
name: string;
|
|
15
|
+
displayName: string | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
version: string | null;
|
|
18
|
+
capabilities: any;
|
|
19
|
+
classification: any;
|
|
20
|
+
architecture: any;
|
|
21
|
+
performance: any;
|
|
22
|
+
tokenInfo: any;
|
|
23
|
+
pricing: any;
|
|
24
|
+
apiDetails: any;
|
|
25
|
+
training: any;
|
|
26
|
+
licensing: any;
|
|
27
|
+
safety: any;
|
|
28
|
+
availability: any;
|
|
29
|
+
technicalSpecs: any;
|
|
30
|
+
releaseDate: Date | null;
|
|
31
|
+
trainingDataCutoff: Date | null;
|
|
32
|
+
deprecationDate: Date | null;
|
|
33
|
+
metadata: any;
|
|
34
|
+
lastScrapedAt: Date | null;
|
|
35
|
+
isActive: boolean | null;
|
|
36
|
+
isDeprecated: boolean | null;
|
|
37
|
+
createdAt: Date | null;
|
|
38
|
+
updatedAt: Date | null;
|
|
39
|
+
}
|
|
40
|
+
export declare function getModel(client: Client, args: GetModelArgs): Promise<GetModelRow | null>;
|
|
41
|
+
export declare const getModelsQuery = "-- name: GetModels :many\nSELECT 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\nFROM llm_models\nWHERE is_active = true\nORDER BY provider_id, name";
|
|
42
|
+
export interface GetModelsRow {
|
|
43
|
+
id: string;
|
|
44
|
+
providerId: string;
|
|
45
|
+
modelId: string;
|
|
46
|
+
slug: string;
|
|
47
|
+
name: string;
|
|
48
|
+
displayName: string | null;
|
|
49
|
+
description: string | null;
|
|
50
|
+
version: string | null;
|
|
51
|
+
capabilities: any;
|
|
52
|
+
classification: any;
|
|
53
|
+
architecture: any;
|
|
54
|
+
performance: any;
|
|
55
|
+
tokenInfo: any;
|
|
56
|
+
pricing: any;
|
|
57
|
+
apiDetails: any;
|
|
58
|
+
training: any;
|
|
59
|
+
licensing: any;
|
|
60
|
+
safety: any;
|
|
61
|
+
availability: any;
|
|
62
|
+
technicalSpecs: any;
|
|
63
|
+
releaseDate: Date | null;
|
|
64
|
+
trainingDataCutoff: Date | null;
|
|
65
|
+
deprecationDate: Date | null;
|
|
66
|
+
metadata: any;
|
|
67
|
+
lastScrapedAt: Date | null;
|
|
68
|
+
isActive: boolean | null;
|
|
69
|
+
isDeprecated: boolean | null;
|
|
70
|
+
createdAt: Date | null;
|
|
71
|
+
updatedAt: Date | null;
|
|
72
|
+
}
|
|
73
|
+
export declare function getModels(client: Client): Promise<GetModelsRow[]>;
|
|
74
|
+
export declare const getModelsByProviderQuery = "-- name: GetModelsByProvider :many\nSELECT 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\nFROM llm_models\nWHERE provider_id = $1\n AND is_active = true\nORDER BY name";
|
|
75
|
+
export interface GetModelsByProviderArgs {
|
|
76
|
+
providerId: string;
|
|
77
|
+
}
|
|
78
|
+
export interface GetModelsByProviderRow {
|
|
79
|
+
id: string;
|
|
80
|
+
providerId: string;
|
|
81
|
+
modelId: string;
|
|
82
|
+
slug: string;
|
|
83
|
+
name: string;
|
|
84
|
+
displayName: string | null;
|
|
85
|
+
description: string | null;
|
|
86
|
+
version: string | null;
|
|
87
|
+
capabilities: any;
|
|
88
|
+
classification: any;
|
|
89
|
+
architecture: any;
|
|
90
|
+
performance: any;
|
|
91
|
+
tokenInfo: any;
|
|
92
|
+
pricing: any;
|
|
93
|
+
apiDetails: any;
|
|
94
|
+
training: any;
|
|
95
|
+
licensing: any;
|
|
96
|
+
safety: any;
|
|
97
|
+
availability: any;
|
|
98
|
+
technicalSpecs: any;
|
|
99
|
+
releaseDate: Date | null;
|
|
100
|
+
trainingDataCutoff: Date | null;
|
|
101
|
+
deprecationDate: Date | null;
|
|
102
|
+
metadata: any;
|
|
103
|
+
lastScrapedAt: Date | null;
|
|
104
|
+
isActive: boolean | null;
|
|
105
|
+
isDeprecated: boolean | null;
|
|
106
|
+
createdAt: Date | null;
|
|
107
|
+
updatedAt: Date | null;
|
|
108
|
+
}
|
|
109
|
+
export declare function getModelsByProvider(client: Client, args: GetModelsByProviderArgs): Promise<GetModelsByProviderRow[]>;
|
|
110
|
+
export declare const upsertModelQuery = "-- name: UpsertModel :one\nINSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,\n classification, architecture, capabilities, performance, token_info,\n pricing, api_details, training, licensing, safety, availability,\n technical_specs, release_date, training_data_cutoff, deprecation_date,\n metadata, last_scraped_at)\nVALUES ($1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10, $11, $12,\n $13, $14, $15, $16, $17, $18,\n $19, $20, $21, $22,\n $23, NOW())\nON CONFLICT (slug) DO UPDATE SET name = EXCLUDED.name,\n display_name = EXCLUDED.display_name,\n description = EXCLUDED.description,\n version = EXCLUDED.version,\n classification = EXCLUDED.classification,\n architecture = EXCLUDED.architecture,\n capabilities = EXCLUDED.capabilities,\n performance = EXCLUDED.performance,\n token_info = EXCLUDED.token_info,\n pricing = EXCLUDED.pricing,\n api_details = EXCLUDED.api_details,\n training = EXCLUDED.training,\n licensing = EXCLUDED.licensing,\n safety = EXCLUDED.safety,\n availability = EXCLUDED.availability,\n technical_specs = EXCLUDED.technical_specs,\n release_date = EXCLUDED.release_date,\n training_data_cutoff = EXCLUDED.training_data_cutoff,\n deprecation_date = EXCLUDED.deprecation_date,\n metadata = EXCLUDED.metadata,\n last_scraped_at = NOW(),\n updated_at = NOW()\nRETURNING 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";
|
|
111
|
+
export interface UpsertModelArgs {
|
|
112
|
+
providerId: string;
|
|
113
|
+
modelId: string;
|
|
114
|
+
slug: string;
|
|
115
|
+
name: string;
|
|
116
|
+
displayName: string | null;
|
|
117
|
+
description: string | null;
|
|
118
|
+
version: string | null;
|
|
119
|
+
classification: any;
|
|
120
|
+
architecture: any;
|
|
121
|
+
capabilities: any;
|
|
122
|
+
performance: any;
|
|
123
|
+
tokenInfo: any;
|
|
124
|
+
pricing: any;
|
|
125
|
+
apiDetails: any;
|
|
126
|
+
training: any;
|
|
127
|
+
licensing: any;
|
|
128
|
+
safety: any;
|
|
129
|
+
availability: any;
|
|
130
|
+
technicalSpecs: any;
|
|
131
|
+
releaseDate: Date | null;
|
|
132
|
+
trainingDataCutoff: Date | null;
|
|
133
|
+
deprecationDate: Date | null;
|
|
134
|
+
metadata: any;
|
|
135
|
+
}
|
|
136
|
+
export interface UpsertModelRow {
|
|
137
|
+
id: string;
|
|
138
|
+
providerId: string;
|
|
139
|
+
modelId: string;
|
|
140
|
+
slug: string;
|
|
141
|
+
name: string;
|
|
142
|
+
displayName: string | null;
|
|
143
|
+
description: string | null;
|
|
144
|
+
version: string | null;
|
|
145
|
+
capabilities: any;
|
|
146
|
+
classification: any;
|
|
147
|
+
architecture: any;
|
|
148
|
+
performance: any;
|
|
149
|
+
tokenInfo: any;
|
|
150
|
+
pricing: any;
|
|
151
|
+
apiDetails: any;
|
|
152
|
+
training: any;
|
|
153
|
+
licensing: any;
|
|
154
|
+
safety: any;
|
|
155
|
+
availability: any;
|
|
156
|
+
technicalSpecs: any;
|
|
157
|
+
releaseDate: Date | null;
|
|
158
|
+
trainingDataCutoff: Date | null;
|
|
159
|
+
deprecationDate: Date | null;
|
|
160
|
+
metadata: any;
|
|
161
|
+
lastScrapedAt: Date | null;
|
|
162
|
+
isActive: boolean | null;
|
|
163
|
+
isDeprecated: boolean | null;
|
|
164
|
+
createdAt: Date | null;
|
|
165
|
+
updatedAt: Date | null;
|
|
166
|
+
}
|
|
167
|
+
export declare function upsertModel(client: Client, args: UpsertModelArgs): Promise<UpsertModelRow | null>;
|
|
168
|
+
export declare const batchUpsertModelsQuery = "-- name: BatchUpsertModels :copyfrom\nINSERT INTO llm_models (provider_id, model_id, slug, name, display_name, description, version,\n classification, architecture, capabilities, performance, token_info,\n pricing, api_details, training, licensing, safety, availability,\n technical_specs, metadata)\nVALUES ($1, $2, $3, $4, $5, $6, $7,\n $8, $9, $10, $11, $12,\n $13, $14, $15, $16, $17, $18,\n $19, $20)";
|
|
169
|
+
export interface BatchUpsertModelsArgs {
|
|
170
|
+
providerId: string;
|
|
171
|
+
modelId: string;
|
|
172
|
+
slug: string;
|
|
173
|
+
name: string;
|
|
174
|
+
displayName: string | null;
|
|
175
|
+
description: string | null;
|
|
176
|
+
version: string | null;
|
|
177
|
+
classification: any;
|
|
178
|
+
architecture: any;
|
|
179
|
+
capabilities: any;
|
|
180
|
+
performance: any;
|
|
181
|
+
tokenInfo: any;
|
|
182
|
+
pricing: any;
|
|
183
|
+
apiDetails: any;
|
|
184
|
+
training: any;
|
|
185
|
+
licensing: any;
|
|
186
|
+
safety: any;
|
|
187
|
+
availability: any;
|
|
188
|
+
technicalSpecs: any;
|
|
189
|
+
metadata: any;
|
|
190
|
+
}
|
|
191
|
+
export declare const updateModelDeprecationQuery = "-- name: UpdateModelDeprecation :exec\nUPDATE llm_models\nSET is_deprecated = true,\n deprecation_date = $1,\n metadata = jsonb_set(metadata, '{replacement_model_id}', to_jsonb($2::text))\nWHERE slug = $3";
|
|
192
|
+
export interface UpdateModelDeprecationArgs {
|
|
193
|
+
deprecationDate: Date | null;
|
|
194
|
+
replacementModelId: string;
|
|
195
|
+
slug: string;
|
|
196
|
+
}
|
|
197
|
+
export declare function updateModelDeprecation(client: Client, args: UpdateModelDeprecationArgs): Promise<void>;
|
|
198
|
+
export {};
|