Skip to content

Commit

Permalink
Log model and usage stats in sample logger
Browse files Browse the repository at this point in the history
  • Loading branch information
JunShern committed Jan 3, 2024
1 parent ded9382 commit 27a9d2b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions evals/completion_fns/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ def __call__(
**{**kwargs, **self.extra_options},
)
result = OpenAICompletionResult(raw_data=result, prompt=openai_create_prompt)
record_sampling(prompt=result.prompt, sampled=result.get_completions())
record_sampling(
prompt=result.prompt,
sampled=result.get_completions(),
model=result.raw_data.model,
usage=result.raw_data.usage,
)
return result


Expand Down Expand Up @@ -133,5 +138,10 @@ def __call__(
**{**kwargs, **self.extra_options},
)
result = OpenAIChatCompletionResult(raw_data=result, prompt=openai_create_prompt)
record_sampling(prompt=result.prompt, sampled=result.get_completions())
record_sampling(
prompt=result.prompt,
sampled=result.get_completions(),
model=result.raw_data.model,
usage=result.raw_data.usage,
)
return result

0 comments on commit 27a9d2b

Please sign in to comment.