langfun 0.0.2.dev20240412__py3-none-any.whl → 0.0.2.dev20240413__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.
@@ -155,19 +155,16 @@ class Matching(base.Evaluation):
155
155
  super().save(definition, result, report)
156
156
 
157
157
  if result:
158
-
159
- def force_dict(v):
160
- return pg.object_utils.json_conversion.strip_types(pg.to_json(v))
161
-
162
158
  # Save matches.
163
159
  pg.save(
164
160
  [
165
- # We force the output to be dict as its type may be defined
166
- # within functors which could be deserialized.
167
- pg.Dict(input=input, output=force_dict(output))
161
+ pg.Dict(input=input, output=output)
168
162
  for input, output, _ in self.matches
169
163
  ],
170
164
  os.path.join(self.dir, Matching.MATCHES_JSON),
165
+ # We force the input and output to be dict so it does not depend on
166
+ # the downstream to serialize.
167
+ force_dict=True,
171
168
  )
172
169
 
173
170
  # Save mismatches.
@@ -175,10 +172,13 @@ class Matching(base.Evaluation):
175
172
  [
176
173
  # We force the output to be dict as its type may be defined
177
174
  # within functors which could be deserialized.
178
- pg.Dict(input=input, output=force_dict(output))
175
+ pg.Dict(input=input, output=output)
179
176
  for input, output, _ in self.mismatches
180
177
  ],
181
178
  os.path.join(self.dir, Matching.MISMATCHES_JSON),
179
+ # We force the input and output to be dict so it does not depend on
180
+ # the downstream to serialize.
181
+ force_dict=True,
182
182
  )
183
183
 
184
184
  if report:
@@ -118,19 +118,18 @@ class Scoring(base.Evaluation):
118
118
  super().save(definition, result, report)
119
119
 
120
120
  if result:
121
-
122
- def force_dict(v):
123
- return pg.object_utils.json_conversion.strip_types(pg.to_json(v))
124
-
125
121
  # Save scored.
126
122
  pg.save(
127
123
  [
128
124
  # We force the output to be dict as its type may be defined
129
125
  # within functors which could be deserialized.
130
- pg.Dict(input=input, output=force_dict(output), score=score)
126
+ pg.Dict(input=input, output=output, score=score)
131
127
  for input, output, score, _ in self.scored
132
128
  ],
133
129
  os.path.join(self.dir, Scoring.SCORED_JSON),
130
+ # We force the input and output to be dict so it does not depend on
131
+ # the downstream to serialize.
132
+ force_dict=True,
134
133
  )
135
134
 
136
135
  if report:
@@ -78,7 +78,9 @@ class QueryStructurePython(QueryStructure):
78
78
 
79
79
  {{ output_title }}:
80
80
  ```python
81
- Answer(final_answer=2)
81
+ Answer(
82
+ final_answer=2
83
+ )
82
84
  ```
