The Completion Function Protocol
Here are the interfaces needed to implement the completion function protocol. Any implementation of this interface can be used inside oaieval
.
Reference implementations:
CompletionFn
Completion functions should implement the CompletionFn
interface:
We take a prompt
representing a single sample from an eval. These prompts can be represented as either a text string or a list of messages in OpenAI Chat format. To work with the existing evals, Completion Function implementations would need to handle both types of inputs, but we provide helper functionality to convert Chat formatted messages into a text string if that is the preferred input for your program:
CompletionResult
The completion function should return an object implementing the CompletionResult
interface:
The get_completions
method returns a list of string completions. Each element should be considered a unique completion (in most cases this will be a list of length 1).
Using your CompletionFn
This is all that's needed to implement a Completion function that works with our existing Evals, allowing you to more easily evaluate your end-to-end logic on tasks.
See completion-fns.md to see how to register and use your completion function with oaieval
.