aws / aws/aws-appsync-community
Potential mapping template missmatch for converse and invokeModel in @aws-appsync/utils/ai
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
I just tried the brand new @aws-appsync/utils/ai converse and invokeModel helpers to write a quick Bedrock invocation resolver. Here's a prototype code:
```typescript
import { type Context } from '@aws-appsync/utils';
import { converse } from '@aws-appsync/utils/ai';
const request = (ctx: Context<{ readonly query: string; readonly limit?: number }>) =>
converse({
modelId: 'us.anthropic.claude-3-5-haiku-20241022-v1:0',
system: [
{
text: `Do something useful for once.`,
},
],
messages: [
{
role: 'user',
content: [{ text: `${ctx.arguments.query}` }],
},
],
});
const response = (ctx: Context) => ctx.result.output.message.content[0].text
export { request, response };
```
This results in the following error:
```json
{
"data": null,
"errors": [
{
"path": [
"explorerCompleteSearchQuery"
],
"data": null,
"errorType": "Code",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "Value for field '$[version]' not found."
}
]
}
```
Here's the object generated by converse:
```json
{
"system": [
{
"guardContent": null,
"text": "Do something useful for once."
}
],
"additionalModelRequestFields": null,
"modelId": "us.anthropic.claude-3-5-haiku-20241022-v1:0",
"additionalModelResponseFieldPaths": [],
"guardrailConfig": null,
"inferenceConfig": null,
"messages": [
{
"role": "user",
"content": [
{
"text": "What do we know about the effects of",
"guardContent": null,
"toolResult": null,
"toolUse": null
}
]
}
],
"operation": "Converse",
"version": null
}
```
So, if I manually replace "version": null with "version": "2023-07-27", the system will start complaining about other things, such as not knowing what a "toolConfig" is or "system".
The same behaviour was exhibited by invokeModel, tooK
There might be a mismatch between what AppSync/Bedrock expect and the return of converse and invokeModel.
What do you think?
Contributor guide
Research direction
Start with the TypeScript `converse` and `invokeModel` helpers and inspect the generated request object, especially its `version` field and the fields shown in the report. Reproduce the resolver failure with the supplied prototype, then compare the helper output with the AppSync/Bedrock mapping expectations. Done means both helpers produce requests accepted by the service, with coverage for the reported fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, typescript
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100