langfun 0.0.2.dev20240424__py3-none-any.whl → 0.0.2.dev20240426__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.
@@ -20,6 +20,43 @@ from langfun.core.structured import schema as schema_lib
20
20
  import pyglove as pg
21
21
 
22
22
 
23
+ class MappingError(Exception): # pylint: disable=g-bad-exception-name
24
+ """Mapping error."""
25
+
26
+ def __init__(self, lm_response: lf.Message, cause: Exception):
27
+ self._lm_response = lm_response
28
+ self._cause = cause
29
+
30
+ @property
31
+ def lm_response(self) -> lf.Message:
32
+ """Returns the LM response that failed to be mapped."""
33
+ return self._lm_response
34
+
35
+ @property
36
+ def cause(self) -> Exception:
37
+ """Returns the cause of the error."""
38
+ return self._cause
39
+
40
+ def __str__(self) -> str:
41
+ return self.format(include_lm_response=True)
42
+
43
+ def format(self, include_lm_response: bool = True) -> str:
44
+ """Formats the mapping error."""
45
+ r = io.StringIO()
46
+ error_message = str(self.cause).rstrip()
47
+ r.write(
48
+ lf.colored(
49
+ f'{self.cause.__class__.__name__}: {error_message}', 'magenta'
50
+ )
51
+ )
52
+ if include_lm_response:
53
+ r.write('\n\n')
54
+ r.write(lf.colored('[LM Response]', 'blue', styles=['bold']))
55
+ r.write('\n')
56
+ r.write(lf.colored(self.lm_response.text, 'blue'))
57
+ return r.getvalue()
58
+
59
+
23
60
  @pg.use_init_args(['input', 'output', 'schema', 'context'])
24
61
  class MappingExample(lf.NaturalLanguageFormattable, lf.Component):
25
62
  """Mapping example between text, schema and structured value."""
@@ -308,7 +345,7 @@ class Mapping(lf.LangFunc):
308
345
  lm_output.result = self.postprocess_result(self.parse_result(lm_output))
309
346
  except Exception as e: # pylint: disable=broad-exception-caught
310
347
  if self.default == lf.RAISE_IF_HAS_ERROR:
311
- raise e
348
+ raise MappingError(lm_output, e) from e
312
349
  lm_output.result = self.default
313
350
  return lm_output
314
351
 
@@ -16,10 +16,27 @@
16
16
  import inspect
17
17
  import unittest
18
18
 
19
+ import langfun.core as lf
19
20
  from langfun.core.structured import mapping
20
21
  import pyglove as pg
21
22
 
22
23
 
24
+ class MappingErrorTest(unittest.TestCase):
25
+
26
+ def test_format(self):
27
+ error = mapping.MappingError(
28
+ lf.AIMessage('hi'), ValueError('Cannot parse message.')
29
+ )
30
+ self.assertEqual(
31
+ lf.text_formatting.decolored(str(error)),
32
+ 'ValueError: Cannot parse message.\n\n[LM Response]\nhi',
33
+ )
34
+ self.assertEqual(
35
+ lf.text_formatting.decolored(error.format(include_lm_response=False)),
36
+ 'ValueError: Cannot parse message.',
37
+ )
38
+
39
+
23
40
  class MappingExampleTest(unittest.TestCase):
24
41
 
25
42
  def test_basics(self):
@@ -17,11 +17,9 @@ import inspect
17
17
  import unittest
18
18
 
19
19
  import langfun.core as lf
20
- from langfun.core import coding
21
20
  from langfun.core.llms import fake
22
21
  from langfun.core.structured import mapping
23
22
  from langfun.core.structured import parsing
24
- from langfun.core.structured import schema as schema_lib
25
23
  import pyglove as pg
26
24
 
27
25
 
@@ -255,7 +253,7 @@ class ParseStructurePythonTest(unittest.TestCase):
255
253
  override_attrs=True,
256
254
  ):
257
255
  with self.assertRaisesRegex(
258
- coding.CodeError,
256
+ mapping.MappingError,
259
257
  'name .* is not defined',
260
258
  ):
261
259
  parsing.parse('three', int)
@@ -546,7 +544,7 @@ class ParseStructureJsonTest(unittest.TestCase):
546
544
  override_attrs=True,
547
545
  ):
