Prompt Chain

Integrate OpenAI Function Calls into Your Apps

Promptfoo example evaluating OpenAI function calls, comparing external-YAML versus inline function definitions.

Works with openai

81
Spark score
out of 100
Updated last month
Version code-scan-action-0.1
Models

Add to Favorites

Why it matters

Enable your applications to leverage OpenAI's function calling capabilities for structured data extraction and task execution.

Outcomes

What it gets done

01

Generate code that utilizes OpenAI function calls.

02

Extract structured data from LLM responses.

03

Classify user intents based on LLM output.

04

Summarize information using function calls.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-openai-function-call | bash

Steps

Steps in the chain

01
Set OPENAI_API_KEY environment variable
02
Review and modify configuration
03
Run the evaluation
04
View the results

Overview

Openai Function Call

This example evaluates OpenAI function calls with promptfoo, comparing external-YAML and inline function definitions side by side. Use it when deciding whether to define OpenAI function-calling schemas externally or inline in a promptfoo config.

What it does

This example evaluates OpenAI function calls with promptfoo, demonstrating two ways to define functions: in an external YAML file, and directly inline in the configuration file.

When to use - and when NOT to

Use it when you want a working comparison of external-file versus inline function definitions for OpenAI function calling. Do not use it if you only need one definition style - the value here is seeing both approaches side by side.

Inputs and outputs

Requires OPENAI_API_KEY. The example is pre-configured in promptfooconfig.yaml, which you can review or modify; running the evaluation produces results viewable via promptfoo view.

Integrations

Set up via npx promptfoo@latest init --example openai-function-call, then run promptfoo eval and promptfoo view.

Who it's for

Developers deciding whether to define OpenAI function-calling schemas in a separate YAML file or inline in their promptfoo config.

Source README

openai-function-call (OpenAI Function Call Example)

You can run this example with:

npx promptfoo@latest init --example openai-function-call
cd openai-function-call

This example demonstrates how to use promptfoo to evaluate OpenAI function calls. It showcases two different methods of defining functions: in an external YAML file and directly in the configuration file.

Setup

  1. Set your OPENAI_API_KEY environment variable:

    export OPENAI_API_KEY=your_api_key_here
    
  2. This example is pre-configured in promptfooconfig.yaml. You can review and modify it if needed.

  3. Run the evaluation:

    promptfoo eval
    
  4. View the results:

    promptfoo view
    

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.