langfun 0.0.2.dev20240319__py3-none-any.whl → 0.0.2.dev20240327__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
@@ -1015,7 +1015,10 @@ class Evaluation(Evaluable):
1015
1015
  status_fn=self._status,
1016
1016
  ):
1017
1017
  if error is not None:
1018
- self._failures.append((example, str(error)))
1018
+ try:
1019
+ self._failures.append((example, str(error)))
1020
+ except Exception as e: # pylint: disable=broad-exception-caught
1021
+ self._failures.append((example, str(e)))
1019
1022
  else:
1020
1023
  output = message.text if self.schema is None else message.result
1021
1024
  self.audit(example, output, message)
@@ -285,7 +285,9 @@ class Mapping(lf.LangFunc):
285
285
  def transform_input(self, lm_input: lf.Message) -> lf.Message:
286
286
  # Find modalities to fill the input message.
287
287
  lm_input.metadata.update(
288
- examples=pg.Ref(self.examples), input=pg.Ref(self.input)
288
+ examples=pg.Ref(self.examples),
289
+ input=pg.Ref(self.input),
290
+ schema=pg.Ref(self.schema) if self.schema is not None else None,
289
291
  )
290
292
  if isinstance(self.input, lf.Message):
291
293
  lm_input.source = self.input
@@ -16,6 +16,7 @@ from typing import Any, Callable, Type, Union
16
16
 
17
17
  import langfun.core as lf
18
18
  from langfun.core.structured import mapping
19
+ from langfun.core.structured import prompting
19
20
  from langfun.core.structured import schema as schema_lib
20
21
  import pyglove as pg
21
22
 
