-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(stepfunctions-tasks): fix bedrock input/output path in step-funct… #31305
Changes from 3 commits
d504493
8f0d77f
7682fa2
6c6ac5f
070af9e
33cd3bc
47d60bd
7589bd4
38b80bd
211e23f
af747c8
a52bdcf
451b442
0b7d4e8
4415b89
2ce70ff
dfa2739
0a7c25b
523c05d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,13 +52,32 @@ const prompt2 = new BedrockInvokeModel(stack, 'Prompt2', { | |
resultPath: '$', | ||
}); | ||
|
||
/** Test for Bedrock Output Path */ | ||
const prompt3 = new BedrockInvokeModel(stack, 'Prompt3', { | ||
model, | ||
inputPath: sfn.JsonPath.stringAt('$.names'), | ||
body: sfn.TaskInput.fromObject( | ||
{ | ||
inputText: sfn.JsonPath.format( | ||
'Alphabetize this list of first names:\n{}', | ||
sfn.JsonPath.stringAt('$.names'), | ||
), | ||
textGenerationConfig: { | ||
maxTokenCount: 100, | ||
temperature: 1, | ||
}, | ||
}, | ||
), | ||
outputPath: sfn.JsonPath.stringAt('$.names'), | ||
}); | ||
|
||
const chain = sfn.Chain.start(prompt1).next(prompt2).next(prompt3); | ||
/** Test for Bedrock s3 URI Path */ | ||
const prompt4 = new BedrockInvokeModel(stack, 'Prompt4', { | ||
model, | ||
s3InputUri: sfn.JsonPath.stringAt('$.names'), | ||
s3OutputUri: sfn.JsonPath.stringAt('$.names'), | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you run the verification steps listed at the top of this class? |
||
const chain = sfn.Chain.start(prompt1).next(prompt2).next(prompt3).next(prompt4); | ||
|
||
new sfn.StateMachine(stack, 'StateMachine', { | ||
definitionBody: sfn.DefinitionBody.fromChainable(chain), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -210,8 +210,8 @@ describe('Invoke Model', () => { | |
|
||
const task = new BedrockInvokeModel(stack, 'Invoke', { | ||
model, | ||
inputPath: sfn.JsonPath.stringAt('$.prompt'), | ||
outputPath: sfn.JsonPath.stringAt('$.prompt'), | ||
s3InputUri: sfn.JsonPath.stringAt('$.prompt'), | ||
s3OutputUri: sfn.JsonPath.stringAt('$.prompt'), | ||
}); | ||
|
||
new sfn.StateMachine(stack, 'StateMachine', { | ||
|
@@ -234,8 +234,6 @@ describe('Invoke Model', () => { | |
], | ||
}, | ||
End: true, | ||
InputPath: '$.prompt', | ||
OutputPath: '$.prompt', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are there other unit tests that test this functionality? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two unit tests, one to check the expected template and one to check the permissions populated in policy There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The title of this unit test is "invoke model allows input and output json path". I think this test was originally meant to test the original behavior of inputPath and outputPath. So we need an additional new test for these new s3InputUri and s3OutputUri params, AND fix this unit test to go back to testing the original behavior of inputPath and outputPath. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: I see in the history now that you had actually added this test in the last change. I do still think we should have both tests (inputPath and s3InputUri) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @clareliguori , this leads to one question can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I see, yes you still need body. With inputPath, you would do something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah seems like I totally missed adding unit tests for inputPath and outputPath |
||
Parameters: { | ||
ModelId: 'arn:aws:bedrock:us-turbo-2:123456789012:provisioned-model/abc-123', | ||
Input: { | ||
|
@@ -330,8 +328,8 @@ describe('Invoke Model', () => { | |
// WHEN | ||
const task = new BedrockInvokeModel(stack, 'Invoke', { | ||
model, | ||
inputPath: sfn.JsonPath.stringAt('$.prompt'), | ||
outputPath: sfn.JsonPath.stringAt('$.prompt'), | ||
s3InputUri: sfn.JsonPath.stringAt('$.prompt'), | ||
s3OutputUri: sfn.JsonPath.stringAt('$.prompt'), | ||
}); | ||
|
||
new sfn.StateMachine(stack, 'StateMachine', { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can help me to understand why body is required instead of inputPath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just added this integ test is to make sure, we are not breaking any existing use case for
outputPath
orinputPath
from the base class, looking back at why it might have been marked as required could be a decision taken while designing this s3 input parameter, i don't see it something as required in API docThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to test the inputPath field, you can do a Pass state to transform the previous output into the format expected for the InvokeModel body.