From a36bb3a3d3914d82dcf199d522caf920bb8dd1ec Mon Sep 17 00:00:00 2001 From: Ian Saultz <52051793+atierian@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:46:10 -0400 Subject: [PATCH] fix(generation): remove trailing comma in inferenceConfig resolver code --- .../generations/graphql/schema-generation.graphql | 7 ++++++- .../amplify-graphql-generation-transformer.test.ts.snap | 2 +- .../src/resolvers/invoke-bedrock.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/amplify-graphql-api-construct-tests/src/__tests__/generations/graphql/schema-generation.graphql b/packages/amplify-graphql-api-construct-tests/src/__tests__/generations/graphql/schema-generation.graphql index 334ebec9c8..9ee59e600e 100644 --- a/packages/amplify-graphql-api-construct-tests/src/__tests__/generations/graphql/schema-generation.graphql +++ b/packages/amplify-graphql-api-construct-tests/src/__tests__/generations/graphql/schema-generation.graphql @@ -4,7 +4,12 @@ type Recipe { } type Query { - summarize(input: String): String @generation(aiModel: "anthropic.claude-3-haiku-20240307-v1:0", systemPrompt: "summarize the input.") + summarize(input: String): String + @generation( + aiModel: "anthropic.claude-3-haiku-20240307-v1:0" + systemPrompt: "summarize the input." + inferenceConfiguration: { temperature: 0.5 } + ) generateRecipe(description: String): Recipe @generation(aiModel: "anthropic.claude-3-haiku-20240307-v1:0", systemPrompt: "You are a 3 star michelin chef that generates recipes.") diff --git a/packages/amplify-graphql-generation-transformer/src/__tests__/__snapshots__/amplify-graphql-generation-transformer.test.ts.snap b/packages/amplify-graphql-generation-transformer/src/__tests__/__snapshots__/amplify-graphql-generation-transformer.test.ts.snap index 5af359d090..1686d54c9b 100644 --- a/packages/amplify-graphql-generation-transformer/src/__tests__/__snapshots__/amplify-graphql-generation-transformer.test.ts.snap +++ b/packages/amplify-graphql-generation-transformer/src/__tests__/__snapshots__/amplify-graphql-generation-transformer.test.ts.snap @@ -519,7 +519,7 @@ export function request(ctx) { const toolConfig = {"tools":[{"toolSpec":{"name":"responseType","description":"Generate a response type for the given field.","inputSchema":{"json":{"type":"object","properties":{"value":{"type":"string","description":"A UTF-8 character sequence."}},"required":["value"]}}}}],"toolChoice":{"tool":{"name":"responseType"}}}; const prompt = "Generate a string based on the description."; const args = JSON.stringify(ctx.args); - const inferenceConfig = { inferenceConfig: {"maxTokens":100,"temperature":0.7,"topP":0.9} },; + const inferenceConfig = { inferenceConfig: {"maxTokens":100,"temperature":0.7,"topP":0.9} }; return { resourcePath: '/model/anthropic.claude-3-haiku-20240307-v1:0/converse', diff --git a/packages/amplify-graphql-generation-transformer/src/resolvers/invoke-bedrock.ts b/packages/amplify-graphql-generation-transformer/src/resolvers/invoke-bedrock.ts index 1bb95f81b5..05713c3d4f 100644 --- a/packages/amplify-graphql-generation-transformer/src/resolvers/invoke-bedrock.ts +++ b/packages/amplify-graphql-generation-transformer/src/resolvers/invoke-bedrock.ts @@ -55,7 +55,7 @@ const generateResolver = (fileName: string, values: Record): str */ const getInferenceConfigResolverDefinition = (inferenceConfiguration?: InferenceConfiguration): string => { return inferenceConfiguration && Object.keys(inferenceConfiguration).length > 0 - ? `{ inferenceConfig: ${JSON.stringify(inferenceConfiguration)} },` + ? `{ inferenceConfig: ${JSON.stringify(inferenceConfiguration)} }` : 'undefined'; };