-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from ysekiy/docupdate
v0.3.0
- Loading branch information
Showing
60 changed files
with
14,190 additions
and
4,398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
VITE_INDEX_ID=***** | ||
# VITE_SERVER_URL=http://localhost:8080 | ||
# VITE_SERVER_URL=http://localhost:8080 | ||
VITE_MODEL_ID=anthropic.claude-3-haiku-20240307-v1:0 | ||
VITE_BEDROCK_REGION=us-west-2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// Licensed under the MIT-0 License (https://github.com/aws/mit-0) | ||
|
||
import { AmplifyProjectInfo, AmplifyRootStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyRootStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
const authRole = resources.authRole; | ||
|
||
const basePolicies = Array.isArray(authRole.policies) | ||
? authRole.policies | ||
: [authRole.policies]; | ||
|
||
// amplify add で追加した Lambda 関数の ARN を取得する | ||
const envName = amplifyProjectInfo.envName; | ||
|
||
// 開発中の環境からデプロイ先のリージョン名を取得 | ||
const fs = require("fs"); | ||
const amplify_meta_json = JSON.parse(fs.readFileSync("amplify/team-provider-info.json")); | ||
const region_name = amplify_meta_json[envName].awscloudformation.Region; | ||
|
||
// arnから抽出してデプロイ先の Account ID を取得 | ||
const authRoleArn = amplify_meta_json[envName].awscloudformation.AuthRoleArn; | ||
const account_id = authRoleArn.split(':')[4]; | ||
|
||
const functionArn = "arn:aws:lambda:" + region_name + ":" + account_id + ":function:streamClaude3-" + envName | ||
|
||
// claude stream func Lambda の Invoke権限を追加 | ||
authRole.policies = [ | ||
...basePolicies, | ||
{ | ||
policyName: "amplify-permissions-custom-resources", | ||
policyDocument: { | ||
Version: "2012-10-17", | ||
Statement: [ | ||
{ | ||
Resource: functionArn, | ||
Action: [ | ||
"lambda:InvokeFunction" | ||
], | ||
Effect: "Allow", | ||
}, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
// .env ファイルを読み込む | ||
let envContent = fs.readFileSync('.env', 'utf-8'); | ||
|
||
// STREAM_FUNC_ARN の値を更新または追加 | ||
const streamFuncArnPattern = /^VITE_STREAM_FUNC_NAME=.*/gm; | ||
if (streamFuncArnPattern.test(envContent)) { | ||
envContent = envContent.replace(streamFuncArnPattern, `VITE_STREAM_FUNC_NAME=streamClaude3-${envName}`); | ||
} else { | ||
envContent += `\nVITE_STREAM_FUNC_NAME=streamClaude3-${envName}`; | ||
} | ||
|
||
// VITE_MODEL_ID の値を追加 | ||
const modelId = "anthropic.claude-3-haiku-20240307-v1:0" | ||
const modelIdPattern = /^VITE_MODEL_ID=.*/gm; | ||
if (modelIdPattern.test(envContent)) { | ||
envContent = envContent.replace(modelIdPattern, `VITE_MODEL_ID=${modelId}`); | ||
} else { | ||
envContent += `\nVITE_MODEL_ID=${modelId}`; | ||
} | ||
|
||
// VITE_BEDROCK_REGION の値を追加 | ||
const bedrockRegionPattern = /^VITE_BEDROCK_REGION=.*/gm; | ||
if (bedrockRegionPattern.test(envContent)) { | ||
envContent = envContent.replace(bedrockRegionPattern, `VITE_BEDROCK_REGION=${region_name}`); | ||
} else { | ||
envContent += `\nVITE_BEDROCK_REGION=${region_name}`; | ||
} | ||
|
||
// .env ファイルに書き込む | ||
fs.writeFileSync('.env', envContent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"pluginId": "amplify-nodejs-function-runtime-provider", | ||
"functionRuntime": "nodejs", | ||
"useLegacyBuild": true, | ||
"defaultEditorFile": "src/index.js" | ||
} |
10 changes: 10 additions & 0 deletions
10
amplify/backend/function/streamClaude3/custom-policies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[ | ||
{ | ||
"Action": [ | ||
"bedrock:InvokeModelWithResponseStream" | ||
], | ||
"Resource": [ | ||
"arn:aws:bedrock:*::foundation-model/*" | ||
] | ||
} | ||
] |
3 changes: 3 additions & 0 deletions
3
amplify/backend/function/streamClaude3/function-parameters.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"lambdaLayers": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"key1": "value1", | ||
"key2": "value2", | ||
"key3": "value3" | ||
} |
Oops, something went wrong.