83
85
  """
84
86
  protocol = 'python'
@@ -116,12 +116,26 @@ class QueryTest(unittest.TestCase):
116
116
  y=2,
117
117
  lm=lm.clone(),
118
118
  expected_snippet=(
119
- 'Please respond to the last INPUT_OBJECT with OUTPUT_OBJECT'
120
- ' according to OUTPUT_TYPE.\n\nINPUT_OBJECT:\n 1 + 1'
121
- ' =\n\nOUTPUT_TYPE:\n Answer\n\n ```python\n class Answer:\n '
122
- ' final_answer: int\n ```\n\nOUTPUT_OBJECT:\n ```python\n '
123
- ' Answer(final_answer=2)\n ```\n\nINPUT_OBJECT:\n What is 1 +'
124
- ' 2?\n\nOUTPUT_TYPE:\n int\n\nOUTPUT_OBJECT:'
119
+ 'Please respond to the last INPUT_OBJECT with OUTPUT_OBJECT '
120
+ 'according to OUTPUT_TYPE.\n\n'
121
+ 'INPUT_OBJECT:\n 1 + 1 =\n\n'
122
+ 'OUTPUT_TYPE:\n'
123
+ ' Answer\n\n'
124
+ ' ```python\n'
125
+ ' class Answer:\n'
126
+ ' final_answer: int\n'
127
+ ' ```\n\n'
128
+ 'OUTPUT_OBJECT:\n'
129
+ ' ```python\n'
130
+ ' Answer(\n'
131
+ ' final_answer=2\n'
132
+ ' )\n'
133
+ ' ```\n\n'
134
+ 'INPUT_OBJECT:\n'
135
+ ' What is 1 + 2?\n\n'
136
+ 'OUTPUT_TYPE:\n'
137
+ ' int\n\n'
138
+ 'OUTPUT_OBJECT:'
125
139
  ),
126
140
  )
127
141
 
@@ -264,7 +278,9 @@ class QueryStructurePythonTest(unittest.TestCase):
264
278
 
265
279
  OUTPUT_OBJECT:
266
280
  ```python
267
- Answer(final_answer=2)
281
+ Answer(
282
+ final_answer=2
283
+ )
268
284
  ```
269
285
 
270
286
  INPUT_OBJECT:
@@ -308,7 +324,9 @@ class QueryStructurePythonTest(unittest.TestCase):
308
324
 
309
325
  OUTPUT_OBJECT:
310
326
  ```python
311
- Answer(final_answer=2)
327
+ Answer(
328
+ final_answer=2
329
+ )
312
330
  ```
313
331
 
314
332
  INPUT_OBJECT:
@@ -192,9 +192,9 @@ class SchemaTest(unittest.TestCase):
192
192
  self.assertEqual(schema.parse('{"result": 1}'), 1)
193
193
  schema = schema_lib.Schema(dict[str, int])
194
194
  self.assertEqual(
195
- schema.parse(
196
- '{"result": {"_type": "Unknown", "x": 1}}}', force_dict=True),
197
- dict(x=1))
195
+ schema.parse('{"result": {"x": 1}}}'),
196
+ dict(x=1)
197
+ )
198
198
  with self.assertRaisesRegex(
199
199
  schema_lib.SchemaError, 'Expect .* but encountered .*'):
200
200
  schema.parse('{"result": "def"}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240412
3
+ Version: 0.0.2.dev20240413
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -42,9 +42,9 @@ langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg
42
42
  langfun/core/eval/__init__.py,sha256=iDA2OcJ3kR6ixZizXIY3N9LsjkaVrfTbSClTiSP8ekY,1291
43
43
  langfun/core/eval/base.py,sha256=Op-DO-YV8sL8mQvCfbzLfDDL6bDMuTtNYeyp5_QCBsQ,55328
44
44
  langfun/core/eval/base_test.py,sha256=mjdQ3ukxc7BhsVJkFJvqtz9EVhSR0OGL9j1zf_AfXR4,21540
45
- langfun/core/eval/matching.py,sha256=g2yuBb4FeOlAlB10hqdWvaIg4QVQlJbiViRDcD2Y8go,9567
45
+ langfun/core/eval/matching.py,sha256=aqNlYrlav7YmsB7rUlsdfoi1RLA5CYqn2RGPxRlPc78,9599
46
46
  langfun/core/eval/matching_test.py,sha256=FFHYD7IDuKe5RMjkx74ksukiwUhO5a_SS340JaIPMws,4898
47
- langfun/core/eval/scoring.py,sha256=mshqbV_WM0zcp15TSR32ACMBDymlsbf6YH06PPx1Tw0,6139
47
+ langfun/core/eval/scoring.py,sha256=aKeanBJf1yO3Q9JEtgPWoiZk_3M_GiqwXVXX7x_g22w,6172
48
48
  langfun/core/eval/scoring_test.py,sha256=YH1cIxBWtfdKcAV9Fh10vLkV5J-gxk8b6nxW4Z2u5pk,4024
49
49
  langfun/core/llms/__init__.py,sha256=gROJ8AjMq_ebXFcEfsyzYGCS6NsGfzf9d43nLu_TIdw,2504
50
50
  langfun/core/llms/fake.py,sha256=dVzOrW27RZ1p3DdQoRCRZs_vfoQcTcNrlWxia7oqmvw,2499
@@ -78,12 +78,12 @@ langfun/core/structured/mapping.py,sha256=7JInwZLmQdu7asHhC0vFLJNOCBnY-hrD6v5RQg
78
78
  langfun/core/structured/mapping_test.py,sha256=07DDCGbwytQHSMm7fCi5-Ly-JNgdV4ubHZq0wthX4A4,3338
79
79
  langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGXLaD8g,11492
80
80
  langfun/core/structured/parsing_test.py,sha256=2_Uf3LYNRON1-5ysEr75xiG_cAxR3ZiixSfvUQu6mOQ,20846
81
- langfun/core/structured/prompting.py,sha256=OAejcd7E-GTRI86i71Uel66te5zcTqyhsNtxe_Nt46U,7407
82
- langfun/core/structured/prompting_test.py,sha256=FdEQ0Sy0zGSFXsaOYkWLjyso37-ckIBZE74hmD7QaAA,19610
81
+ langfun/core/structured/prompting.py,sha256=mOmCWNVMnBk4rI7KBlEm5kmusPXoAKiWcohhzaw-s2o,7427
82
+ langfun/core/structured/prompting_test.py,sha256=luJoJ16h0CkKmZv0-elOD2xLhqa7exZwHUTa9J15wqs,19894
83
83
  langfun/core/structured/schema.py,sha256=mJXirgqx3N7SA9zBO_ISHrzcV-ZRshLhnMJyCcSjGjY,25057
84
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
- langfun/core/structured/schema_test.py,sha256=XsTACSWwFmqlj4pCKsKWcVJbOaeu2DP0jMMCR4EZ_Js,22405
86
+ langfun/core/structured/schema_test.py,sha256=yw_Uo3xJC3JA9dBDjZdkQdBGPf04e7t1oT9SZTAiSdg,22360
87
87
  langfun/core/structured/scoring.py,sha256=a3vfGnqf-DOWjD07MF54GCZTO_R1RTxTDVPzerXnU0s,2325
88
88
  langfun/core/structured/scoring_test.py,sha256=TznLMl0x9QxzmhHz_3Vr44VOXuvFnUSeRQVhu33W5cA,1437
89
89
  langfun/core/templates/__init__.py,sha256=bO0eMsVJbi7sxEB2YlInKRQ2EVP-RyyKUwcD-8msuN4,927
@@ -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.dev20240412.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
99
- langfun-0.0.2.dev20240412.dist-info/METADATA,sha256=9k3LWLg191e7teg-qoLBiTu9Oct_y_KH9IoLp7hjJXg,3405
100
- langfun-0.0.2.dev20240412.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
- langfun-0.0.2.dev20240412.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
102
- langfun-0.0.2.dev20240412.dist-info/RECORD,,
98
+ langfun-0.0.2.dev20240413.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
99
+ langfun-0.0.2.dev20240413.dist-info/METADATA,sha256=O7nH000mRIqk6_yW-mchTjLq3iB6MFVbebb3sE_QMek,3405
100
+ langfun-0.0.2.dev20240413.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
101
+ langfun-0.0.2.dev20240413.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
102
+ langfun-0.0.2.dev20240413.dist-info/RECORD,,