wirejs-deploy-amplify-basic 0.1.164 → 0.1.166
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.
|
@@ -51,6 +51,10 @@ function createContext(event: APIGatewayProxyEventV2) {
|
|
|
51
51
|
description: 'HTTP origin (base address) for machines outside your network to use. Only populated for `npm run start:public`, and only accessible in environments that support NAT-PMP.',
|
|
52
52
|
value: location.origin
|
|
53
53
|
}),
|
|
54
|
+
new SystemAttribute('wirejs', 'aws-region', {
|
|
55
|
+
description: 'AWS region where the application is deployed.',
|
|
56
|
+
value: env.AWS_REGION || 'unknown'
|
|
57
|
+
}),
|
|
54
58
|
]
|
|
55
59
|
});
|
|
56
60
|
} catch {
|
package/build.js
CHANGED
|
@@ -103,64 +103,6 @@ async function discoverResources() {
|
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
// /**
|
|
107
|
-
// *
|
|
108
|
-
// * @returns {string[]}
|
|
109
|
-
// */
|
|
110
|
-
// function discoverApiDeps() {
|
|
111
|
-
// return execSync(`npm ls --omit=dev --all --parseable -w ./api`)
|
|
112
|
-
// .toString()
|
|
113
|
-
// .split('\n')
|
|
114
|
-
// .map(line => line.trim())
|
|
115
|
-
// .filter(line => line.includes('node_modules'));
|
|
116
|
-
// }
|
|
117
|
-
|
|
118
|
-
// async function installApiDeps() {
|
|
119
|
-
// console.log("adding deps to package.json");
|
|
120
|
-
// // add deps used by Amplify to deploy backend
|
|
121
|
-
// const packageData = JSON.parse(
|
|
122
|
-
// await fs.promises.readFile(path.join(LAMBDA_BUILD_DIR, 'package.json'))
|
|
123
|
-
// );
|
|
124
|
-
// packageData.dependencies = {
|
|
125
|
-
// 'jose': '^6.1.0',
|
|
126
|
-
// ...(packageData.dependencies || {}),
|
|
127
|
-
// 'wirejs-resources': `file:${SELF_DIR}`
|
|
128
|
-
// };
|
|
129
|
-
// await fs.promises.writeFile(
|
|
130
|
-
// path.join(LAMBDA_BUILD_DIR, 'package.json'),
|
|
131
|
-
// JSON.stringify(packageData, null, 2)
|
|
132
|
-
// );
|
|
133
|
-
|
|
134
|
-
// console.log("installing all deps")
|
|
135
|
-
|
|
136
|
-
// // install all
|
|
137
|
-
// execSync('npm i');
|
|
138
|
-
|
|
139
|
-
// console.log("done installing deps");
|
|
140
|
-
// }
|
|
141
|
-
|
|
142
|
-
// /**
|
|
143
|
-
// *
|
|
144
|
-
// * @param {string[]} deps
|
|
145
|
-
// */
|
|
146
|
-
// async function prepareApiLambda(deps) {
|
|
147
|
-
// await copy
|
|
148
|
-
// (path.join(CWD, 'api', 'dist'),
|
|
149
|
-
// path.join(LAMBDA_BUILD_DIR, 'dist')
|
|
150
|
-
// );
|
|
151
|
-
// await copy(
|
|
152
|
-
// path.join(CWD, 'api', 'dist', 'package.json'),
|
|
153
|
-
// path.join(LAMBDA_BUILD_DIR, 'dist', 'package.json')
|
|
154
|
-
// );
|
|
155
|
-
|
|
156
|
-
// buildSync({
|
|
157
|
-
// entryPoints: path.join(LAMBDA_BUILD_DIR, 'handler.ts'),
|
|
158
|
-
// bundle: true,
|
|
159
|
-
// packages: 'external',
|
|
160
|
-
// outfile: 'handler.js',
|
|
161
|
-
// });
|
|
162
|
-
// }
|
|
163
|
-
|
|
164
106
|
async function deployFrontend() {
|
|
165
107
|
console.log("copying frontend assets");
|
|
166
108
|
await copy(PROJECT_DIST_DIR, STATIC_DIR);
|
package/dist/services/llm.d.ts
CHANGED
package/dist/services/llm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LLM as BaseLLM } from 'wirejs-resources';
|
|
2
2
|
import { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand, } from '@aws-sdk/client-bedrock-runtime';
|
|
3
3
|
import { defaultProvider } from '@aws-sdk/credential-provider-node';
|
|
4
|
+
import { env } from 'process';
|
|
4
5
|
export class LLM extends BaseLLM {
|
|
5
6
|
bedrockClient;
|
|
6
7
|
constructor(scope, id, options) {
|
|
@@ -75,15 +76,38 @@ export class LLM extends BaseLLM {
|
|
|
75
76
|
'amazon.nova-micro-v1:0': ['nova-micro']
|
|
76
77
|
};
|
|
77
78
|
}
|
|
79
|
+
getRegionalPrefix() {
|
|
80
|
+
const region = env.AWS_REGION || 'us-east-1';
|
|
81
|
+
if (region.startsWith('us-')) {
|
|
82
|
+
return 'us';
|
|
83
|
+
}
|
|
84
|
+
else if (region.startsWith('eu-')) {
|
|
85
|
+
return 'eu';
|
|
86
|
+
}
|
|
87
|
+
else if (region.startsWith('ap-')) {
|
|
88
|
+
return 'ap';
|
|
89
|
+
}
|
|
90
|
+
else if (region.startsWith('ca-')) {
|
|
91
|
+
return 'us'; // Canada uses US prefix
|
|
92
|
+
}
|
|
93
|
+
else if (region.startsWith('sa-')) {
|
|
94
|
+
return 'us'; // South America uses US prefix
|
|
95
|
+
}
|
|
96
|
+
// Default to US for unknown regions
|
|
97
|
+
return 'us';
|
|
98
|
+
}
|
|
78
99
|
getModelId(model) {
|
|
79
100
|
const normalized = model.trim().toLowerCase();
|
|
80
101
|
const modelAliases = this.getModelAliases();
|
|
81
102
|
for (const [canonicalModelId, aliases] of Object.entries(modelAliases)) {
|
|
82
103
|
if (normalized === canonicalModelId || aliases.includes(normalized)) {
|
|
83
|
-
|
|
104
|
+
const regionalPrefix = this.getRegionalPrefix();
|
|
105
|
+
return `${regionalPrefix}.${canonicalModelId}`;
|
|
84
106
|
}
|
|
85
107
|
}
|
|
86
|
-
|
|
108
|
+
// For unknown models, still apply regional prefix if it looks like a standard model ID
|
|
109
|
+
const regionalPrefix = this.getRegionalPrefix();
|
|
110
|
+
return `${regionalPrefix}.${model}`;
|
|
87
111
|
}
|
|
88
112
|
async invokeBedrock(modelId, systemPrompt, messages, stream, tools, abortSignal) {
|
|
89
113
|
const toolConfig = tools && tools.length > 0 ? {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wirejs-deploy-amplify-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.166",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"recursive-copy": "^2.0.14",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"wirejs-dom": "^1.0.44",
|
|
47
|
-
"wirejs-resources": "^0.1.
|
|
47
|
+
"wirejs-resources": "^0.1.166"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@aws-amplify/backend": "^1.14.0",
|