From 064772171d93acc4c00135d492f82c859b42d718 Mon Sep 17 00:00:00 2001 From: Dane Date: Thu, 4 Jan 2024 03:46:19 +1100 Subject: [PATCH] Add a recorder for function calls (#1389) **What:** Adds a recorder for function calls made by models. **Why:** Currently function calls can be logged using `record_event` but it'd be convenient for function calls to logged consistently. --- evals/record.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/evals/record.py b/evals/record.py index 5afe5a859a..4f428d810f 100644 --- a/evals/record.py +++ b/evals/record.py @@ -215,6 +215,15 @@ def record_sampling(self, prompt, sampled, sample_id=None, **extra): } self.record_event("sampling", data, sample_id=sample_id) + def record_function_call(self, name, arguments, return_value, sample_id=None, **extra): + data = { + "name": name, + "arguments": arguments, + "return_value": return_value, + **extra, + } + self.record_event("function_call", data, sample_id=sample_id) + def record_cond_logp(self, prompt, completion, logp, sample_id=None, **extra): data = { "prompt": prompt, @@ -591,6 +600,10 @@ def record_sampling(prompt, sampled, **extra): return default_recorder().record_sampling(prompt, sampled, **extra) +def record_function_call(name, arguments, return_value, **extra): + return default_recorder().record_function_call(name, arguments, return_value, **extra) + + def record_cond_logp(prompt, completion, logp, **extra): return default_recorder().record_cond_logp(prompt, completion, logp, **extra)