langfun 0.0.2.dev20240717__py3-none-any.whl → 0.0.2.dev20240718__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.
@@ -193,6 +193,11 @@ def query(
193
193
  if isinstance(prompt, pg.Symbolic) and prompt.sym_partial and schema is None:
194
194
  schema = prompt.__class__
195
195
 
196
+ # Create a copy of the prompt if it has a parent object, so all child modality
197
+ # objects could be referred by path relative to the prompt.
198
+ if isinstance(prompt, lf.Template) and prompt.sym_parent:
199
+ prompt = prompt.clone()
200
+
196
201
  if schema in (None, str):
197
202
  # Query with natural language output.
198
203
  output = lf.LangFunc.from_value(prompt, **kwargs)(
@@ -361,6 +361,17 @@ class QueryTest(unittest.TestCase):
361
361
  """),
362
362
  )
363
363
 
364
+ def test_query_prompt_with_unrooted_template(self):
365
+ output = prompting.query_prompt(
366
+ pg.Dict(
367
+ input=lf.Template(
368
+ 'what is {{image}}',
369
+ image=modalities.Image.from_bytes(b'mock_image')
370
+ )
371
+ ).input,
372
+ )
373
+ self.assertIsNotNone(output.get_modality('image'))
374
+
364
375
  def test_query_output(self):
365
376
  self.assertEqual(
366
377
  prompting.query_output(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langfun
3
- Version: 0.0.2.dev20240717
3
+ Version: 0.0.2.dev20240718
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -100,8 +100,8 @@ langfun/core/structured/mapping.py,sha256=QKbSnvOgut-sx2mZPjHJcdlDLxR8b3ZC16ZLWo
100
100
  langfun/core/structured/mapping_test.py,sha256=PiXklMeIa8L6KtMi3ju7J9Y39gZy0hIGz-Oeq4A_7XE,3835
101
101
  langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGXLaD8g,11492
102
102
  langfun/core/structured/parsing_test.py,sha256=34wDrXaQ-EYhJLfDL8mX9K53oQMSzh5pVYdKjnESmK8,20895
103
- langfun/core/structured/prompting.py,sha256=vjmJn7GMFkqkrEB6qRrYvjB78WVx_OhsIyMN8PTb-7o,8641
104
- langfun/core/structured/prompting_test.py,sha256=W1FmbOfMXhBV8uZ3WN1fBxKLtdYngvR9l1JYo46HqJQ,22723
103
+ langfun/core/structured/prompting.py,sha256=_U6Z65AwXvVvfaQFCY9GawB_QV9S3u7P7BOU2URABmw,8873
104
+ langfun/core/structured/prompting_test.py,sha256=Yc5GevbTyxtW6FAORXiqzakcuoJF-IPjoZ8kvLJW5is,23057
105
105
  langfun/core/structured/schema.py,sha256=oiT4P4Q9pG-QOnFzxETN2EQZqNln8nG4zAJHxcmeX9U,27729
106
106
  langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
107
107
  langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
@@ -117,8 +117,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
117
117
  langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
118
118
  langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
119
119
  langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
120
- langfun-0.0.2.dev20240717.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
121
- langfun-0.0.2.dev20240717.dist-info/METADATA,sha256=Ho6QyM-oWmPyKZ5Q5S6Zh7gh1R00X_cyS-0ChbUCzRU,3550
122
- langfun-0.0.2.dev20240717.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
123
- langfun-0.0.2.dev20240717.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
124
- langfun-0.0.2.dev20240717.dist-info/RECORD,,
120
+ langfun-0.0.2.dev20240718.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
121
+ langfun-0.0.2.dev20240718.dist-info/METADATA,sha256=3IEvZ3gnn8jyj65j9IwmrW_k6T3O5KrB87IltWop59M,3550
122
+ langfun-0.0.2.dev20240718.dist-info/WHEEL,sha256=FZ75kcLy9M91ncbIgG8dnpCncbiKXSRGJ_PFILs6SFg,91
123
+ langfun-0.0.2.dev20240718.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
124
+ langfun-0.0.2.dev20240718.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (71.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5