Skip to content

Commit 8426782

Browse files
committed
Fix bad merge issues
1 parent d1dec7f commit 8426782

File tree

13 files changed

+131
-20
lines changed

13 files changed

+131
-20
lines changed

package-lock.json

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/ai-constructs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @aws-amplify/ai-constructs
22

3+
## 1.0.0
4+
5+
### Major Changes
6+
7+
- bbd6add: GA release of backend AI features
8+
9+
### Patch Changes
10+
11+
- fd8759d: Fix a case when Bedrock throws validation error if tool input is not persisted in history
12+
313
## 0.8.2
414

515
### Patch Changes

packages/ai-constructs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aws-amplify/ai-constructs",
3-
"version": "0.8.2",
3+
"version": "1.0.0",
44
"type": "commonjs",
55
"publishConfig": {
66
"access": "public"

packages/ai-constructs/src/conversation/runtime/bedrock_converse_adapter.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,8 @@ void describe('Bedrock converse adapter', () => {
901901
assert.strictEqual(responseText, 'finalResponse');
902902

903903
assert.strictEqual(toolExecuteMock.mock.calls.length, 2);
904-
assert.strictEqual(toolExecuteMock.mock.calls[0].arguments[0], undefined);
905-
assert.strictEqual(toolExecuteMock.mock.calls[1].arguments[0], undefined);
904+
assert.deepStrictEqual(toolExecuteMock.mock.calls[0].arguments[0], {});
905+
assert.deepStrictEqual(toolExecuteMock.mock.calls[1].arguments[0], {});
906906
});
907907

908908
void it('throws if tool is duplicated', () => {

packages/ai-constructs/src/conversation/runtime/bedrock_converse_adapter.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export class BedrockConverseAdapter {
252252
if (toolUseBlock) {
253253
if (toolUseInput) {
254254
toolUseBlock.toolUse.input = JSON.parse(toolUseInput);
255+
} else {
256+
// Bedrock API requires tool input to be non-null in message history.
257+
// Therefore, falling back to empty object.
258+
toolUseBlock.toolUse.input = {};
255259
}
256260
accumulatedAssistantMessage.content?.push(toolUseBlock);
257261
if (

packages/backend-ai/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# @aws-amplify/backend-ai
22

3+
## 1.0.0
4+
5+
### Major Changes
6+
7+
- bbd6add: GA release of backend AI features
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [fd8759d]
12+
- Updated dependencies [bbd6add]
13+
- @aws-amplify/ai-constructs@1.0.0
14+
315
## 0.3.5
416

517
### Patch Changes

packages/backend-ai/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aws-amplify/backend-ai",
3-
"version": "0.3.5",
3+
"version": "1.0.0",
44
"type": "module",
55
"publishConfig": {
66
"access": "public"
@@ -22,7 +22,7 @@
2222
},
2323
"license": "Apache-2.0",
2424
"dependencies": {
25-
"@aws-amplify/ai-constructs": "^0.8.0",
25+
"@aws-amplify/ai-constructs": "^1.0.0",
2626
"@aws-amplify/backend-output-schemas": "^1.4.0",
2727
"@aws-amplify/backend-output-storage": "^1.1.3",
2828
"@aws-amplify/data-schema-types": "^1.2.0",

packages/backend-function/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ type ResourceConfig = {
117117
GraphQL: {
118118
endpoint: string;
119119
region: string;
120-
defaultAuthMode: string;
120+
defaultAuthMode: 'iam';
121121
modelIntrospection: any;
122122
};
123123
};

packages/integration-tests/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"type": "module",
66
"devDependencies": {
77
"@apollo/client": "^3.10.1",
8-
"@aws-amplify/ai-constructs": "^0.8.0",
8+
"@aws-amplify/ai-constructs": "^1.0.0",
99
"@aws-amplify/auth-construct": "^1.4.0",
1010
"@aws-amplify/backend": "^1.6.0",
11-
"@aws-amplify/backend-ai": "^0.3.5",
11+
"@aws-amplify/backend-ai": "^1.0.0",
1212
"@aws-amplify/backend-secret": "^1.1.4",
1313
"@aws-amplify/client-config": "^1.5.1",
1414
"@aws-amplify/data-schema": "^1.0.0",

packages/integration-tests/src/test-project-setup/conversation_handler_project.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import assert from 'assert';
2626
import { NormalizedCacheObject } from '@apollo/client';
2727
import {
2828
bedrockModelId,
29+
expectedRandomNumber,
2930
expectedTemperatureInDataToolScenario,
3031
expectedTemperaturesInProgrammaticToolScenario,
3132
} from '../test-projects/conversation-handler/amplify/constants.js';
@@ -278,6 +279,16 @@ class ConversationHandlerTestProject extends TestProjectBase {
278279
)
279280
);
280281

282+
await this.executeWithRetry(() =>
283+
this.assertCustomConversationHandlerCanExecuteTurnWithParameterLessTool(
284+
backendId,
285+
authenticatedUserCredentials.accessToken,
286+
dataUrl,
287+
apolloClient,
288+
true
289+
)
290+
);
291+
281292
await this.executeWithRetry(() =>
282293
this.assertDefaultConversationHandlerCanExecuteTurnWithDataTool(
283294
backendId,
@@ -853,6 +864,56 @@ class ConversationHandlerTestProject extends TestProjectBase {
853864
);
854865
};
855866

867+
private assertCustomConversationHandlerCanExecuteTurnWithParameterLessTool =
868+
async (
869+
backendId: BackendIdentifier,
870+
accessToken: string,
871+
graphqlApiEndpoint: string,
872+
apolloClient: ApolloClient<NormalizedCacheObject>,
873+
streamResponse: boolean
874+
): Promise<void> => {
875+
const customConversationHandlerFunction = (
876+
await this.resourceFinder.findByBackendIdentifier(
877+
backendId,
878+
'AWS::Lambda::Function',
879+
(name) => name.includes('custom')
880+
)
881+
)[0];
882+
883+
const message: CreateConversationMessageChatInput = {
884+
conversationId: randomUUID().toString(),
885+
id: randomUUID().toString(),
886+
role: 'user',
887+
content: [
888+
{
889+
text: 'Give me a random number',
890+
},
891+
],
892+
};
893+
await this.insertMessage(apolloClient, message);
894+
895+
// send event
896+
const event: ConversationTurnEvent = {
897+
conversationId: message.conversationId,
898+
currentMessageId: message.id,
899+
graphqlApiEndpoint: graphqlApiEndpoint,
900+
request: {
901+
headers: { authorization: accessToken },
902+
},
903+
...this.getCommonEventProperties(streamResponse),
904+
};
905+
const response = await this.executeConversationTurn(
906+
event,
907+
customConversationHandlerFunction,
908+
apolloClient
909+
);
910+
// Assert that tool was used. I.e. LLM used value provided by the tool.
911+
assert.match(
912+
response.content,
913+
new RegExp(expectedRandomNumber.toString())
914+
);
915+
};
916+
856917
private assertDefaultConversationHandlerCanPropagateError = async (
857918
backendId: BackendIdentifier,
858919
accessToken: string,

0 commit comments

Comments
 (0)