aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 12 forks source link

Extend InvokeModelCommand to specify knowledge base #757

Open jogep opened 1 month ago

jogep commented 1 month ago

As a user I want to use the InvokeModelCommand with a specified knowledge base to have better matching results.

  const bedrockInput = {
    "modelId": "anthropic.claude-3-sonnet-20240229-v1:0",
    "contentType": "application/json",
    "accept": "application/json",
    "body": JSON.stringify({
      "anthropic_version": "bedrock-2023-05-31",
      "max_tokens": 4096,
      "system": "Take on the role of a ...",
     "knowledgeBaseId": "<ID OF KNOWLEDGEBASE>",
      "messages": [{
        "role": "user",
        "content": [{
          "type": "text",
          "text": promt
        }]
      }]
    })
  };
  const bedrockData = await bedrockClient.send(new InvokeModelCommand(bedrockInput));