@@ -270,7 +271,7 @@ def call(
270
271
  return lm_output if returns_message else lm_output.text
271
272
 
272
273
  # Call `parsing_lm` for structured parsing.
273
- return parse(
274
+ return prompting.query(
274
275
  lm_output,
275
276
  schema,
276
277
  examples=parsing_examples,
@@ -143,14 +143,14 @@ def generate_class(
143
143
 
144
144
 
145
145
  def classgen_example(
146
- class_name: str, prompt: str | pg.Symbolic, cls: Type[Any]
146
+ prompt: str | pg.Symbolic, cls: Type[Any]
147
147
  ) -> mapping.MappingExample:
148
148
  """Creates a class generation example."""
149
149
  if isinstance(prompt, lf.Template):
150
150
  prompt = prompt.render()
151
151
  return mapping.MappingExample(
152
152
  input=prompt,
153
- context=class_name,
153
+ context=cls.__name__,
154
154
  output=cls,
155
155
  )
156
156
 
@@ -168,7 +168,6 @@ def default_classgen_examples() -> list[mapping.MappingExample]:
168
168
 
169
169
  return [
170
170
  classgen_example(
171
- 'Solution',
172
171
  'How to evaluate an arithmetic expression?',
173
172
  Solution,
174
173
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240319
3
+ Version: 0.0.2.dev20240327
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=iDA2OcJ3kR6ixZizXIY3N9LsjkaVrfTbSClTiSP8ekY,1291
43
- langfun/core/eval/base.py,sha256=tT_85jpLMCbXufKf64BMslid9FB1TNhe3AIkIpLULhA,53782
43
+ langfun/core/eval/base.py,sha256=7eyR2LWYs3hFMxTgWJf12yXOKhBT3qno68lz_tqfZv8,53933
44
44
  langfun/core/eval/base_test.py,sha256=3AG-PN6yv0DMcHvpPas2nv2bJoY9JdAYSYwiPUnnolo,21177
45
45
  langfun/core/eval/matching.py,sha256=g2yuBb4FeOlAlB10hqdWvaIg4QVQlJbiViRDcD2Y8go,9567
46
46
  langfun/core/eval/matching_test.py,sha256=IfuMF_dEmy4VzK6tIldRzD2Nqlml7SSh4u-baFNcZrw,4912
@@ -74,14 +74,14 @@ langfun/core/structured/completion.py,sha256=skBxt6V_fv2TBUKnzFgnPMbVY8HSYn8sY04
74
74
  langfun/core/structured/completion_test.py,sha256=98UCgA4gzfp6H6HgP2s2kcKs25YH3k4Nxj1rgAvmVBw,19249
75
75
  langfun/core/structured/description.py,sha256=SXW4MJvshFjbR-0gw6rE21o6WXq12UlRXawvDBXMZFA,5211
76
76
  langfun/core/structured/description_test.py,sha256=UtZGjSFUaQ6130t1E5tcL7ODu0xIefkapb53TbnqsK8,7362
77
- langfun/core/structured/mapping.py,sha256=tahkaAB-L6yKbYb7qjVI301-FfIARdw4w8nP3wqS2-k,10291
77
+ langfun/core/structured/mapping.py,sha256=m7i80GU3vfDZXw4TTnidWTS3K-c1H8JNX9KcoMw4E4s,10373
78
78
  langfun/core/structured/mapping_test.py,sha256=07DDCGbwytQHSMm7fCi5-Ly-JNgdV4ubHZq0wthX4A4,3338
79
- langfun/core/structured/parsing.py,sha256=yTKuezai5i-X9W-jU0DeEZzqHHbCFom0plj-D0bhp98,11436
79
+ langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGXLaD8g,11492
80
80
  langfun/core/structured/parsing_test.py,sha256=2_Uf3LYNRON1-5ysEr75xiG_cAxR3ZiixSfvUQu6mOQ,20846
81
81
  langfun/core/structured/prompting.py,sha256=0xRPC0K_RaFRv-j52x8_-1n1eRFSomJEpdZApVXsCV0,6902
82
82
  langfun/core/structured/prompting_test.py,sha256=SwoYbPyKhUT1H2QbqHvl93biCiE9Ttn1aWixoHH-v9Y,19129
83
83
  langfun/core/structured/schema.py,sha256=60griJ-yC1SExX6g-aOcAOo8yFh53CdwMV4EVK3ivug,25207
84
- langfun/core/structured/schema_generation.py,sha256=Yv9flJ4GTtLw-bDB8S7A93G-z4gXsFMkMASkbiduT3E,5353
84
+ langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
85
85
  langfun/core/structured/schema_generation_test.py,sha256=cfZyP0gHno2fXy_c9vsVdvHmqKQSfuyUsCtfO3JFmYQ,2945
86
86
  langfun/core/structured/schema_test.py,sha256=kMIgnAzm3f2O5ofn0pPKjT6H8hny4cWVaUVDOZuyjOQ,21987
87
87
  langfun/core/structured/scoring.py,sha256=a3vfGnqf-DOWjD07MF54GCZTO_R1RTxTDVPzerXnU0s,2325
@@ -95,8 +95,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
95
95
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
96
96
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
97
97
  langfun/core/templates/selfplay_test.py,sha256=IB5rWbjK_9CTkqEo1BclQPzFAKcIiusJckH8J19HFgI,2096
98
- langfun-0.0.2.dev20240319.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
99
- langfun-0.0.2.dev20240319.dist-info/METADATA,sha256=sDKuxrM_kBnxcU99DD5uyERL3OIJ4oeEN19QkqKOKuU,3405
100
- langfun-0.0.2.dev20240319.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
- langfun-0.0.2.dev20240319.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
102
- langfun-0.0.2.dev20240319.dist-info/RECORD,,
98
+ langfun-0.0.2.dev20240327.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
99
+ langfun-0.0.2.dev20240327.dist-info/METADATA,sha256=MNEoj0OV9qA2DzR1nN28cYuOryn97VV3zEDLtXCRfHE,3405
100
+ langfun-0.0.2.dev20240327.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
+ langfun-0.0.2.dev20240327.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
102
+ langfun-0.0.2.dev20240327.dist-info/RECORD,,