Skip to content
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

Bedrock produces "ValidationException: This model doesn't support the toolConfig.toolChoice.tool field." when using Nova model. #4396

Open
pr1ntr opened this issue Jan 14, 2025 · 0 comments
Labels
ai/provider bug Something isn't working

Comments

@pr1ntr
Copy link

pr1ntr commented Jan 14, 2025

Description

I am attempting to use AWS's Nova model with generateObject and it produces this error:

ValidationException: This model doesn't support the toolConfig.toolChoice.tool field. Remove toolConfig.toolChoice.tool and try again.

Code example

AWS_BEDROCK_REGION=us-east-1
AWS_BEDROCK_MODEL_ID=amazon.nova-pro-v1:0
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock'
import { generateObject } from 'ai'
import mime from 'mime'
import fs from 'fs/promises'
import { MODEL_ID, BEDROCK_REGION } from '../data/constants.js'

const bedrock = createAmazonBedrock({
  region: BEDROCK_REGION,
})
const model = bedrock(MODEL_ID)

//In this situation there are no files being passed.
export async function generate(prompt, schema, system = null, files = []) {
  const time = Date.now()
  console.log('Generating data...')

  const fileParts = []
  for (let file of files) {
    const fileBuffer = await fs.readFile(file)
    const fileMime = mime.getType(file)
    fileParts.push({
      type: 'file',
      data: fileBuffer,
      mimeType: fileMime,
    })
  }

  const { object } = await generateObject({
    model,
    temperature: 0.8,
    maxTokens: 5120,
    output: 'object',
    schema,
    ...(system ? { system } : {}),
    messages: [
      {
        role: 'user',
        content: [
          {
            type: 'text',
            text: prompt,
          },
          ...fileParts,
        ],
      },
    ],
  })

  console.log('Time to generate data:', Date.now() - time)

  return object
}

AI provider

"@ai-sdk/amazon-bedrock": "^1.0.8",

Additional context

No response

@pr1ntr pr1ntr added the bug Something isn't working label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants