Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for lambda data client #2147

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/brave-cheetahs-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@aws-amplify/backend': patch
'@aws-amplify/backend-function': patch
---

feat: Add backend-function runtime behavior to get the data config
6 changes: 6 additions & 0 deletions .changeset/rare-kiwis-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@aws-amplify/backend': patch
'@aws-amplify/backend-data': patch
---

feat: Add mis build to S3 from the data construct factory
65 changes: 34 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/ai-constructs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @aws-amplify/ai-constructs

## 1.0.0

### Major Changes

- bbd6add: GA release of backend AI features

### Patch Changes

- fd8759d: Fix a case when Bedrock throws validation error if tool input is not persisted in history

## 0.8.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ai-constructs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/ai-constructs",
"version": "0.8.2",
"version": "1.0.0",
"type": "commonjs",
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ void describe('Bedrock converse adapter', () => {
assert.strictEqual(responseText, 'finalResponse');

assert.strictEqual(toolExecuteMock.mock.calls.length, 2);
assert.strictEqual(toolExecuteMock.mock.calls[0].arguments[0], undefined);
assert.strictEqual(toolExecuteMock.mock.calls[1].arguments[0], undefined);
assert.deepStrictEqual(toolExecuteMock.mock.calls[0].arguments[0], {});
assert.deepStrictEqual(toolExecuteMock.mock.calls[1].arguments[0], {});
});

void it('throws if tool is duplicated', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ export class BedrockConverseAdapter {
if (toolUseBlock) {
if (toolUseInput) {
toolUseBlock.toolUse.input = JSON.parse(toolUseInput);
} else {
// Bedrock API requires tool input to be non-null in message history.
// Therefore, falling back to empty object.
toolUseBlock.toolUse.input = {};
}
accumulatedAssistantMessage.content?.push(toolUseBlock);
if (
Expand Down
12 changes: 12 additions & 0 deletions packages/backend-ai/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# @aws-amplify/backend-ai

## 1.0.0

### Major Changes

- bbd6add: GA release of backend AI features

### Patch Changes

- Updated dependencies [fd8759d]
- Updated dependencies [bbd6add]
- @aws-amplify/[email protected]

## 0.3.5

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/backend-ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/backend-ai",
"version": "0.3.5",
"version": "1.0.0",
"type": "module",
"publishConfig": {
"access": "public"
Expand All @@ -22,7 +22,7 @@
},
"license": "Apache-2.0",
"dependencies": {
"@aws-amplify/ai-constructs": "^0.8.0",
"@aws-amplify/ai-constructs": "^1.0.0",
"@aws-amplify/backend-output-schemas": "^1.4.0",
"@aws-amplify/backend-output-storage": "^1.1.3",
"@aws-amplify/data-schema-types": "^1.2.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/backend-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"@aws-amplify/backend-output-storage": "^1.1.3",
"@aws-amplify/backend-output-schemas": "^1.4.0",
"@aws-amplify/data-construct": "^1.10.1",
"@aws-amplify/plugin-types": "^1.4.0",
"@aws-amplify/data-schema-types": "^1.2.0"
"@aws-amplify/data-schema-types": "^1.2.0",
"@aws-amplify/graphql-generator": "^0.5.1",
"@aws-amplify/plugin-types": "^1.4.0"
}
}
29 changes: 22 additions & 7 deletions packages/backend-data/src/app_sync_policy_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export class AppSyncPolicyGenerator {
/**
* Initialize with the GraphqlAPI that the policies will be scoped to
*/
constructor(private readonly graphqlApi: IGraphqlApi) {
constructor(
private readonly graphqlApi: IGraphqlApi,
private readonly modelIntrospectionSchemaArn?: string
) {
this.stack = Stack.of(graphqlApi);
}
/**
Expand All @@ -29,13 +32,25 @@ export class AppSyncPolicyGenerator {
.map((action) => actionToTypeMap[action])
// convert Type to resourceName
.map((type) => [this.graphqlApi.arn, 'types', type, '*'].join('/'));
return new Policy(this.stack, `${this.policyPrefix}${this.policyCount++}`, {
statements: [

const statements = [
new PolicyStatement({
actions: ['appsync:GraphQL'],
resources,
}),
];

if (this.modelIntrospectionSchemaArn) {
statements.push(
new PolicyStatement({
actions: ['appsync:GraphQL'],
resources,
}),
],
actions: ['s3:GetObject'],
resources: [this.modelIntrospectionSchemaArn],
})
);
}

return new Policy(this.stack, `${this.policyPrefix}${this.policyCount++}`, {
statements,
});
}
}
Expand Down
Loading
Loading