aws-appsync-community
aws-appsync-community copied to clipboard
invokeModel from '@aws-appsync/utils/ai' result in 'Value for field '$[method]' not found.'
I am trying out appsync bedrock integration using '@aws-appsync/utils/ai'
But I am experiencing the following issue:
Value for field '$[method]' not found.
Please find below all the details:
Version: "@aws-appsync/utils": "2.0.3"
Appsync javascript function code:
import { runtime, util } from "@aws-appsync/utils";
import { invokeModel } from "@aws-appsync/utils/ai";
export function request(ctx) {
const { nameToUse, cached } = ctx.stash;
if (cached) {
runtime.earlyReturn(ctx, { skipTo: "NEXT" });
}
const prompt = `
REDACTED
`.trim();
return invokeModel({
modelId: ctx.env.BEDROCK_MODEL_ID,
body: { inputText: prompt },
});
}
export function response(ctx) {
if (ctx.error) {
util.error(ctx.error.message, ctx.error.type, ctx.result);
}
if (!ctx.result) {
util.error("Resolve service error", "InternalServerError");
}
const out = JSON.parse(ctx.result.results[0].outputText);
ctx.stash.transliterated = out.unicode.trim();
return ctx.result;
}
Appsync logs:
{
"logType": "RequestFunctionEvaluation",
"fieldName": "assignName",
"resolverArn": "arn:aws:appsync:us-east-1:{redacted}:apis/{redacted}/types/Mutation/resolvers/assignName",
"functionName": "ResolveNameFunction",
"fieldInError": true,
"evaluationResult": {
"operation": "InvokeModel",
"modelId": "amazon.nova-micro-v1:0",
"body": "{\"inputText\":\"REDACTED\"}"
},
"parentType": "Mutation",
"path": [
"assignName"
],
"requestId": "a0f5b7ed-8b64-4b59-b95e-f5488b53b624",
"context": {
"arguments": {
"locales": [
"en-US-u-fw-mon-mu-celsius",
"fr-FR-u-fw-mon-mu-celsius"
]
},
"prev": {},
"stash": {
"nameToUse": "Nicolas",
"user": {
"id": "f094f76d-8042-4147-8123-59cae80a15e9",
"legalFirstName": "Nicolas"
}
},
"outErrors": []
},
"errors": [
"Value for field '$[method]' not found."
],
"graphQLAPIId": "{redacted}",
"functionArn": "arn:aws:appsync:us-east-1:{redacted}:apis/{redacted}/functions/oi4omr5ocnbvfkpmk45noiajvy"
Let me know if you need anything else, Thank you.
(You should probably redact your ARNs, specifically the Account ID and the API ID followed by deleting the edit history of your post)