weave-typescript 0.51.3 → 0.52.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/google/protobuf/duration.pb.d.ts +99 -0
- package/dist/google/protobuf/duration.pb.js +93 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/dist/weave/authz/v1/index.d.ts +1 -0
- package/dist/weave/authz/v1/index.js +38 -0
- package/dist/weave/authz/v1/options.pb.d.ts +52 -0
- package/dist/weave/authz/v1/options.pb.js +403 -0
- package/dist/weave/filter/v1/index.d.ts +1 -0
- package/dist/weave/filter/v1/index.js +38 -0
- package/dist/{weaveapi/atc/v1/message.pb.d.ts → weave/filter/v1/options.pb.d.ts} +33 -21
- package/dist/weave/filter/v1/options.pb.js +417 -0
- package/dist/weave/index.d.ts +2 -0
- package/dist/weave/index.js +39 -0
- package/dist/weaveapi/agent/v1/agent.pb.d.ts +137 -188
- package/dist/weaveapi/agent/v1/agent.pb.js +891 -2151
- package/dist/weaveapi/agent/v1/index.d.ts +1 -1
- package/dist/weaveapi/agent/v1/index.js +2 -2
- package/dist/weaveapi/agent/v1/run.pb.d.ts +289 -0
- package/dist/weaveapi/agent/v1/run.pb.js +2763 -0
- package/dist/weaveapi/auth/v1/auth.pb.d.ts +67 -14
- package/dist/weaveapi/auth/v1/auth.pb.js +829 -89
- package/dist/weaveapi/auth/v1/index.d.ts +4 -1
- package/dist/weaveapi/auth/v1/index.js +5 -2
- package/dist/weaveapi/auth/v1/{service.pb.d.ts → organization_admin.pb.d.ts} +39 -530
- package/dist/weaveapi/auth/v1/{service.pb.js → organization_admin.pb.js} +2978 -5812
- package/dist/weaveapi/auth/v1/personal_access_token.pb.d.ts +114 -0
- package/dist/weaveapi/auth/v1/personal_access_token.pb.js +750 -0
- package/dist/weaveapi/auth/v1/profile.pb.d.ts +161 -0
- package/dist/weaveapi/auth/v1/profile.pb.js +1007 -0
- package/dist/weaveapi/auth/v1/session.pb.d.ts +460 -0
- package/dist/weaveapi/auth/v1/session.pb.js +3544 -0
- package/dist/weaveapi/chat/v1/chat.pb.d.ts +377 -149
- package/dist/weaveapi/chat/v1/chat.pb.js +3492 -1614
- package/dist/weaveapi/chat/v1/index.d.ts +0 -1
- package/dist/weaveapi/chat/v1/index.js +1 -2
- package/dist/weaveapi/consolidation/v1/consolidation.pb.d.ts +95 -0
- package/dist/weaveapi/consolidation/v1/consolidation.pb.js +770 -1
- package/dist/weaveapi/consolidation/v1/index.d.ts +0 -1
- package/dist/weaveapi/consolidation/v1/index.js +1 -2
- package/dist/weaveapi/content/v1/content.pb.d.ts +63 -0
- package/dist/weaveapi/content/v1/content.pb.js +470 -0
- package/dist/weaveapi/content/v1/index.d.ts +1 -0
- package/dist/weaveapi/content/v1/index.js +38 -0
- package/dist/weaveapi/gateway/v1/gateway.pb.d.ts +247 -523
- package/dist/weaveapi/gateway/v1/gateway.pb.js +1648 -5783
- package/dist/weaveapi/gateway/v1/index.d.ts +0 -1
- package/dist/weaveapi/gateway/v1/index.js +1 -2
- package/dist/weaveapi/index.d.ts +5 -5
- package/dist/weaveapi/index.js +6 -6
- package/dist/weaveapi/inference/v1/generate.pb.d.ts +120 -0
- package/dist/weaveapi/inference/v1/generate.pb.js +1159 -0
- package/dist/weaveapi/inference/v1/index.d.ts +4 -0
- package/dist/weaveapi/{provider → inference}/v1/index.js +4 -2
- package/dist/weaveapi/{model → inference}/v1/model.pb.d.ts +52 -15
- package/dist/weaveapi/{model → inference}/v1/model.pb.js +529 -116
- package/dist/weaveapi/{model/v1/service.pb.d.ts → inference/v1/model_route.pb.d.ts} +182 -110
- package/dist/weaveapi/{model/v1/service.pb.js → inference/v1/model_route.pb.js} +2197 -1061
- package/dist/weaveapi/inference/v1/provider.pb.d.ts +264 -0
- package/dist/weaveapi/inference/v1/provider.pb.js +2590 -0
- package/dist/weaveapi/ingestion/v1/index.d.ts +0 -2
- package/dist/weaveapi/ingestion/v1/index.js +1 -3
- package/dist/weaveapi/ingestion/v1/ingestion.pb.d.ts +543 -0
- package/dist/weaveapi/ingestion/v1/ingestion.pb.js +5550 -16
- package/dist/weaveapi/initialization/v1/index.d.ts +1 -0
- package/dist/weaveapi/initialization/v1/index.js +38 -0
- package/dist/weaveapi/initialization/v1/initialization.pb.d.ts +99 -0
- package/dist/weaveapi/initialization/v1/initialization.pb.js +510 -0
- package/dist/weaveapi/organization/v1/index.d.ts +0 -1
- package/dist/weaveapi/organization/v1/index.js +1 -2
- package/dist/weaveapi/organization/v1/organization.pb.d.ts +241 -0
- package/dist/weaveapi/organization/v1/organization.pb.js +1838 -1
- package/dist/weaveapi/reporting/index.d.ts +1 -0
- package/dist/weaveapi/reporting/index.js +38 -0
- package/dist/weaveapi/{task → reporting}/v1/index.d.ts +1 -1
- package/dist/weaveapi/{model → reporting}/v1/index.js +2 -2
- package/dist/weaveapi/reporting/v1/service.pb.d.ts +38 -0
- package/dist/weaveapi/reporting/v1/service.pb.js +167 -0
- package/dist/weaveapi/reporting/v1/usage.pb.d.ts +150 -0
- package/dist/weaveapi/reporting/v1/usage.pb.js +1837 -0
- package/dist/weaveapi/retrieval/v1/index.d.ts +0 -1
- package/dist/weaveapi/retrieval/v1/index.js +1 -2
- package/dist/weaveapi/retrieval/v1/retrieval.pb.d.ts +96 -2
- package/dist/weaveapi/retrieval/v1/retrieval.pb.js +690 -10
- package/dist/weaveapi/tool/index.d.ts +1 -0
- package/dist/weaveapi/tool/index.js +38 -0
- package/dist/weaveapi/tool/v1/index.d.ts +1 -0
- package/dist/weaveapi/tool/v1/index.js +38 -0
- package/dist/weaveapi/tool/v1/tool.pb.d.ts +370 -0
- package/dist/weaveapi/tool/v1/tool.pb.js +2717 -0
- package/dist/weaveapi/workflow/v1/index.d.ts +1 -1
- package/dist/weaveapi/workflow/v1/index.js +2 -2
- package/dist/weaveapi/workflow/v1/run.pb.d.ts +244 -0
- package/dist/weaveapi/workflow/v1/run.pb.js +2084 -0
- package/dist/weaveapi/workflow/v1/workflow.pb.d.ts +122 -275
- package/dist/weaveapi/workflow/v1/workflow.pb.js +790 -3261
- package/dist/weavesql/weavedb/agent_sql.d.ts +173 -477
- package/dist/weavesql/weavedb/agent_sql.js +281 -758
- package/dist/weavesql/weavedb/authorization_outbox_sql.d.ts +261 -0
- package/dist/weavesql/weavedb/authorization_outbox_sql.js +445 -0
- package/dist/weavesql/weavedb/chat_sql.d.ts +103 -345
- package/dist/weavesql/weavedb/chat_sql.js +312 -597
- package/dist/weavesql/weavedb/document_consolidation_sql.d.ts +217 -0
- package/dist/weavesql/weavedb/document_consolidation_sql.js +486 -0
- package/dist/weavesql/weavedb/document_ingestion_sql.d.ts +1433 -0
- package/dist/weavesql/weavedb/document_ingestion_sql.js +3488 -0
- package/dist/weavesql/weavedb/document_retrieval_sql.d.ts +314 -0
- package/dist/weavesql/weavedb/document_retrieval_sql.js +965 -0
- package/dist/weavesql/weavedb/document_table_sql.d.ts +6 -6
- package/dist/weavesql/weavedb/document_table_sql.js +12 -12
- package/dist/weavesql/weavedb/identity_sql.d.ts +1014 -0
- package/dist/weavesql/weavedb/identity_sql.js +1811 -0
- package/dist/weavesql/weavedb/inference_model_route_sql.d.ts +161 -0
- package/dist/weavesql/weavedb/inference_model_route_sql.js +408 -0
- package/dist/weavesql/weavedb/inference_provider_sql.d.ts +125 -0
- package/dist/weavesql/weavedb/inference_provider_sql.js +228 -0
- package/dist/weavesql/weavedb/initialization_sql.d.ts +15 -0
- package/dist/weavesql/weavedb/initialization_sql.js +33 -0
- package/dist/weavesql/weavedb/model_catalog_sql.d.ts +6 -6
- package/dist/weavesql/weavedb/model_catalog_sql.js +6 -6
- package/dist/weavesql/weavedb/organization_sql.d.ts +22 -102
- package/dist/weavesql/weavedb/organization_sql.js +54 -262
- package/dist/weavesql/weavedb/tool_sql.d.ts +209 -0
- package/dist/weavesql/weavedb/tool_sql.js +407 -0
- package/dist/weavesql/weavedb/usage_sql.d.ts +356 -0
- package/dist/weavesql/weavedb/usage_sql.js +568 -0
- package/dist/weavesql/weavedb/workflow_sql.d.ts +159 -546
- package/dist/weavesql/weavedb/workflow_sql.js +281 -909
- package/package.json +1 -1
- package/dist/weaveapi/agent/v1/service.pb.d.ts +0 -397
- package/dist/weaveapi/agent/v1/service.pb.js +0 -3152
- package/dist/weaveapi/atc/v1/event.pb.d.ts +0 -134
- package/dist/weaveapi/atc/v1/event.pb.js +0 -1124
- package/dist/weaveapi/atc/v1/index.d.ts +0 -5
- package/dist/weaveapi/atc/v1/index.js +0 -42
- package/dist/weaveapi/atc/v1/message.pb.js +0 -287
- package/dist/weaveapi/atc/v1/process.pb.d.ts +0 -91
- package/dist/weaveapi/atc/v1/process.pb.js +0 -658
- package/dist/weaveapi/atc/v1/run.pb.d.ts +0 -71
- package/dist/weaveapi/atc/v1/run.pb.js +0 -525
- package/dist/weaveapi/atc/v1/service.pb.d.ts +0 -472
- package/dist/weaveapi/atc/v1/service.pb.js +0 -3093
- package/dist/weaveapi/chat/v1/service.pb.d.ts +0 -345
- package/dist/weaveapi/chat/v1/service.pb.js +0 -2545
- package/dist/weaveapi/consolidation/v1/service.pb.d.ts +0 -93
- package/dist/weaveapi/consolidation/v1/service.pb.js +0 -427
- package/dist/weaveapi/gateway/v1/service.pb.d.ts +0 -235
- package/dist/weaveapi/gateway/v1/service.pb.js +0 -651
- package/dist/weaveapi/ingestion/v1/service.pb.d.ts +0 -420
- package/dist/weaveapi/ingestion/v1/service.pb.js +0 -2311
- package/dist/weaveapi/ingestion/v1/table.pb.d.ts +0 -121
- package/dist/weaveapi/ingestion/v1/table.pb.js +0 -1478
- package/dist/weaveapi/model/v1/index.d.ts +0 -2
- package/dist/weaveapi/organization/v1/service.pb.d.ts +0 -261
- package/dist/weaveapi/organization/v1/service.pb.js +0 -1561
- package/dist/weaveapi/project/v1/index.d.ts +0 -2
- package/dist/weaveapi/project/v1/index.js +0 -39
- package/dist/weaveapi/project/v1/project.pb.d.ts +0 -105
- package/dist/weaveapi/project/v1/project.pb.js +0 -1004
- package/dist/weaveapi/project/v1/service.pb.d.ts +0 -247
- package/dist/weaveapi/project/v1/service.pb.js +0 -1994
- package/dist/weaveapi/provider/v1/index.d.ts +0 -2
- package/dist/weaveapi/provider/v1/provider.pb.d.ts +0 -137
- package/dist/weaveapi/provider/v1/provider.pb.js +0 -1000
- package/dist/weaveapi/provider/v1/service.pb.d.ts +0 -223
- package/dist/weaveapi/provider/v1/service.pb.js +0 -1888
- package/dist/weaveapi/retrieval/v1/service.pb.d.ts +0 -93
- package/dist/weaveapi/retrieval/v1/service.pb.js +0 -385
- package/dist/weaveapi/task/v1/index.js +0 -39
- package/dist/weaveapi/task/v1/service.pb.d.ts +0 -172
- package/dist/weaveapi/task/v1/service.pb.js +0 -1436
- package/dist/weaveapi/task/v1/task.pb.d.ts +0 -85
- package/dist/weaveapi/task/v1/task.pb.js +0 -802
- package/dist/weaveapi/workflow/v1/service.pb.d.ts +0 -392
- package/dist/weaveapi/workflow/v1/service.pb.js +0 -3146
- /package/dist/{weaveapi/atc → weave/authz}/index.d.ts +0 -0
- /package/dist/{weaveapi/atc → weave/authz}/index.js +0 -0
- /package/dist/{weaveapi/model → weave/filter}/index.d.ts +0 -0
- /package/dist/{weaveapi/model → weave/filter}/index.js +0 -0
- /package/dist/weaveapi/{project → content}/index.d.ts +0 -0
- /package/dist/weaveapi/{project → content}/index.js +0 -0
- /package/dist/weaveapi/{provider → inference}/index.d.ts +0 -0
- /package/dist/weaveapi/{provider → inference}/index.js +0 -0
- /package/dist/weaveapi/{task → initialization}/index.d.ts +0 -0
- /package/dist/weaveapi/{task → initialization}/index.js +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { QueryArrayConfig, QueryArrayResult } from "pg";
|
|
2
|
+
interface Client {
|
|
3
|
+
query: (config: QueryArrayConfig) => Promise<QueryArrayResult>;
|
|
4
|
+
}
|
|
5
|
+
export declare const upsertInferenceModelQuery = "-- name: UpsertInferenceModel :one\nWITH inserted AS (\n INSERT INTO weave.inference_model (\n organization_id,\n model_id\n ) VALUES (\n $1,\n $2\n )\n ON CONFLICT (organization_id, model_id) DO NOTHING\n RETURNING\n id,\n organization_id,\n model_id,\n created_at,\n updated_at,\n true::boolean AS created\n)\nSELECT\n id,\n organization_id,\n model_id,\n created_at,\n updated_at,\n created\nFROM inserted\nUNION ALL\nSELECT\n im.id,\n im.organization_id,\n im.model_id,\n im.created_at,\n im.updated_at,\n false::boolean AS created\nFROM weave.inference_model im\nWHERE im.organization_id = $1\n AND im.model_id = $2\n AND NOT EXISTS (SELECT 1 FROM inserted)\nLIMIT 1";
|
|
6
|
+
export interface UpsertInferenceModelArgs {
|
|
7
|
+
organizationId: string;
|
|
8
|
+
modelId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface UpsertInferenceModelRow {
|
|
11
|
+
id: string;
|
|
12
|
+
organizationId: string;
|
|
13
|
+
modelId: string;
|
|
14
|
+
createdAt: Date;
|
|
15
|
+
updatedAt: Date;
|
|
16
|
+
created: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function upsertInferenceModel(client: Client, args: UpsertInferenceModelArgs): Promise<UpsertInferenceModelRow | null>;
|
|
19
|
+
export declare const getInferenceModelByModelIDQuery = "-- name: GetInferenceModelByModelID :one\nSELECT id, organization_id, model_id, created_at, updated_at\nFROM weave.inference_model\nWHERE organization_id = $1\n AND model_id = $2";
|
|
20
|
+
export interface GetInferenceModelByModelIDArgs {
|
|
21
|
+
organizationId: string;
|
|
22
|
+
modelId: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GetInferenceModelByModelIDRow {
|
|
25
|
+
id: string;
|
|
26
|
+
organizationId: string;
|
|
27
|
+
modelId: string;
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
}
|
|
31
|
+
export declare function getInferenceModelByModelID(client: Client, args: GetInferenceModelByModelIDArgs): Promise<GetInferenceModelByModelIDRow | null>;
|
|
32
|
+
export declare const createInferenceModelRouteQuery = "-- name: CreateInferenceModelRoute :one\nWITH created AS (\n INSERT INTO weave.inference_model_route (\n organization_id,\n inference_model_id,\n inference_provider_configuration_id,\n provider_model_id,\n priority\n ) VALUES (\n $1,\n $2,\n $3,\n $4,\n COALESCE($5::integer, 100)\n )\n RETURNING id, organization_id, inference_model_id, inference_provider_configuration_id, provider_model_id, priority, created_at, updated_at\n)\nSELECT\n r.id,\n r.organization_id,\n r.inference_model_id,\n im.model_id,\n r.inference_provider_configuration_id,\n r.provider_model_id,\n r.priority,\n r.created_at,\n r.updated_at\nFROM created r\n JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id";
|
|
33
|
+
export interface CreateInferenceModelRouteArgs {
|
|
34
|
+
organizationId: string;
|
|
35
|
+
inferenceModelId: string;
|
|
36
|
+
inferenceProviderConfigurationId: string;
|
|
37
|
+
providerModelId: string;
|
|
38
|
+
priority: number | null;
|
|
39
|
+
}
|
|
40
|
+
export interface CreateInferenceModelRouteRow {
|
|
41
|
+
id: string;
|
|
42
|
+
organizationId: string;
|
|
43
|
+
inferenceModelId: string;
|
|
44
|
+
modelId: string;
|
|
45
|
+
inferenceProviderConfigurationId: string;
|
|
46
|
+
providerModelId: string;
|
|
47
|
+
priority: number;
|
|
48
|
+
createdAt: Date;
|
|
49
|
+
updatedAt: Date;
|
|
50
|
+
}
|
|
51
|
+
export declare function createInferenceModelRoute(client: Client, args: CreateInferenceModelRouteArgs): Promise<CreateInferenceModelRouteRow | null>;
|
|
52
|
+
export declare const getInferenceModelRouteQuery = "-- name: GetInferenceModelRoute :one\nSELECT\n r.id,\n r.organization_id,\n r.inference_model_id,\n im.model_id,\n r.inference_provider_configuration_id,\n r.provider_model_id,\n r.priority,\n r.created_at,\n r.updated_at\nFROM weave.inference_model_route r\n JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id\nWHERE r.organization_id = $1\n AND r.id = $2";
|
|
53
|
+
export interface GetInferenceModelRouteArgs {
|
|
54
|
+
organizationId: string;
|
|
55
|
+
inferenceModelRouteId: string;
|
|
56
|
+
}
|
|
57
|
+
export interface GetInferenceModelRouteRow {
|
|
58
|
+
id: string;
|
|
59
|
+
organizationId: string;
|
|
60
|
+
inferenceModelId: string;
|
|
61
|
+
modelId: string;
|
|
62
|
+
inferenceProviderConfigurationId: string;
|
|
63
|
+
providerModelId: string;
|
|
64
|
+
priority: number;
|
|
65
|
+
createdAt: Date;
|
|
66
|
+
updatedAt: Date;
|
|
67
|
+
}
|
|
68
|
+
export declare function getInferenceModelRoute(client: Client, args: GetInferenceModelRouteArgs): Promise<GetInferenceModelRouteRow | null>;
|
|
69
|
+
export declare const updateInferenceModelRouteQuery = "-- name: UpdateInferenceModelRoute :one\nWITH updated AS (\n UPDATE weave.inference_model_route\n SET inference_model_id = $1,\n inference_provider_configuration_id = $2,\n provider_model_id = $3,\n priority = $4\n WHERE weave.inference_model_route.organization_id = $5\n AND weave.inference_model_route.id = $6\n RETURNING id, organization_id, inference_model_id, inference_provider_configuration_id, provider_model_id, priority, created_at, updated_at\n)\nSELECT\n r.id,\n r.organization_id,\n r.inference_model_id,\n im.model_id,\n r.inference_provider_configuration_id,\n r.provider_model_id,\n r.priority,\n r.created_at,\n r.updated_at\nFROM updated r\n JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id";
|
|
70
|
+
export interface UpdateInferenceModelRouteArgs {
|
|
71
|
+
inferenceModelId: string;
|
|
72
|
+
inferenceProviderConfigurationId: string;
|
|
73
|
+
providerModelId: string;
|
|
74
|
+
priority: number;
|
|
75
|
+
organizationId: string;
|
|
76
|
+
inferenceModelRouteId: string;
|
|
77
|
+
}
|
|
78
|
+
export interface UpdateInferenceModelRouteRow {
|
|
79
|
+
id: string;
|
|
80
|
+
organizationId: string;
|
|
81
|
+
inferenceModelId: string;
|
|
82
|
+
modelId: string;
|
|
83
|
+
inferenceProviderConfigurationId: string;
|
|
84
|
+
providerModelId: string;
|
|
85
|
+
priority: number;
|
|
86
|
+
createdAt: Date;
|
|
87
|
+
updatedAt: Date;
|
|
88
|
+
}
|
|
89
|
+
export declare function updateInferenceModelRoute(client: Client, args: UpdateInferenceModelRouteArgs): Promise<UpdateInferenceModelRouteRow | null>;
|
|
90
|
+
export declare const deleteInferenceModelRouteQuery = "-- name: DeleteInferenceModelRoute :exec\nDELETE FROM weave.inference_model_route\nWHERE organization_id = $1\n AND id = $2";
|
|
91
|
+
export interface DeleteInferenceModelRouteArgs {
|
|
92
|
+
organizationId: string;
|
|
93
|
+
inferenceModelRouteId: string;
|
|
94
|
+
}
|
|
95
|
+
export declare function deleteInferenceModelRoute(client: Client, args: DeleteInferenceModelRouteArgs): Promise<void>;
|
|
96
|
+
export declare const listInferenceModelRoutesQuery = "-- name: ListInferenceModelRoutes :many\nSELECT\n r.id,\n r.organization_id,\n r.inference_model_id,\n im.model_id,\n r.inference_provider_configuration_id,\n r.provider_model_id,\n r.priority,\n r.created_at,\n r.updated_at\nFROM weave.inference_model_route r\n JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id\nWHERE r.organization_id = $1\n AND ($2::text IS NULL OR im.model_id = $2::text)\nORDER BY im.model_id ASC, r.priority ASC, r.id ASC\nLIMIT COALESCE($4::integer, 100)\nOFFSET COALESCE($3::integer, 0)";
|
|
97
|
+
export interface ListInferenceModelRoutesArgs {
|
|
98
|
+
organizationId: string;
|
|
99
|
+
modelId: string | null;
|
|
100
|
+
pageOffset: number | null;
|
|
101
|
+
pageSize: number | null;
|
|
102
|
+
}
|
|
103
|
+
export interface ListInferenceModelRoutesRow {
|
|
104
|
+
id: string;
|
|
105
|
+
organizationId: string;
|
|
106
|
+
inferenceModelId: string;
|
|
107
|
+
modelId: string;
|
|
108
|
+
inferenceProviderConfigurationId: string;
|
|
109
|
+
providerModelId: string;
|
|
110
|
+
priority: number;
|
|
111
|
+
createdAt: Date;
|
|
112
|
+
updatedAt: Date;
|
|
113
|
+
}
|
|
114
|
+
export declare function listInferenceModelRoutes(client: Client, args: ListInferenceModelRoutesArgs): Promise<ListInferenceModelRoutesRow[]>;
|
|
115
|
+
export declare const getOrganizationChatSettingsQuery = "-- name: GetOrganizationChatSettings :one\nSELECT\n o.id AS organization_id,\n im.model_id AS default_chat_model_id,\n r.inference_provider_configuration_id AS default_provider_configuration_id\nFROM weave.organization o\n LEFT JOIN weave.inference_model_route r\n ON r.organization_id = o.id\n AND r.id = o.default_chat_model_route_id\n LEFT JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id\nWHERE o.id = $1";
|
|
116
|
+
export interface GetOrganizationChatSettingsArgs {
|
|
117
|
+
organizationId: string;
|
|
118
|
+
}
|
|
119
|
+
export interface GetOrganizationChatSettingsRow {
|
|
120
|
+
organizationId: string;
|
|
121
|
+
defaultChatModelId: string | null;
|
|
122
|
+
defaultProviderConfigurationId: string | null;
|
|
123
|
+
}
|
|
124
|
+
export declare function getOrganizationChatSettings(client: Client, args: GetOrganizationChatSettingsArgs): Promise<GetOrganizationChatSettingsRow | null>;
|
|
125
|
+
export declare const setOrganizationChatSettingsQuery = "-- name: SetOrganizationChatSettings :one\nWITH selected_route AS (\n SELECT r.id\n FROM weave.inference_model_route r\n JOIN weave.inference_model im\n ON im.organization_id = r.organization_id\n AND im.id = r.inference_model_id\n WHERE r.organization_id = $1\n AND im.model_id = $2\n AND r.inference_provider_configuration_id = $3\n)\nUPDATE weave.organization o\nSET default_chat_model_route_id = selected_route.id\nFROM selected_route\nWHERE o.id = $1\nRETURNING\n o.id AS organization_id,\n $2::text AS default_chat_model_id,\n $3::uuid AS default_provider_configuration_id";
|
|
126
|
+
export interface SetOrganizationChatSettingsArgs {
|
|
127
|
+
organizationId: string;
|
|
128
|
+
defaultChatModelId: string;
|
|
129
|
+
defaultProviderConfigurationId: string;
|
|
130
|
+
}
|
|
131
|
+
export interface SetOrganizationChatSettingsRow {
|
|
132
|
+
organizationId: string;
|
|
133
|
+
defaultChatModelId: string;
|
|
134
|
+
defaultProviderConfigurationId: string;
|
|
135
|
+
}
|
|
136
|
+
export declare function setOrganizationChatSettings(client: Client, args: SetOrganizationChatSettingsArgs): Promise<SetOrganizationChatSettingsRow | null>;
|
|
137
|
+
export declare const getModelRuntimeConfigurationQuery = "-- name: GetModelRuntimeConfiguration :one\nSELECT\n imr.id AS inference_model_route_id,\n imr.organization_id,\n im.id AS inference_model_id,\n im.model_id,\n imr.provider_model_id,\n imr.priority,\n p.id AS inference_provider_configuration_id,\n p.kind AS provider_kind,\n p.name AS provider_name,\n p.slug AS provider_slug,\n p.base_url AS provider_base_url,\n c.credential_kind,\n c.encrypted_credentials,\n c.credential_hint,\n c.key_id,\n c.last_rotated_at\nFROM weave.inference_model_route imr\n JOIN weave.inference_model im\n ON im.organization_id = imr.organization_id\n AND im.id = imr.inference_model_id\n JOIN weave.inference_provider_configuration p\n ON p.organization_id = imr.organization_id\n AND p.id = imr.inference_provider_configuration_id\n JOIN weave.inference_provider_credential c\n ON c.inference_provider_configuration_id = p.id\nWHERE imr.organization_id = $1\n AND im.model_id = $2\nORDER BY imr.priority ASC\nLIMIT 1";
|
|
138
|
+
export interface GetModelRuntimeConfigurationArgs {
|
|
139
|
+
organizationId: string;
|
|
140
|
+
modelId: string;
|
|
141
|
+
}
|
|
142
|
+
export interface GetModelRuntimeConfigurationRow {
|
|
143
|
+
inferenceModelRouteId: string;
|
|
144
|
+
organizationId: string;
|
|
145
|
+
inferenceModelId: string;
|
|
146
|
+
modelId: string;
|
|
147
|
+
providerModelId: string;
|
|
148
|
+
priority: number;
|
|
149
|
+
inferenceProviderConfigurationId: string;
|
|
150
|
+
providerKind: string;
|
|
151
|
+
providerName: string;
|
|
152
|
+
providerSlug: string;
|
|
153
|
+
providerBaseUrl: string | null;
|
|
154
|
+
credentialKind: string;
|
|
155
|
+
encryptedCredentials: Buffer;
|
|
156
|
+
credentialHint: string;
|
|
157
|
+
keyId: string;
|
|
158
|
+
lastRotatedAt: Date;
|
|
159
|
+
}
|
|
160
|
+
export declare function getModelRuntimeConfiguration(client: Client, args: GetModelRuntimeConfigurationArgs): Promise<GetModelRuntimeConfigurationRow | null>;
|
|
161
|
+
export {};
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModelRuntimeConfigurationQuery = exports.setOrganizationChatSettingsQuery = exports.getOrganizationChatSettingsQuery = exports.listInferenceModelRoutesQuery = exports.deleteInferenceModelRouteQuery = exports.updateInferenceModelRouteQuery = exports.getInferenceModelRouteQuery = exports.createInferenceModelRouteQuery = exports.getInferenceModelByModelIDQuery = exports.upsertInferenceModelQuery = void 0;
|
|
4
|
+
exports.upsertInferenceModel = upsertInferenceModel;
|
|
5
|
+
exports.getInferenceModelByModelID = getInferenceModelByModelID;
|
|
6
|
+
exports.createInferenceModelRoute = createInferenceModelRoute;
|
|
7
|
+
exports.getInferenceModelRoute = getInferenceModelRoute;
|
|
8
|
+
exports.updateInferenceModelRoute = updateInferenceModelRoute;
|
|
9
|
+
exports.deleteInferenceModelRoute = deleteInferenceModelRoute;
|
|
10
|
+
exports.listInferenceModelRoutes = listInferenceModelRoutes;
|
|
11
|
+
exports.getOrganizationChatSettings = getOrganizationChatSettings;
|
|
12
|
+
exports.setOrganizationChatSettings = setOrganizationChatSettings;
|
|
13
|
+
exports.getModelRuntimeConfiguration = getModelRuntimeConfiguration;
|
|
14
|
+
exports.upsertInferenceModelQuery = `-- name: UpsertInferenceModel :one
|
|
15
|
+
WITH inserted AS (
|
|
16
|
+
INSERT INTO weave.inference_model (
|
|
17
|
+
organization_id,
|
|
18
|
+
model_id
|
|
19
|
+
) VALUES (
|
|
20
|
+
$1,
|
|
21
|
+
$2
|
|
22
|
+
)
|
|
23
|
+
ON CONFLICT (organization_id, model_id) DO NOTHING
|
|
24
|
+
RETURNING
|
|
25
|
+
id,
|
|
26
|
+
organization_id,
|
|
27
|
+
model_id,
|
|
28
|
+
created_at,
|
|
29
|
+
updated_at,
|
|
30
|
+
true::boolean AS created
|
|
31
|
+
)
|
|
32
|
+
SELECT
|
|
33
|
+
id,
|
|
34
|
+
organization_id,
|
|
35
|
+
model_id,
|
|
36
|
+
created_at,
|
|
37
|
+
updated_at,
|
|
38
|
+
created
|
|
39
|
+
FROM inserted
|
|
40
|
+
UNION ALL
|
|
41
|
+
SELECT
|
|
42
|
+
im.id,
|
|
43
|
+
im.organization_id,
|
|
44
|
+
im.model_id,
|
|
45
|
+
im.created_at,
|
|
46
|
+
im.updated_at,
|
|
47
|
+
false::boolean AS created
|
|
48
|
+
FROM weave.inference_model im
|
|
49
|
+
WHERE im.organization_id = $1
|
|
50
|
+
AND im.model_id = $2
|
|
51
|
+
AND NOT EXISTS (SELECT 1 FROM inserted)
|
|
52
|
+
LIMIT 1`;
|
|
53
|
+
async function upsertInferenceModel(client, args) {
|
|
54
|
+
const result = await client.query({
|
|
55
|
+
text: exports.upsertInferenceModelQuery,
|
|
56
|
+
values: [args.organizationId, args.modelId],
|
|
57
|
+
rowMode: "array"
|
|
58
|
+
});
|
|
59
|
+
if (result.rows.length !== 1) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const row = result.rows[0];
|
|
63
|
+
return {
|
|
64
|
+
id: row[0],
|
|
65
|
+
organizationId: row[1],
|
|
66
|
+
modelId: row[2],
|
|
67
|
+
createdAt: row[3],
|
|
68
|
+
updatedAt: row[4],
|
|
69
|
+
created: row[5]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.getInferenceModelByModelIDQuery = `-- name: GetInferenceModelByModelID :one
|
|
73
|
+
SELECT id, organization_id, model_id, created_at, updated_at
|
|
74
|
+
FROM weave.inference_model
|
|
75
|
+
WHERE organization_id = $1
|
|
76
|
+
AND model_id = $2`;
|
|
77
|
+
async function getInferenceModelByModelID(client, args) {
|
|
78
|
+
const result = await client.query({
|
|
79
|
+
text: exports.getInferenceModelByModelIDQuery,
|
|
80
|
+
values: [args.organizationId, args.modelId],
|
|
81
|
+
rowMode: "array"
|
|
82
|
+
});
|
|
83
|
+
if (result.rows.length !== 1) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const row = result.rows[0];
|
|
87
|
+
return {
|
|
88
|
+
id: row[0],
|
|
89
|
+
organizationId: row[1],
|
|
90
|
+
modelId: row[2],
|
|
91
|
+
createdAt: row[3],
|
|
92
|
+
updatedAt: row[4]
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
exports.createInferenceModelRouteQuery = `-- name: CreateInferenceModelRoute :one
|
|
96
|
+
WITH created AS (
|
|
97
|
+
INSERT INTO weave.inference_model_route (
|
|
98
|
+
organization_id,
|
|
99
|
+
inference_model_id,
|
|
100
|
+
inference_provider_configuration_id,
|
|
101
|
+
provider_model_id,
|
|
102
|
+
priority
|
|
103
|
+
) VALUES (
|
|
104
|
+
$1,
|
|
105
|
+
$2,
|
|
106
|
+
$3,
|
|
107
|
+
$4,
|
|
108
|
+
COALESCE($5::integer, 100)
|
|
109
|
+
)
|
|
110
|
+
RETURNING id, organization_id, inference_model_id, inference_provider_configuration_id, provider_model_id, priority, created_at, updated_at
|
|
111
|
+
)
|
|
112
|
+
SELECT
|
|
113
|
+
r.id,
|
|
114
|
+
r.organization_id,
|
|
115
|
+
r.inference_model_id,
|
|
116
|
+
im.model_id,
|
|
117
|
+
r.inference_provider_configuration_id,
|
|
118
|
+
r.provider_model_id,
|
|
119
|
+
r.priority,
|
|
120
|
+
r.created_at,
|
|
121
|
+
r.updated_at
|
|
122
|
+
FROM created r
|
|
123
|
+
JOIN weave.inference_model im
|
|
124
|
+
ON im.organization_id = r.organization_id
|
|
125
|
+
AND im.id = r.inference_model_id`;
|
|
126
|
+
async function createInferenceModelRoute(client, args) {
|
|
127
|
+
const result = await client.query({
|
|
128
|
+
text: exports.createInferenceModelRouteQuery,
|
|
129
|
+
values: [args.organizationId, args.inferenceModelId, args.inferenceProviderConfigurationId, args.providerModelId, args.priority],
|
|
130
|
+
rowMode: "array"
|
|
131
|
+
});
|
|
132
|
+
if (result.rows.length !== 1) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const row = result.rows[0];
|
|
136
|
+
return {
|
|
137
|
+
id: row[0],
|
|
138
|
+
organizationId: row[1],
|
|
139
|
+
inferenceModelId: row[2],
|
|
140
|
+
modelId: row[3],
|
|
141
|
+
inferenceProviderConfigurationId: row[4],
|
|
142
|
+
providerModelId: row[5],
|
|
143
|
+
priority: row[6],
|
|
144
|
+
createdAt: row[7],
|
|
145
|
+
updatedAt: row[8]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
exports.getInferenceModelRouteQuery = `-- name: GetInferenceModelRoute :one
|
|
149
|
+
SELECT
|
|
150
|
+
r.id,
|
|
151
|
+
r.organization_id,
|
|
152
|
+
r.inference_model_id,
|
|
153
|
+
im.model_id,
|
|
154
|
+
r.inference_provider_configuration_id,
|
|
155
|
+
r.provider_model_id,
|
|
156
|
+
r.priority,
|
|
157
|
+
r.created_at,
|
|
158
|
+
r.updated_at
|
|
159
|
+
FROM weave.inference_model_route r
|
|
160
|
+
JOIN weave.inference_model im
|
|
161
|
+
ON im.organization_id = r.organization_id
|
|
162
|
+
AND im.id = r.inference_model_id
|
|
163
|
+
WHERE r.organization_id = $1
|
|
164
|
+
AND r.id = $2`;
|
|
165
|
+
async function getInferenceModelRoute(client, args) {
|
|
166
|
+
const result = await client.query({
|
|
167
|
+
text: exports.getInferenceModelRouteQuery,
|
|
168
|
+
values: [args.organizationId, args.inferenceModelRouteId],
|
|
169
|
+
rowMode: "array"
|
|
170
|
+
});
|
|
171
|
+
if (result.rows.length !== 1) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
const row = result.rows[0];
|
|
175
|
+
return {
|
|
176
|
+
id: row[0],
|
|
177
|
+
organizationId: row[1],
|
|
178
|
+
inferenceModelId: row[2],
|
|
179
|
+
modelId: row[3],
|
|
180
|
+
inferenceProviderConfigurationId: row[4],
|
|
181
|
+
providerModelId: row[5],
|
|
182
|
+
priority: row[6],
|
|
183
|
+
createdAt: row[7],
|
|
184
|
+
updatedAt: row[8]
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
exports.updateInferenceModelRouteQuery = `-- name: UpdateInferenceModelRoute :one
|
|
188
|
+
WITH updated AS (
|
|
189
|
+
UPDATE weave.inference_model_route
|
|
190
|
+
SET inference_model_id = $1,
|
|
191
|
+
inference_provider_configuration_id = $2,
|
|
192
|
+
provider_model_id = $3,
|
|
193
|
+
priority = $4
|
|
194
|
+
WHERE weave.inference_model_route.organization_id = $5
|
|
195
|
+
AND weave.inference_model_route.id = $6
|
|
196
|
+
RETURNING id, organization_id, inference_model_id, inference_provider_configuration_id, provider_model_id, priority, created_at, updated_at
|
|
197
|
+
)
|
|
198
|
+
SELECT
|
|
199
|
+
r.id,
|
|
200
|
+
r.organization_id,
|
|
201
|
+
r.inference_model_id,
|
|
202
|
+
im.model_id,
|
|
203
|
+
r.inference_provider_configuration_id,
|
|
204
|
+
r.provider_model_id,
|
|
205
|
+
r.priority,
|
|
206
|
+
r.created_at,
|
|
207
|
+
r.updated_at
|
|
208
|
+
FROM updated r
|
|
209
|
+
JOIN weave.inference_model im
|
|
210
|
+
ON im.organization_id = r.organization_id
|
|
211
|
+
AND im.id = r.inference_model_id`;
|
|
212
|
+
async function updateInferenceModelRoute(client, args) {
|
|
213
|
+
const result = await client.query({
|
|
214
|
+
text: exports.updateInferenceModelRouteQuery,
|
|
215
|
+
values: [args.inferenceModelId, args.inferenceProviderConfigurationId, args.providerModelId, args.priority, args.organizationId, args.inferenceModelRouteId],
|
|
216
|
+
rowMode: "array"
|
|
217
|
+
});
|
|
218
|
+
if (result.rows.length !== 1) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
const row = result.rows[0];
|
|
222
|
+
return {
|
|
223
|
+
id: row[0],
|
|
224
|
+
organizationId: row[1],
|
|
225
|
+
inferenceModelId: row[2],
|
|
226
|
+
modelId: row[3],
|
|
227
|
+
inferenceProviderConfigurationId: row[4],
|
|
228
|
+
providerModelId: row[5],
|
|
229
|
+
priority: row[6],
|
|
230
|
+
createdAt: row[7],
|
|
231
|
+
updatedAt: row[8]
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
exports.deleteInferenceModelRouteQuery = `-- name: DeleteInferenceModelRoute :exec
|
|
235
|
+
DELETE FROM weave.inference_model_route
|
|
236
|
+
WHERE organization_id = $1
|
|
237
|
+
AND id = $2`;
|
|
238
|
+
async function deleteInferenceModelRoute(client, args) {
|
|
239
|
+
await client.query({
|
|
240
|
+
text: exports.deleteInferenceModelRouteQuery,
|
|
241
|
+
values: [args.organizationId, args.inferenceModelRouteId],
|
|
242
|
+
rowMode: "array"
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
exports.listInferenceModelRoutesQuery = `-- name: ListInferenceModelRoutes :many
|
|
246
|
+
SELECT
|
|
247
|
+
r.id,
|
|
248
|
+
r.organization_id,
|
|
249
|
+
r.inference_model_id,
|
|
250
|
+
im.model_id,
|
|
251
|
+
r.inference_provider_configuration_id,
|
|
252
|
+
r.provider_model_id,
|
|
253
|
+
r.priority,
|
|
254
|
+
r.created_at,
|
|
255
|
+
r.updated_at
|
|
256
|
+
FROM weave.inference_model_route r
|
|
257
|
+
JOIN weave.inference_model im
|
|
258
|
+
ON im.organization_id = r.organization_id
|
|
259
|
+
AND im.id = r.inference_model_id
|
|
260
|
+
WHERE r.organization_id = $1
|
|
261
|
+
AND ($2::text IS NULL OR im.model_id = $2::text)
|
|
262
|
+
ORDER BY im.model_id ASC, r.priority ASC, r.id ASC
|
|
263
|
+
LIMIT COALESCE($4::integer, 100)
|
|
264
|
+
OFFSET COALESCE($3::integer, 0)`;
|
|
265
|
+
async function listInferenceModelRoutes(client, args) {
|
|
266
|
+
const result = await client.query({
|
|
267
|
+
text: exports.listInferenceModelRoutesQuery,
|
|
268
|
+
values: [args.organizationId, args.modelId, args.pageOffset, args.pageSize],
|
|
269
|
+
rowMode: "array"
|
|
270
|
+
});
|
|
271
|
+
return result.rows.map(row => {
|
|
272
|
+
return {
|
|
273
|
+
id: row[0],
|
|
274
|
+
organizationId: row[1],
|
|
275
|
+
inferenceModelId: row[2],
|
|
276
|
+
modelId: row[3],
|
|
277
|
+
inferenceProviderConfigurationId: row[4],
|
|
278
|
+
providerModelId: row[5],
|
|
279
|
+
priority: row[6],
|
|
280
|
+
createdAt: row[7],
|
|
281
|
+
updatedAt: row[8]
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
exports.getOrganizationChatSettingsQuery = `-- name: GetOrganizationChatSettings :one
|
|
286
|
+
SELECT
|
|
287
|
+
o.id AS organization_id,
|
|
288
|
+
im.model_id AS default_chat_model_id,
|
|
289
|
+
r.inference_provider_configuration_id AS default_provider_configuration_id
|
|
290
|
+
FROM weave.organization o
|
|
291
|
+
LEFT JOIN weave.inference_model_route r
|
|
292
|
+
ON r.organization_id = o.id
|
|
293
|
+
AND r.id = o.default_chat_model_route_id
|
|
294
|
+
LEFT JOIN weave.inference_model im
|
|
295
|
+
ON im.organization_id = r.organization_id
|
|
296
|
+
AND im.id = r.inference_model_id
|
|
297
|
+
WHERE o.id = $1`;
|
|
298
|
+
async function getOrganizationChatSettings(client, args) {
|
|
299
|
+
const result = await client.query({
|
|
300
|
+
text: exports.getOrganizationChatSettingsQuery,
|
|
301
|
+
values: [args.organizationId],
|
|
302
|
+
rowMode: "array"
|
|
303
|
+
});
|
|
304
|
+
if (result.rows.length !== 1) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const row = result.rows[0];
|
|
308
|
+
return {
|
|
309
|
+
organizationId: row[0],
|
|
310
|
+
defaultChatModelId: row[1],
|
|
311
|
+
defaultProviderConfigurationId: row[2]
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
exports.setOrganizationChatSettingsQuery = `-- name: SetOrganizationChatSettings :one
|
|
315
|
+
WITH selected_route AS (
|
|
316
|
+
SELECT r.id
|
|
317
|
+
FROM weave.inference_model_route r
|
|
318
|
+
JOIN weave.inference_model im
|
|
319
|
+
ON im.organization_id = r.organization_id
|
|
320
|
+
AND im.id = r.inference_model_id
|
|
321
|
+
WHERE r.organization_id = $1
|
|
322
|
+
AND im.model_id = $2
|
|
323
|
+
AND r.inference_provider_configuration_id = $3
|
|
324
|
+
)
|
|
325
|
+
UPDATE weave.organization o
|
|
326
|
+
SET default_chat_model_route_id = selected_route.id
|
|
327
|
+
FROM selected_route
|
|
328
|
+
WHERE o.id = $1
|
|
329
|
+
RETURNING
|
|
330
|
+
o.id AS organization_id,
|
|
331
|
+
$2::text AS default_chat_model_id,
|
|
332
|
+
$3::uuid AS default_provider_configuration_id`;
|
|
333
|
+
async function setOrganizationChatSettings(client, args) {
|
|
334
|
+
const result = await client.query({
|
|
335
|
+
text: exports.setOrganizationChatSettingsQuery,
|
|
336
|
+
values: [args.organizationId, args.defaultChatModelId, args.defaultProviderConfigurationId],
|
|
337
|
+
rowMode: "array"
|
|
338
|
+
});
|
|
339
|
+
if (result.rows.length !== 1) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
const row = result.rows[0];
|
|
343
|
+
return {
|
|
344
|
+
organizationId: row[0],
|
|
345
|
+
defaultChatModelId: row[1],
|
|
346
|
+
defaultProviderConfigurationId: row[2]
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
exports.getModelRuntimeConfigurationQuery = `-- name: GetModelRuntimeConfiguration :one
|
|
350
|
+
SELECT
|
|
351
|
+
imr.id AS inference_model_route_id,
|
|
352
|
+
imr.organization_id,
|
|
353
|
+
im.id AS inference_model_id,
|
|
354
|
+
im.model_id,
|
|
355
|
+
imr.provider_model_id,
|
|
356
|
+
imr.priority,
|
|
357
|
+
p.id AS inference_provider_configuration_id,
|
|
358
|
+
p.kind AS provider_kind,
|
|
359
|
+
p.name AS provider_name,
|
|
360
|
+
p.slug AS provider_slug,
|
|
361
|
+
p.base_url AS provider_base_url,
|
|
362
|
+
c.credential_kind,
|
|
363
|
+
c.encrypted_credentials,
|
|
364
|
+
c.credential_hint,
|
|
365
|
+
c.key_id,
|
|
366
|
+
c.last_rotated_at
|
|
367
|
+
FROM weave.inference_model_route imr
|
|
368
|
+
JOIN weave.inference_model im
|
|
369
|
+
ON im.organization_id = imr.organization_id
|
|
370
|
+
AND im.id = imr.inference_model_id
|
|
371
|
+
JOIN weave.inference_provider_configuration p
|
|
372
|
+
ON p.organization_id = imr.organization_id
|
|
373
|
+
AND p.id = imr.inference_provider_configuration_id
|
|
374
|
+
JOIN weave.inference_provider_credential c
|
|
375
|
+
ON c.inference_provider_configuration_id = p.id
|
|
376
|
+
WHERE imr.organization_id = $1
|
|
377
|
+
AND im.model_id = $2
|
|
378
|
+
ORDER BY imr.priority ASC
|
|
379
|
+
LIMIT 1`;
|
|
380
|
+
async function getModelRuntimeConfiguration(client, args) {
|
|
381
|
+
const result = await client.query({
|
|
382
|
+
text: exports.getModelRuntimeConfigurationQuery,
|
|
383
|
+
values: [args.organizationId, args.modelId],
|
|
384
|
+
rowMode: "array"
|
|
385
|
+
});
|
|
386
|
+
if (result.rows.length !== 1) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
const row = result.rows[0];
|
|
390
|
+
return {
|
|
391
|
+
inferenceModelRouteId: row[0],
|
|
392
|
+
organizationId: row[1],
|
|
393
|
+
inferenceModelId: row[2],
|
|
394
|
+
modelId: row[3],
|
|
395
|
+
providerModelId: row[4],
|
|
396
|
+
priority: row[5],
|
|
397
|
+
inferenceProviderConfigurationId: row[6],
|
|
398
|
+
providerKind: row[7],
|
|
399
|
+
providerName: row[8],
|
|
400
|
+
providerSlug: row[9],
|
|
401
|
+
providerBaseUrl: row[10],
|
|
402
|
+
credentialKind: row[11],
|
|
403
|
+
encryptedCredentials: row[12],
|
|
404
|
+
credentialHint: row[13],
|
|
405
|
+
keyId: row[14],
|
|
406
|
+
lastRotatedAt: row[15]
|
|
407
|
+
};
|
|
408
|
+
}
|