From fe9122d424c80f1abb2c1f16a8acea3b7aeefa11 Mon Sep 17 00:00:00 2001 From: Daiyi Peng Date: Thu, 2 May 2024 15:51:13 -0700 Subject: [PATCH] `lf.eval`: Fix a few issues - Dryrun to use the copy's examples to avoid mess up the current evaluation's state. - Reset examples when starting to run. - Fix usage aggregation logic when the LLM does not provide usage information. This avoids the state of the current evaluation get messed up if calling `self.examples` has a side effect. PiperOrigin-RevId: 630202707 --- langfun/core/eval/base.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/langfun/core/eval/base.py b/langfun/core/eval/base.py index c6bae9a..3fa8bf7 100644 --- a/langfun/core/eval/base.py +++ b/langfun/core/eval/base.py @@ -549,7 +549,7 @@ def _render_message(self, message: lf.Message, s: io.StringIO) -> None: ) s.write(html.escape(pg.format(m.result))) s.write('') - if 'usage' in m.metadata: + if 'usage' in m.metadata and m.usage is not None: s.write( '