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 b5f0766391
chore(deps): update minor and patch dependencies (#4686)
1 month ago
..
b5f0766391
chore(deps): update minor and patch dependencies (#4686)
1 month ago
d61e341c6d
docs(examples): consolidate google-vertex-tools examples (#4587)
2 months ago
d61e341c6d
docs(examples): consolidate google-vertex-tools examples (#4587)
2 months ago
95eb3e3c11
chore(providers): add support for for tools in Vertex provider (#3077)
6 months ago

README.md

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

google-vertex-tools (Google Vertex Tools)

Example configurations for testing Google Vertex AI models with function calling and tool callbacks.

You can run this example with:

npx promptfoo@latest init --example google-vertex-tools

Purpose

This example demonstrates how to use Vertex AI models with:

  • Function calling and tool declarations
  • Function callback execution with local implementations
  • Different configuration approaches (YAML vs JavaScript)

Prerequisites

  1. Install the Google Auth Library:

    npm install google-auth-library
    
  2. Enable the Vertex AI API in your Google Cloud project

  3. Configure your Google Cloud project:

    gcloud config set project PROJECT_ID
    
  4. Set up authentication using one of these methods:

    • Authenticate with your Google account:

      gcloud auth application-default login
      
    • Use a machine with an authorized service account

    • Use service account credentials file:

      1. Download your service account JSON

      2. Set the credentials path:

        export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
        

Configurations

This example includes two different approaches:

Basic Tool Declaration (promptfooconfig.yaml)

Uses external tool definitions and validates function calls without execution:

  • promptfooconfig.yaml - YAML configuration with external tools
  • tools.json - Function definitions for weather lookup

Function Callbacks (promptfooconfig-callback.js)

Demonstrates actual function execution with local callbacks:

  • promptfooconfig-callback.js - JavaScript configuration with inline tools and callbacks
  • Includes local function implementation for adding numbers

Running the Examples

  1. Basic tool declaration example:

    promptfoo eval -c promptfooconfig.yaml
    
  2. Function callback example:

    promptfoo eval -c promptfooconfig-callback.js
    
  3. View results:

    promptfoo view
    

Expected Results

  • Basic example: Validates that the model correctly calls the weather function with proper parameters
  • Callback example: Actually executes the addition function and validates the computed results

Learn More

Tip!

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

Comments

Loading...