langfun 0.0.2.dev20240502__py3-none-any.whl → 0.0.2.dev20240504__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
langfun/core/eval/base.py CHANGED
@@ -549,7 +549,7 @@ class Evaluable(lf.Component):
549
549
  )
550
550
  s.write(html.escape(pg.format(m.result)))
551
551
  s.write('</div>')
552
- if 'usage' in m.metadata:
552
+ if 'usage' in m.metadata and m.usage is not None:
553
553
  s.write(
554
554
  '<div style="background-color: #EEEEEE; color: black; '
555
555
  'white-space: pre-wrap; padding: 10px; border: 0px solid; '
@@ -1056,11 +1056,11 @@ class Evaluation(Evaluable):
1056
1056
  verbose: bool,
1057
1057
  **kwargs,
1058
1058
  ) -> None:
1059
- # Set the example for dryrun.
1060
- example = example or self.examples[0]
1061
-
1062
1059
  # We make a copy to avoid pollute the state of current object.
1063
1060
  copy: Evaluation = self.clone()
1061
+
1062
+ # Set the example for dryrun.
1063
+ example = example or copy.examples[0]
1064
1064
  copy.__dict__['examples'] = [example]
1065
1065
 
1066
1066
  # We set the symbolic parent of the cloned to access contextual information
@@ -1126,6 +1126,9 @@ class Evaluation(Evaluable):
1126
1126
  **kwargs,
1127
1127
  ) -> None:
1128
1128
  # Setup examples.
1129
+ # Reset examples so it could be read from the input functor.
1130
+ self.__dict__.pop('examples', None)
1131
+
1129
1132
  if end is None:
1130
1133
  end = len(self.examples)
1131
1134
  examples = self.examples[start:end]
@@ -1434,8 +1437,9 @@ class Evaluation(Evaluable):
1434
1437
  self._num_completed += 1
1435
1438
 
1436
1439
  def audit_usage(self, message: lf.Message, dryrun: bool = False) -> None:
1440
+ del dryrun
1437
1441
  for m in message.trace():
1438
- if 'usage' in m.metadata:
1442
+ if m.metadata.get('usage', None) is not None:
1439
1443
  self._total_prompt_tokens += m.usage.prompt_tokens
1440
1444
  self._total_completion_tokens += m.usage.completion_tokens
1441
1445
  self._num_usages += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240502
3
+ Version: 0.0.2.dev20240504
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -40,7 +40,7 @@ langfun/core/coding/python/parsing_test.py,sha256=9vAWF484kWIm6JZq8NFiMgKUDhXV-d
40
40
  langfun/core/coding/python/permissions.py,sha256=1QWGHvzL8MM0Ok_auQ9tURqZHtdOfJaDpBzZ29GUE-c,2544
41
41
  langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg366zn99-g__6TbPQ0,2699
42
42
  langfun/core/eval/__init__.py,sha256=Evt-E4FEhZF2tXL6-byh_AyA7Cc_ZoGmvnN7vkAZedk,1898
43
- langfun/core/eval/base.py,sha256=VgHdnfkHeGPp0XjIGHw9LDZsR0Z4-yuWIkzn4pqJj3Y,73967
43
+ langfun/core/eval/base.py,sha256=ZUx-rBjdWyJ5augNIUgRF77-FE-YdFum2uqe0h7-baM,74132
44
44
  langfun/core/eval/base_test.py,sha256=cHOTIWVW4Dp8gKKIKcZrAcJ-w84j2GIozTzJoiAX7p4,26743
45
45
  langfun/core/eval/matching.py,sha256=Y4vFoNTQEOwko6IA8l9OZ52-vt52e3VGmcTtvLA67wM,9782
46
46
  langfun/core/eval/matching_test.py,sha256=f7iVyXH5KGJBWt4Wp14Bt9J3X59A6Ayfog9MbuFvPew,5532
@@ -103,8 +103,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
103
103
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
104
104
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
105
105
  langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
106
- langfun-0.0.2.dev20240502.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
107
- langfun-0.0.2.dev20240502.dist-info/METADATA,sha256=FkgVwz1ahKFAAUsS_sb_SElp3xj_3j6HPQBGeZkGVsw,3405
108
- langfun-0.0.2.dev20240502.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
- langfun-0.0.2.dev20240502.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
110
- langfun-0.0.2.dev20240502.dist-info/RECORD,,
106
+ langfun-0.0.2.dev20240504.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
107
+ langfun-0.0.2.dev20240504.dist-info/METADATA,sha256=BHJpszV9jEUP68lSayLe5QcGfqdRSeCngTA_FynrWEE,3405
108
+ langfun-0.0.2.dev20240504.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
109
+ langfun-0.0.2.dev20240504.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
110
+ langfun-0.0.2.dev20240504.dist-info/RECORD,,