Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel
Michael 02af9d6e5b
refactor(providers): split anthropic provider into modular components (#3406)
5 months ago
..
ccbbe46727
chore: add cursor AI rules for development workflow (#3326)
5 months ago
cd8b724dbf
feat(groq): integrate native Groq SDK and update documentation (#1479)
1 year ago
665242dda8
chore(examples): add yaml schema and descriptions to config files (#2358)
8 months ago
02af9d6e5b
refactor(providers): split anthropic provider into modular components (#3406)
5 months ago

README.md

You have to be logged in to leave a comment. Sign In

tool-use (Function and Tool Calling)

This example demonstrates how to evaluate LLM function/tool calling capabilities using promptfoo.

You can run this example with:

npx promptfoo@latest init --example tool-use

Overview

This example shows how to configure and test function/tool calling capabilities across multiple LLM providers:

  • OpenAI (with native function calling)
  • Anthropic (with Claude's tool use)
  • AWS Bedrock models
  • Groq (with function calling)

Each provider has slightly different syntax and requirements for implementing function/tool calling.

Environment Variables

This example requires the following environment variables:

  • OPENAI_API_KEY - Your OpenAI API key
  • ANTHROPIC_API_KEY - Your Anthropic API key
  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY - For AWS Bedrock (if using the Bedrock example)
  • GROQ_API_KEY - If using Groq's LLaMA models

You can set these in a .env file or directly in your environment.

Provider Documentation

Each provider implements tool use with different syntax:

Running the Example

The configuration for this example is in:

  • promptfooconfig.yaml - Main example with OpenAI, Anthropic, and Groq
  • promptfooconfig.bedrock.yaml - Example specifically for AWS Bedrock models

To run the main example:

promptfoo eval

To run the Bedrock example:

promptfoo eval -c promptfooconfig.bedrock.yaml

After running the evaluation, view the results with:

promptfoo view

Example Tool: Weather Function

This example uses a simple weather lookup function that takes a location and optionally a temperature unit. The example illustrates how different providers handle the same function definition with different syntaxes.

External tools can also be loaded from separate files, as demonstrated with external_tools.yaml.

Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...