aws-samples

Function Calling Using Amazon Bedrock Anthropic Claude 3 — AI skill for Claude Code

AI community

Function calling using Amazon Bedrock with Anthropic Claude 3 foundation model.

How to install Function Calling Using Amazon Bedrock Anthropic Claude 3

This entry records only its repository, not the path inside it, so there is no exact command to give. Open aws-samples/function-calling-using-amazon-bedrock-anthropic-claude-3 and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Function Calling Using Amazon Bedrock Anthropic Claude 3 does

Function calling using Amazon Bedrock with Anthropic Claude 3 foundation model.

Alternatives in AI

  • Anthropic SDK TypeScript — Access to Anthropic's safety-first language model APIs in TypeScript 2.1k ★
  • Vllm Mlx — High-performance OpenAI and Anthropic compatible LLM inference server for Apple Silicon 1.5k ★
  • Claude To ChatGPT — This project converts the API of Anthropic's Claude model to the OpenAI Chat API format 1.3k ★

README

Function calling using Amazon Bedrock with Anthropic Claude 3

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models from leading AI companies and a set of capabilities to build generative AI applications.

This sample repo provide an example for using function calling using the [Converse API](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock-runtime/client/converse.html) with [Anthropic Claude 3 Sonnet](https://aws.amazon.com/about-aws/whats-new/2024/03/anthropics-claude-3-sonnet-model-amazon-bedrock/), using multiple tools. This repo is a sample only code, that demonstrate how to use function calling as tools for a model to use to fetch results using plain function code.

The `Converse` API provides a consistent interface that works with all models that support messages. This allows you to write code once and use it with different models. Should a model have unique inference parameters, you can also pass those unique parameters to the model.

Overview

Function calling (also known as tools), is a way to provide the model, with a descriptive guidance for a function that is available to the model to use for answering the user input.

In this sample, we will ask a Claude 3 to answer, what is a stock ticker value, and with option to convert the default ticker currency to any currency that was provided in the user input.

Tools

There are 2 tools available to the models to use:

  • get_stock_price - given a ticker string, the open source library yfinance will get the current stock value, and currency that its being traded.
  • convert_currency - given an amount, source and target currency, the open source library CurrencyConverter will convert the amount given from source currency to target currency.

The model each turn will review the prompt given, will decide if it can answer properly the question p