548
546
  with self.assertRaisesRegex(
549
- schema_lib.JsonError,
547
+ mapping.MappingError,
550
548
  'No JSON dict in the output',
551
549
  ):
552
550
  parsing.parse('three', int, protocol='json')
@@ -176,8 +176,11 @@ def query(
176
176
  returning the structured `message.result`.
177
177
  skip_lm: If True, returns the rendered prompt as a UserMessage object.
178
178
  otherwise return the LLM response based on the rendered prompt.
179
- **kwargs: Keyword arguments passed to the
180
- `lf.structured.NaturalLanguageToStructureed` transform.
179
+ **kwargs: Keyword arguments passed to render the prompt or configure the
180
+ `lf.structured.Mapping` class. Notable kwargs are:
181
+ - template_str: Change the root template for query.
182
+ - preamble: Change the preamble for query.
183
+ - mapping_template: Change the template for each mapping examle.
181
184
 
182
185
  Returns:
183
186
  The result based on the schema.
@@ -201,10 +204,17 @@ def query(
201
204
  return output if returns_message else output.text
202
205
 
203
206
  # Query with structured output.
207
+ prompt_kwargs = kwargs.copy()
208
+
209
+ # NOTE(daiyip): when `template_str` is passed in, it's intended to modify the
210
+ # QueryStructure template string. Therefore, we pop out the argument for
211
+ # prompt rendering.
212
+ prompt_kwargs.pop('template_str', None)
213
+
204
214
  if isinstance(prompt, str):
205
- prompt = lf.Template(prompt, **kwargs)
215
+ prompt = lf.Template(prompt, **prompt_kwargs)
206
216
  elif isinstance(prompt, lf.Template):
207
- prompt = prompt.rebind(**kwargs)
217
+ prompt = prompt.rebind(**prompt_kwargs, raise_on_no_change=False)
208
218
 
209
219
  if isinstance(prompt, lf.Template):
210
220
  prompt = prompt.render(lm=lm)
@@ -17,12 +17,10 @@ import inspect
17
17
  import unittest
18
18
 
19
19
  import langfun.core as lf
20
- from langfun.core import coding
21
20
  from langfun.core import modalities
22
21
  from langfun.core.llms import fake
23
22
  from langfun.core.structured import mapping
24
23
  from langfun.core.structured import prompting
25
- from langfun.core.structured import schema as schema_lib
26
24
  import pyglove as pg
27
25
 
28
26
 
@@ -140,6 +138,39 @@ class QueryTest(unittest.TestCase):
140
138
  ),
141
139
  )
142
140
 
141
+ def test_str_to_structure_render_custom_template(self):
142
+ lm = fake.StaticResponse('1')
143
+ self.assert_render(
144
+ 'What is {{x}} + {{y}}?',
145
+ int,
146
+ x=1,
147
+ y=2,
148
+ lm=lm.clone(),
149
+ template_str='!!{{ DEFAULT }}!!',
150
+ expected_snippet=(
151
+ '!!Please respond to the last INPUT_OBJECT with OUTPUT_OBJECT '
152
+ 'according to OUTPUT_TYPE.\n\n'
153
+ 'INPUT_OBJECT:\n 1 + 1 =\n\n'
154
+ 'OUTPUT_TYPE:\n'
155
+ ' Answer\n\n'
156
+ ' ```python\n'
157
+ ' class Answer:\n'
158
+ ' final_answer: int\n'
159
+ ' ```\n\n'
160
+ 'OUTPUT_OBJECT:\n'
161
+ ' ```python\n'
162
+ ' Answer(\n'
163
+ ' final_answer=2\n'
164
+ ' )\n'
165
+ ' ```\n\n'
166
+ 'INPUT_OBJECT:\n'
167
+ ' What is 1 + 2?\n\n'
168
+ 'OUTPUT_TYPE:\n'
169
+ ' int\n\n'
170
+ 'OUTPUT_OBJECT:!!'
171
+ ),
172
+ )
173
+
143
174
  def test_str_to_str_render(self):
144
175
  lm = fake.StaticResponse('1')
145
176
  self.assert_render(
@@ -439,7 +470,7 @@ class QueryStructurePythonTest(unittest.TestCase):
439
470
  override_attrs=True,
440
471
  ):
