examples/google-aistudio-tools/README.md
This example demonstrates how to use Google AI Studio's function calling, search capabilities, code execution, and URL context features with promptfoo.
You can run this example with:
npx promptfoo@latest init --example google-aistudio-tools
cd google-aistudio-tools
GOOGLE_API_KEY in your environmentThis example shows how to:
The function calling configuration (promptfooconfig.yaml) demonstrates:
tools.jsonRun with:
promptfoo eval -c promptfooconfig.yaml
The search grounding configuration (promptfooconfig.search.yaml) demonstrates:
Run with:
promptfoo eval -c promptfooconfig.search.yaml
The code execution configuration (promptfooconfig.codeexecution.yaml) demonstrates:
Run with:
promptfoo eval -c promptfooconfig.codeexecution.yaml
The URL context configuration (promptfooconfig.urlcontext.yaml) demonstrates:
Run with:
promptfoo eval -c promptfooconfig.urlcontext.yaml
promptfooconfig.yaml: Function calling configurationpromptfooconfig.search.yaml: Search grounding configurationpromptfooconfig.codeexecution.yaml: Code execution configurationpromptfooconfig.urlcontext.yaml: URL context configurationtools.json: Function definition for the weather exampleWhen using Search grounding in your own applications:
This example demonstrates three approaches to search:
Search as a tool (Gemini 2.5): Allows the model to decide when to use search
tools:
- googleSearch: {}
Search with thinking (Gemini 2.5): Adds thinking capabilities for better reasoning
generationConfig:
thinkingConfig:
thinkingBudget: 1024
tools:
- googleSearch: {}
Dynamic retrieval (Gemini 1.5): Controls when to use search with threshold settings
tools:
- googleSearchRetrieval:
dynamicRetrievalConfig:
mode: 'MODE_DYNAMIC'
dynamicThreshold: 0 # 0 = always use search, 1 = never use search