Skip to content

Commit

Permalink
Add a recorder for function calls (openai#1389)
Browse files Browse the repository at this point in the history
**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.
  • Loading branch information
danesherbs committed Jan 3, 2024
1 parent bbe26f8 commit 0647721
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions evals/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0647721

Please sign in to comment.