441
472
  with self.assertRaisesRegex(
442
- coding.CodeError,
473
+ mapping.MappingError,
443
474
  'name .* is not defined',
444
475
  ):
445
476
  prompting.query('Compute 1 + 2', int)
@@ -677,7 +708,7 @@ class QueryStructureJsonTest(unittest.TestCase):
677
708
  override_attrs=True,
678
709
  ):
679
710
  with self.assertRaisesRegex(
680
- schema_lib.JsonError,
711
+ mapping.MappingError,
681
712
  'No JSON dict in the output',
682
713
  ):
683
714
  prompting.query('Compute 1 + 2', int, protocol='json')
@@ -14,8 +14,8 @@
14
14
  import inspect
15
15
  import unittest
16
16
 
17
- import langfun.core.coding as lf_coding
18
17
  from langfun.core.llms import fake
18
+ from langfun.core.structured import mapping
19
19
  from langfun.core.structured import schema_generation
20
20
 
21
21
 
@@ -92,7 +92,7 @@ class GenerateClassTest(unittest.TestCase):
92
92
  )
93
93
  self.assertIs(cls.__name__, 'B')
94
94
 
95
- with self.assertRaises(lf_coding.CodeError):
95
+ with self.assertRaises(mapping.MappingError):
96
96
  schema_generation.generate_class(
97
97
  'Foo',
98
98
  'Generate a Foo class with a field pointing to another class A',
langfun/core/template.py CHANGED
@@ -48,7 +48,12 @@ class Template(
48
48
  component.Component,
49
49
  pg.typing.CustomTyping,
50
50
  ):
51
- """Langfun string template."""
51
+ """Langfun string template.
52
+
53
+ Langfun uses jinja2 as its template engine. Pleaes check out
54
+ https://jinja.palletsprojects.com/en/3.1.x/templates/ for detailed
55
+ explanation on the template language.
56
+ """
52
57
 
53
58
  template_str: Annotated[
54
59
  str,
@@ -101,6 +106,11 @@ class Template(
101
106
  # Declare template variables as symbolic attributes.
102
107
  template_vars = Template.resolve_vars(template_str)
103
108
  for var_name in template_vars:
109
+ if 'DEFAULT' == var_name:
110
+ raise ValueError(
111
+ '`{{ DEFAULT }}` cannot be used in pre-configured templates. '
112
+ f'Encountered: {template_str!r}'
113
+ )
104
114
  # NOTE(daiyip): This is to avoid warning from accessing
105
115
  # `pg.Object.schema`, which was replaced by `pg.Object.__schema__`.
106
116
  if var_name == 'schema' or not hasattr(cls, var_name):
@@ -153,7 +163,7 @@ class Template(
153
163
  # TODO(daiyip): Consider to delay template parsing upon usage.
154
164
  unassigned_vars = {}
155
165
  for k in self._variables:
156
- if not hasattr(self, k):
166
+ if k not in ('DEFAULT',) and not hasattr(self, k):
157
167
  unassigned_vars[k] = component.contextual()
158
168
  if unassigned_vars:
159
169
  self.rebind(unassigned_vars, skip_notification=True)
@@ -398,6 +408,93 @@ class Template(
398
408
  # Override __hash__ since __eq__ has changed.
399
409
  return object.__hash__(self)
400
410
 
411
+ #
412
+ # Special methods.
413
+ #
414
+
415
+ @property
416
+ def DEFAULT(self) -> 'Template':
417
+ """Referring to the default value used for this template.
418
+
419
+ This method is intended to be used in template for referring to the default
420
+ value of current template. There are two scenarios:
421
+
422
+ Scenario 1: Use instance-level template_str to override the class default.
423
+
424
+ ```
425
+ class Foo(lf.Template):
426
+ '''Foo template.
427
+
428
+ This is {{x}}.
429
+ '''
430
+
431
+ f = Foo(template_str='<h1>{{DEFAULT}}</h1>', x=1)
432
+ f.render()
433
+
434
+ >> <h1>This is 1.</h1>
435
+ ```
436
+
437
+ Scenario 2: Use an ad-hoc template to override a predefined field.
438
+
439
+ ```
440
+ class Bar(lf.Template):
441
+ '''Bar template.
442
+
443
+ {{preamble}}
444
+ {{prompt}}
445
+ '''
446
+ preamble: lf.Template = lf.Template('You are a chat bot.')
447
+ prompt: lf.Template = lf.Template('User: hi')
448
+
449
+ b = Bar(preamble=lf.Template('<h1>{{DEFAULT}}<h1>'),
450
+ prompt=lf.Template('<h2>{{DEFAULT}}</h2>')
451
+ b.render()
452
+
453
+ >> <h1>You are a chat bot.<h1>
454
+ >> <h2>User: hi</h2>
455
+ ```
456
+
457
+ Returns:
458
+ The default (pre-configured) value used for this template.
459
+ """
460
+ base_template = self.__class__.__schema__['template_str'].default_value
461
+ if base_template == pg.MISSING_VALUE:
462
+ if not self.sym_path:
463
+ raise ValueError(
464
+ f'No DEFAULT template found for {self!r}: '
465
+ 'The template neither has a default `template_str` nor is '
466
+ 'contained under another object.'
467
+ )
468
+ key = self.sym_path.key
469
+ assert self.sym_parent is not None
470
+ assigned_field = self.sym_parent.sym_attr_field(key)
471
+ container_cls = self.sym_parent.__class__
472
+
473
+ if (
474
+ assigned_field is None
475
+ or assigned_field.default_value == pg.MISSING_VALUE
476
+ ):
477
+ raise ValueError(
478
+ f'No DEFAULT template found for {self!r}: '
479
+ f'`{container_cls.__name__}.{key}` '
480
+ 'does not have a default value. '
481
+ )
482
+ base_template = assigned_field.default_value
483
+ if isinstance(base_template, Template):
484
+ base_template = base_template.template_str
485
+ if not isinstance(base_template, str):
486
+ raise ValueError(
487
+ f'No DEFAULT template found for {self!r}: The default '
488
+ f'value {base_template!r} of '
489
+ f'`{container_cls.__name__}.{key}` is not a '
490
+ '`lf.Template` object or str.'
491
+ )
492
+ t = Template(base_template)
493
+ # NOTE(daiyip): Set the parent of the newly created template to self so
494
+ # it could access all the contextual variables.
495
+ t.sym_setparent(self)
496
+ return t
497
+
401
498
 
402
499
  # Register converter from str to LangFunc, therefore we can always
403
500
  # pass strs to attributes that accept LangFunc.
@@ -312,6 +312,72 @@ class RenderTest(unittest.TestCase):
312
312
  'This is 1 and {{a}}',
313
313
  )
314
314
 
315
+ def test_render_with_default(self):
316
+
317
+ class Foo(Template):
318
+ """Foo.
319
+
320
+ This is {{x}}
321
+ """
322
+
323
+ f = Foo(template_str='!{{DEFAULT}}!', x=1)
324
+ self.assertEqual(f.DEFAULT.x, 1)
325
+ self.assertEqual(
326
+ f.render(), '!This is 1!'
327
+ )
328
+
329
+ class Bar(Template):
330
+ """Bar.
331
+
332
+ {{preamble}}
333
+ {{prompt}}
334
+ """
335
+
336
+ preamble: Template = Template('You are a chat bot.')
337
+ prompt: Template = Template('User: hi! {{name}}')
338
+
339
+ b = Bar(
340
+ preamble=Template('<h1>{{DEFAULT}}</h1>'),
341
+ prompt=Template('<h2>{{DEFAULT}}</h2>'),
342
+ name='Tom',
343
+ )
344
+ # Test variable access.
345
+ self.assertEqual(
346
+ b.render(),
347
+ inspect.cleandoc("""
348
+ <h1>You are a chat bot.</h1>
349
+ <h2>User: hi! Tom</h2>
350
+ """),
351
+ )
352
+
353
+ with self.assertRaisesRegex(ValueError, '`{{ DEFAULT }}` cannot be used'):
354
+
355
+ class Baz(Template): # pylint: disable=unused-variable
356
+ """Baz.
357
+
358
+ {{DEFAULT}}
359
+ """
360
+
361
+ with self.assertRaisesRegex(
362
+ ValueError, 'The template neither has a default `template_str` nor'
363
+ ):
364
+ Template('{{DEFAULT}}').render()
365
+
366
+ d = pg.Dict(x=Template('{{DEFAULT}}'))
367
+ with self.assertRaisesRegex(
368
+ ValueError, 'does not have a default value'
369
+ ):
370
+ _ = d.x.DEFAULT
371
+
372
+ class Tes(pg.Object):
373
+ x: str | None = None
374
+
375
+ t = Tes(x=Template('{{DEFAULT}}'))
376
+ with self.assertRaisesRegex(
377
+ ValueError, 'is not a `lf.Template` object or str'
378
+ ):
379
+ _ = t.x.DEFAULT
380
+
315
381
  def test_bad_render(self):
316
382
  with self.assertRaises(ValueError):
317
383
  Template('Hello {{x}}').render(allow_partial=False)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240424
3
+ Version: 0.0.2.dev20240426
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -21,6 +21,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
21
  Classifier: Topic :: Software Development :: Libraries
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
+ Requires-Dist: absl-py >=1.0.0
24
25
  Requires-Dist: google-generativeai >=0.3.2
25
26
  Requires-Dist: jinja2 >=3.1.2
26
27
  Requires-Dist: openai ==0.27.2
@@ -1,4 +1,4 @@
1
- langfun/__init__.py,sha256=3iCC7F8XoRZ7Gvus11NT50e4KDOQJxIPn9a7TlLzuVI,1880
1
+ langfun/__init__.py,sha256=zh-EYTCLxkUAIc2zMo3Lye46_CrMrhwO_GwBHZspUvE,1919
2
2
  langfun/core/__init__.py,sha256=6QEuXOZ9BXxm6TjpaMXuLwUBTYO3pkFDqn9QVBXyyPQ,4248
3
3
  langfun/core/component.py,sha256=oxesbC0BoE_TbtxwW5x-BAZWxZyyJbuPiX5S38RqCv0,9909
4
4
  langfun/core/component_test.py,sha256=uR-_Sz_42Jxc5qzLIB-f5_pXmNwnC01Xlbv5NOQSeSU,8021
@@ -6,10 +6,10 @@ langfun/core/concurrent.py,sha256=TRc49pJ3HQro2kb5FtcWkHjhBm8UcgE8RJybU5cU3-0,24
6
6
  langfun/core/concurrent_test.py,sha256=mwFMZhDUdppnDr7vDSTwcbMHwrdsIoKJwRYNtl4ZWL4,15185
7
7
  langfun/core/console.py,sha256=bk5rNPNm9rMGW5YT2HixxU04p2umnoabn5SDz6Dqe88,2317
8
8
  langfun/core/console_test.py,sha256=5SYJdxpJGLgdSSQqqMPoA1X6jpsLD8rgcyk-EgI65oE,1077
9
- langfun/core/langfunc.py,sha256=WXdTc3QsmGD_n80KD9dFRr5MHpGZ9E_y_Rhtk4t9-3w,11852
9
+ langfun/core/langfunc.py,sha256=bRujJfH4iTwKFtFxQf745uJkfltuFnPfOGLuP8ydcr4,11646
10
10
  langfun/core/langfunc_test.py,sha256=sQaKuZpGGmG80GRifhbxkj7nfzQLJKj4Vuw5y1s1K3U,8378
11
- langfun/core/language_model.py,sha256=mJfQ_Zqq9IyVyZUdYMQ1BPrpo4Gn8yxDJb_RghQFP_I,18911
12
- langfun/core/language_model_test.py,sha256=oWQjnyiJugSpHJKda-qLaSvmbm1sx_v-ZXrHvw_kNk4,14172
11
+ langfun/core/language_model.py,sha256=dypSV3kr6BLC7hsvV1_QOiqrHUHWtOjQfyFqH79WZmU,20052
12
+ langfun/core/language_model_test.py,sha256=T-itu7Li2smv2dkru0C0neCs2W4VJXlNTYahXU6jF54,19548
13
13
  langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
14
14
  langfun/core/message.py,sha256=QhvV9t5qaryPcruyxxcXi3gm9QDInkSldwTtK6sVJ3c,15734
15
15
  langfun/core/message_test.py,sha256=Z23pUM5vPnDrYkIIibe2KL73D5HKur_awI0ut_EQFQA,9501
@@ -21,8 +21,8 @@ langfun/core/sampling.py,sha256=vygWvgC8MFw0_AKNSmz-ywMXJYWf8cl0tI8QycvAmyI,5795
21
21
  langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY,3663
22
22
  langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,10930
23
23
  langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
24
- langfun/core/template.py,sha256=dr3tZCbXH2qWzigO_EFVHe0GDnnCu58Tru5Mvlzin4o,18447
25
- langfun/core/template_test.py,sha256=xty7PgdNhGpw7ZRZ6QGwhKZWG6dyRgI16Lg3p7IMLJg,13944
24
+ langfun/core/template.py,sha256=FZByYq6mhVDjT4HJ3yY-_TUZ13BiURzTJSKLw6QyLY4,21462
25
+ langfun/core/template_test.py,sha256=Mbv0dFjboGCVvbDkHD-HacZnlCi8Ku2Hpf2UjdwGSNo,15464
26
26
  langfun/core/text_formatting.py,sha256=ytjj7opnRJ6w-pkglL2CZUyfYDXLpNf65E42LBb31gc,5158
27
27
  langfun/core/text_formatting_test.py,sha256=nyKC6tn2L4hPJiqQHgxcbQsJJi4A4Nbj8FiO8iT6B80,1514
28
28
  langfun/core/coding/__init__.py,sha256=5utju_fwEsImaiftx4oXKl9FAM8p281k8-Esdh_-m1w,835
@@ -39,18 +39,18 @@ langfun/core/coding/python/parsing.py,sha256=uyvI1c5OLZhMVK2Oltkl3oJxSLlG0wadlpQ
39
39
  langfun/core/coding/python/parsing_test.py,sha256=9vAWF484kWIm6JZq8NFiMgKUDhXV-deRl1QMmNERfAA,7386
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
- langfun/core/eval/__init__.py,sha256=iDA2OcJ3kR6ixZizXIY3N9LsjkaVrfTbSClTiSP8ekY,1291
43
- langfun/core/eval/base.py,sha256=TZAmcdRBtzwMG1V3e_NgyJXg7J6dWMdMBrHvBnFuFho,55359
44
- langfun/core/eval/base_test.py,sha256=QiYSRX_Rm4HV77ggxYa1IdKpyacM2ZJzFpZjLrMdEq8,21592
45
- langfun/core/eval/matching.py,sha256=aqNlYrlav7YmsB7rUlsdfoi1RLA5CYqn2RGPxRlPc78,9599
46
- langfun/core/eval/matching_test.py,sha256=PrV9ONTzXntIxFWApajoCjmNwydBnRJE8Kvp0o6x6XY,4898
47
- langfun/core/eval/scoring.py,sha256=aKeanBJf1yO3Q9JEtgPWoiZk_3M_GiqwXVXX7x_g22w,6172
48
- langfun/core/eval/scoring_test.py,sha256=vgehbKQlouk-mDPsz5oi2kFunaOy9y6AX5d7ZukHYkg,4024
42
+ langfun/core/eval/__init__.py,sha256=NSmPe2lxdxFoY4h8VkNyONPAFtOTUpK9WhmZRaqUgiI,1335
43
+ langfun/core/eval/base.py,sha256=1svQoZ0C2DGCVLvr0Qt0TcrlJKtJptdoOBVAxkxnHoU,60264
44
+ langfun/core/eval/base_test.py,sha256=g3lRp2dcq411cLYHpn8spI4feyv2nOccs5PlFBwav3g,22512
45
+ langfun/core/eval/matching.py,sha256=Ks-L9vyMNDj4R8zFczzByT_4DK2wAFatyCZupdHzx_g,9932
46
+ langfun/core/eval/matching_test.py,sha256=5Qs9ETaLoyNcJ43f-_bK2Bfe--2Y3U79DnSA55-l6pc,4932
47
+ langfun/core/eval/scoring.py,sha256=A3y6HMcmpREQPqUD-WtImYOb2jG-23WpcUO2-WGhel0,6360
48
+ langfun/core/eval/scoring_test.py,sha256=vxJR-2rBghUDUOCLTIMd6M3i1F8xDhA-U45wuBHVfc0,4058
49
49
  langfun/core/llms/__init__.py,sha256=1bPg1QI8duOZCYINm-jWi094x0JtLmsk4KX60qIC_gs,3245
50
50
  langfun/core/llms/anthropic.py,sha256=7W9YdPN3SlAFhAIQlihMkrpo7tTY_4NvD0KIlCrqcsk,8505
51
51
  langfun/core/llms/anthropic_test.py,sha256=TMM30myyEhwF99Le4RvJEXOn8RYl0q1FRkt9Q9nl1jk,5540
52
52
  langfun/core/llms/fake.py,sha256=b-Xk5IPTbUt-elsyzd_i3n1tqzc_kgETXrEvgJruSMk,2824
53
- langfun/core/llms/fake_test.py,sha256=ZlDQgL41EX3eYTfBQNp2nB2LciqCmtoHgCsGvW4XhwI,4184
53
+ langfun/core/llms/fake_test.py,sha256=ipKfdOcuqVcJ8lDXVpnBVb9HHG0hAVkFkMoHpWjC2cI,7212
54
54
  langfun/core/llms/google_genai.py,sha256=n8zyJwh9UCTgb6-8LyvmjVNFGZQ4-zfzZ0ulkhHAnR8,8624
55
55
  langfun/core/llms/google_genai_test.py,sha256=_UcGTfl16-aDUlEWFC2W2F8y9jPUs53RBYA6MOCpGXw,7525
56
56
  langfun/core/llms/groq.py,sha256=NaGItVL_pkOpqPpI4bPGU27xLFRoaeizZ49v2s-4ERs,7844
@@ -58,7 +58,7 @@ langfun/core/llms/groq_test.py,sha256=M6GtlrsOvDun_j-sR8cPh4W_moHWZNSTiThu3kuwbb
58
58
  langfun/core/llms/llama_cpp.py,sha256=Y_KkMUf3Xfac49koMUtUslKl3h-HWp3-ntq7Jaa3bdo,2385
59
59
  langfun/core/llms/llama_cpp_test.py,sha256=ZxC6defGd_HX9SFRU9U4cJiQnBKundbOrchbXuC1Z2M,1683
60
60
  langfun/core/llms/openai.py,sha256=06nPhmw0zIA5Zqv3eqsrZtYLHnKwW7N8yt3LlFUFVpI,13247
61
- langfun/core/llms/openai_test.py,sha256=Yt_W6k8YXpT3bs0JroARofCGmn_Uq3u61LmZxqWS2DQ,8272
61
+ langfun/core/llms/openai_test.py,sha256=MiLqBaYliAkWVEwOBmX3HTj_eAuWLv77q8-I3VyVEBU,14841
62
62
  langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
63
63
  langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
64
64
  langfun/core/llms/cache/in_memory.py,sha256=YfFyJEhLs73cUiB0ZfhMxYpdE8Iuxxw-dvMFwGHTSHw,4742
@@ -73,22 +73,22 @@ langfun/core/modalities/mime.py,sha256=wVfaYflhGz1W4v3m972rAplW3OGOFtjFpHDYIaUD5
73
73
  langfun/core/modalities/mime_test.py,sha256=cVHxRvJ1QXC1SVhBmWkJdWGpL9Xl0UNfTQq6j0OGGL4,1881
74
74
  langfun/core/modalities/video.py,sha256=25M4XsNG5XEWRy57LYT_a6_aMURMPAgC41B3weEXFsY,1747
75
75
  langfun/core/modalities/video_test.py,sha256=jYuI2m8S8zDCAVBPEUbbpP205dXAht90A2_PHWo4-r8,2039
76
- langfun/core/structured/__init__.py,sha256=YJfifg66fFF5I6a-riI7T4PV4jYRmv89Ti617zsFNzo,3532
76
+ langfun/core/structured/__init__.py,sha256=zO6mdApZgWy6d2i3s_FWrjHS_-7qWnase0VRq0KhKn0,3589
77
77
  langfun/core/structured/completion.py,sha256=skBxt6V_fv2TBUKnzFgnPMbVY8HSYn8sY04MLok2yvs,7299
78
- langfun/core/structured/completion_test.py,sha256=0FJreSmz0Umsj47dIlOyCjBXUa7janIplXhg1CbLT4U,19301
78
+ langfun/core/structured/completion_test.py,sha256=MYxEzeScC3gFVujvrMMboBF5nh-QiVLwGgqAV3oaFUQ,19273
79
79
  langfun/core/structured/description.py,sha256=SXW4MJvshFjbR-0gw6rE21o6WXq12UlRXawvDBXMZFA,5211
80
80
  langfun/core/structured/description_test.py,sha256=UtZGjSFUaQ6130t1E5tcL7ODu0xIefkapb53TbnqsK8,7362
81
81
  langfun/core/structured/function_generation.py,sha256=pFgS3vcRAWiuFBol2x5Eeip3XqoudONsOpeJpWyjT3s,7479
82
82
  langfun/core/structured/function_generation_test.py,sha256=ZJI-aaGgWWszn92u7h5IZ9Pl70N2DgAGGJrIxPzsvwg,10065
83
- langfun/core/structured/mapping.py,sha256=7JInwZLmQdu7asHhC0vFLJNOCBnY-hrD6v5RQgf-xKk,11020
84
- langfun/core/structured/mapping_test.py,sha256=07DDCGbwytQHSMm7fCi5-Ly-JNgdV4ubHZq0wthX4A4,3338
83
+ langfun/core/structured/mapping.py,sha256=Vq3bQZWi4iYjcVn8D2kvPXTAm9jrQ-_1ueHLbXtGRNQ,12112
84
+ langfun/core/structured/mapping_test.py,sha256=PiXklMeIa8L6KtMi3ju7J9Y39gZy0hIGz-Oeq4A_7XE,3835
85
85
  langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGXLaD8g,11492
86
- langfun/core/structured/parsing_test.py,sha256=9rUe7ipRhltQv7y8NXgR98lBXhSVKnfRM9TSAyVdxbs,20980
87
- langfun/core/structured/prompting.py,sha256=mOmCWNVMnBk4rI7KBlEm5kmusPXoAKiWcohhzaw-s2o,7427
88
- langfun/core/structured/prompting_test.py,sha256=csOzqHRp6T3KGp7Dsm0vS-BkZdQ4ALRt09iiFNz_YmA,19945
86
+ langfun/core/structured/parsing_test.py,sha256=34wDrXaQ-EYhJLfDL8mX9K53oQMSzh5pVYdKjnESmK8,20895
87
+ langfun/core/structured/prompting.py,sha256=WICdX_figP2u98Hvg3BFSTF83nNKxM4x1STxkWe2_9Y,7925
88
+ langfun/core/structured/prompting_test.py,sha256=vslaCAUikfwOvqsKzqs_oyEacrefFsr2SWSqu6OHi3w,20813
89
89
  langfun/core/structured/schema.py,sha256=mJXirgqx3N7SA9zBO_ISHrzcV-ZRshLhnMJyCcSjGjY,25057
90
90
  langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
91
- langfun/core/structured/schema_generation_test.py,sha256=cfZyP0gHno2fXy_c9vsVdvHmqKQSfuyUsCtfO3JFmYQ,2945
91
+ langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
92
92
  langfun/core/structured/schema_test.py,sha256=yw_Uo3xJC3JA9dBDjZdkQdBGPf04e7t1oT9SZTAiSdg,22360
93
93
  langfun/core/structured/scoring.py,sha256=a3vfGnqf-DOWjD07MF54GCZTO_R1RTxTDVPzerXnU0s,2325
94
94
  langfun/core/structured/scoring_test.py,sha256=TznLMl0x9QxzmhHz_3Vr44VOXuvFnUSeRQVhu33W5cA,1437
@@ -101,8 +101,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
101
101
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
102
102
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
103
103
  langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
104
- langfun-0.0.2.dev20240424.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
105
- langfun-0.0.2.dev20240424.dist-info/METADATA,sha256=lxR47TWcPw7tXWYdgQ6rDFiCSd2B5fLo-BljSutR9IM,3405
106
- langfun-0.0.2.dev20240424.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
107
- langfun-0.0.2.dev20240424.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
108
- langfun-0.0.2.dev20240424.dist-info/RECORD,,
104
+ langfun-0.0.2.dev20240426.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
105
+ langfun-0.0.2.dev20240426.dist-info/METADATA,sha256=VIhHPTScfC_kHY3j2aCQ38CKW2BrPeSgDO37U2E2kYo,3436
106
+ langfun-0.0.2.dev20240426.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
107
+ langfun-0.0.2.dev20240426.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
108
+ langfun-0.0.2.dev20240426.dist-info/RECORD,,