langfun 0.0.2.dev20240528__py3-none-any.whl → 0.0.2.dev20240529__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.
Potentially problematic release.
This version of langfun might be problematic. Click here for more details.
- langfun/core/language_model_test.py +3 -2
- langfun/core/llms/google_genai_test.py +1 -1
- langfun/core/llms/openai_test.py +1 -1
- langfun/core/llms/vertexai_test.py +1 -1
- langfun/core/message.py +1 -1
- langfun/core/message_test.py +12 -9
- langfun/core/modality.py +2 -2
- langfun/core/modality_test.py +1 -1
- langfun/core/structured/completion_test.py +2 -2
- langfun/core/structured/prompting_test.py +8 -6
- langfun/core/template_test.py +1 -1
- {langfun-0.0.2.dev20240528.dist-info → langfun-0.0.2.dev20240529.dist-info}/METADATA +1 -1
- {langfun-0.0.2.dev20240528.dist-info → langfun-0.0.2.dev20240529.dist-info}/RECORD +16 -16
- {langfun-0.0.2.dev20240528.dist-info → langfun-0.0.2.dev20240529.dist-info}/LICENSE +0 -0
- {langfun-0.0.2.dev20240528.dist-info → langfun-0.0.2.dev20240529.dist-info}/WHEEL +0 -0
- {langfun-0.0.2.dev20240528.dist-info → langfun-0.0.2.dev20240529.dist-info}/top_level.txt +0 -0
@@ -418,8 +418,9 @@ class LanguageModelTest(unittest.TestCase):
|
|
418
418
|
with contextlib.redirect_stdout(string_io):
|
419
419
|
self.assertEqual(
|
420
420
|
lm(message_lib.UserMessage(
|
421
|
-
'hi
|
422
|
-
'hi
|
421
|
+
'hi <<[[image]]>>', image=Image()), debug=True),
|
422
|
+
'hi <<[[image]]>>'
|
423
|
+
)
|
423
424
|
|
424
425
|
debug_info = string_io.getvalue()
|
425
426
|
self.assertIn('[0] LM INFO', debug_info)
|
@@ -102,7 +102,7 @@ class GenAITest(unittest.TestCase):
|
|
102
102
|
|
103
103
|
def test_content_from_message_mm(self):
|
104
104
|
message = lf.UserMessage(
|
105
|
-
'This is an
|
105
|
+
'This is an <<[[image]]>>, what is it?',
|
106
106
|
image=lf_modalities.Image.from_bytes(example_image),
|
107
107
|
)
|
108
108
|
|
langfun/core/llms/openai_test.py
CHANGED
@@ -74,7 +74,7 @@ class VertexAITest(unittest.TestCase):
|
|
74
74
|
|
75
75
|
def test_content_from_message_mm(self):
|
76
76
|
message = lf.UserMessage(
|
77
|
-
'This is an
|
77
|
+
'This is an <<[[image]]>>, what is it?',
|
78
78
|
image=lf_modalities.Image.from_bytes(example_image),
|
79
79
|
)
|
80
80
|
|
langfun/core/message.py
CHANGED
@@ -144,7 +144,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
144
144
|
def from_value(cls, value: Union[str, 'Message']) -> 'Message':
|
145
145
|
"""Creates a message from a value or return value itself if a Message."""
|
146
146
|
if isinstance(value, modality.Modality):
|
147
|
-
return cls('
|
147
|
+
return cls('<<[[object]]>>', object=value)
|
148
148
|
if isinstance(value, Message):
|
149
149
|
return value
|
150
150
|
return cls(value)
|
langfun/core/message_test.py
CHANGED
@@ -54,7 +54,7 @@ class MessageTest(unittest.TestCase):
|
|
54
54
|
self.assertTrue(
|
55
55
|
pg.eq(
|
56
56
|
message.UserMessage.from_value(CustomModality('foo')),
|
57
|
-
message.UserMessage('
|
57
|
+
message.UserMessage('<<[[object]]>>', object=CustomModality('foo')),
|
58
58
|
)
|
59
59
|
)
|
60
60
|
m = message.UserMessage('hi')
|
@@ -258,13 +258,16 @@ class MessageTest(unittest.TestCase):
|
|
258
258
|
|
259
259
|
def test_referred_modalities(self):
|
260
260
|
m1 = message.UserMessage(
|
261
|
-
'hi, this is a
|
261
|
+
'hi, this is a <<[[img1]]>> and <<[[x.img2]]>>',
|
262
262
|
img1=CustomModality('foo'),
|
263
263
|
x=dict(img2=CustomModality('bar')),
|
264
264
|
)
|
265
265
|
m2 = message.SystemMessage('class Question:\n image={{img1}}', source=m1)
|
266
266
|
m3 = message.AIMessage(
|
267
|
-
|
267
|
+
(
|
268
|
+
'This is the <<[[output_image]]>> based on <<[[x.img2]]>>, '
|
269
|
+
'{{unknown_var}}'
|
270
|
+
),
|
268
271
|
output_image=CustomModality('bar'),
|
269
272
|
source=m2,
|
270
273
|
)
|
@@ -279,8 +282,8 @@ class MessageTest(unittest.TestCase):
|
|
279
282
|
def test_chunking(self):
|
280
283
|
m = message.UserMessage(
|
281
284
|
inspect.cleandoc("""
|
282
|
-
Hi, this is
|
283
|
-
|
285
|
+
Hi, this is <<[[a]]>> and this is {{b}}.
|
286
|
+
<<[[x.c]]>> {{something else
|
284
287
|
"""),
|
285
288
|
a=CustomModality('foo'),
|
286
289
|
x=dict(c=CustomModality('bar')),
|
@@ -294,7 +297,7 @@ class MessageTest(unittest.TestCase):
|
|
294
297
|
CustomModality('foo'),
|
295
298
|
'and this is {{b}}.',
|
296
299
|
CustomModality('bar'),
|
297
|
-
'
|
300
|
+
'{{something else',
|
298
301
|
],
|
299
302
|
)
|
300
303
|
)
|
@@ -304,10 +307,10 @@ class MessageTest(unittest.TestCase):
|
|
304
307
|
message.AIMessage(
|
305
308
|
inspect.cleandoc("""
|
306
309
|
Hi, this is
|
307
|
-
|
310
|
+
<<[[obj0]]>>
|
308
311
|
and this is {{b}}.
|
309
|
-
|
310
|
-
|
312
|
+
<<[[obj1]]>>
|
313
|
+
{{something else
|
311
314
|
"""),
|
312
315
|
obj0=pg.Ref(m.a),
|
313
316
|
obj1=pg.Ref(m.x.c),
|
langfun/core/modality.py
CHANGED
@@ -32,8 +32,8 @@ def format_modality_as_ref(enabled: bool = True) -> ContextManager[None]:
|
|
32
32
|
class Modality(component.Component):
|
33
33
|
"""Base class for multimodal object."""
|
34
34
|
|
35
|
-
REF_START = '
|
36
|
-
REF_END = '
|
35
|
+
REF_START = '<<[['
|
36
|
+
REF_END = ']]>>'
|
37
37
|
|
38
38
|
def format(self, *args, **kwargs) -> str:
|
39
39
|
if self.referred_name is None or not pg.object_utils.thread_local_get(
|
langfun/core/modality_test.py
CHANGED
@@ -37,7 +37,7 @@ class ModalityTest(unittest.TestCase):
|
|
37
37
|
self.assertEqual(v.referred_name, 'x.metadata.y')
|
38
38
|
self.assertEqual(str(v), "CustomModality(\n content = 'a'\n)")
|
39
39
|
with modality.format_modality_as_ref():
|
40
|
-
self.assertEqual(str(v), '
|
40
|
+
self.assertEqual(str(v), '<<[[x.metadata.y]]>>')
|
41
41
|
|
42
42
|
|
43
43
|
class ModalityRefTest(unittest.TestCase):
|
@@ -464,7 +464,7 @@ class CompleteStructureTest(unittest.TestCase):
|
|
464
464
|
|
465
465
|
MODALITY_REFERENCES:
|
466
466
|
{
|
467
|
-
'examples[0].input.image':
|
467
|
+
'examples[0].input.image': <<[[examples[0].input.image]]>>
|
468
468
|
}
|
469
469
|
|
470
470
|
OUTPUT_OBJECT:
|
@@ -490,7 +490,7 @@ class CompleteStructureTest(unittest.TestCase):
|
|
490
490
|
|
491
491
|
MODALITY_REFERENCES:
|
492
492
|
{
|
493
|
-
'input.image':
|
493
|
+
'input.image': <<[[input.image]]>>
|
494
494
|
}
|
495
495
|
|
496
496
|
OUTPUT_OBJECT:
|
@@ -208,7 +208,7 @@ class QueryTest(unittest.TestCase):
|
|
208
208
|
modalities.Image.from_bytes(b'mock_image'),
|
209
209
|
int,
|
210
210
|
lm=lm,
|
211
|
-
expected_snippet='\n\nINPUT_OBJECT:\n
|
211
|
+
expected_snippet='\n\nINPUT_OBJECT:\n <<[[input]]>>\n\n',
|
212
212
|
expected_modalities=1,
|
213
213
|
)
|
214
214
|
|
@@ -218,7 +218,7 @@ class QueryTest(unittest.TestCase):
|
|
218
218
|
modalities.Image.from_bytes(b'mock_image'),
|
219
219
|
None,
|
220
220
|
lm=lm,
|
221
|
-
expected_snippet='
|
221
|
+
expected_snippet='<<[[input]]>>',
|
222
222
|
exact_match=True,
|
223
223
|
expected_modalities=1,
|
224
224
|
)
|
@@ -231,7 +231,9 @@ class QueryTest(unittest.TestCase):
|
|
231
231
|
this_image=modalities.Image.from_bytes(b'cat_image'),
|
232
232
|
that_image=modalities.Image.from_bytes(b'mouse_image'),
|
233
233
|
lm=lm,
|
234
|
-
expected_snippet=
|
234
|
+
expected_snippet=(
|
235
|
+
'What are these? <<[[this_image]]>> and <<[[that_image]]>>'
|
236
|
+
),
|
235
237
|
exact_match=True,
|
236
238
|
expected_modalities=2,
|
237
239
|
)
|
@@ -245,7 +247,7 @@ class QueryTest(unittest.TestCase):
|
|
245
247
|
],
|
246
248
|
None,
|
247
249
|
lm=lm,
|
248
|
-
expected_snippet='`[
|
250
|
+
expected_snippet='`[<<[[input[0]]]>>, <<[[input[1]]]>>]`',
|
249
251
|
exact_match=True,
|
250
252
|
expected_modalities=2,
|
251
253
|
)
|
@@ -274,8 +276,8 @@ class QueryTest(unittest.TestCase):
|
|
274
276
|
|
275
277
|
MODALITY_REFERENCES:
|
276
278
|
{
|
277
|
-
'input[0]':
|
278
|
-
'input[1]':
|
279
|
+
'input[0]': <<[[input[0]]]>>,
|
280
|
+
'input[1]': <<[[input[1]]]>>
|
279
281
|
}
|
280
282
|
"""),
|
281
283
|
expected_modalities=2,
|
langfun/core/template_test.py
CHANGED
@@ -9,12 +9,12 @@ langfun/core/console_test.py,sha256=5SYJdxpJGLgdSSQqqMPoA1X6jpsLD8rgcyk-EgI65oE,
|
|
9
9
|
langfun/core/langfunc.py,sha256=RvIcRjIq0jWYRu1xim-FYe4HSrt97r3GMBO_PuagUmw,11060
|
10
10
|
langfun/core/langfunc_test.py,sha256=_mfARnakX3oji5HDigFSLMd6yQ2wma-2Mgbztwqn73g,8501
|
11
11
|
langfun/core/language_model.py,sha256=owNCgefGoPeRCHrxBhMtNdOj3orbeVml4eqLf1n211o,20760
|
12
|
-
langfun/core/language_model_test.py,sha256=
|
12
|
+
langfun/core/language_model_test.py,sha256=NZaSUls6cZdtxiqkqumWbtkx9zgNiJlsviYZOWkuHig,20137
|
13
13
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
14
|
-
langfun/core/message.py,sha256=
|
15
|
-
langfun/core/message_test.py,sha256=
|
16
|
-
langfun/core/modality.py,sha256
|
17
|
-
langfun/core/modality_test.py,sha256=
|
14
|
+
langfun/core/message.py,sha256=Rw3yC9HyGRjMhfDgyNjGlSCALEyDDbJ0_o6qTXeeDiQ,15738
|
15
|
+
langfun/core/message_test.py,sha256=b6DDRoQ5j3uK-dc0QPSLelNTKaXX10MxJrRiI61iGX4,9574
|
16
|
+
langfun/core/modality.py,sha256=-BZDYf5d4bmZnhZyS4QVGTSwvU7Xgs_55IOzeRmyacE,3378
|
17
|
+
langfun/core/modality_test.py,sha256=HyZ5xONKQ0Fw18SzoWAq-Ob9njOXIIjBo1hNtw-rudw,2400
|
18
18
|
langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPeloE,1177
|
19
19
|
langfun/core/natural_language_test.py,sha256=LHGU_1ytbkGuSZQFIFP7vP3dBlcY4-A12fT6dbjUA0E,1424
|
20
20
|
langfun/core/sampling.py,sha256=vygWvgC8MFw0_AKNSmz-ywMXJYWf8cl0tI8QycvAmyI,5795
|
@@ -22,7 +22,7 @@ langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY
|
|
22
22
|
langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,10930
|
23
23
|
langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
|
24
24
|
langfun/core/template.py,sha256=UhNNGUDJ4StUhPBKzHmjym36khxHOGWGr9MDxBwgxQA,22284
|
25
|
-
langfun/core/template_test.py,sha256=
|
25
|
+
langfun/core/template_test.py,sha256=cb005qM_3dvJikaPDB3rirfIrMAIIVRpoiXGREGJ43o,15468
|
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
|
@@ -54,15 +54,15 @@ langfun/core/llms/anthropic_test.py,sha256=TMM30myyEhwF99Le4RvJEXOn8RYl0q1FRkt9Q
|
|
54
54
|
langfun/core/llms/fake.py,sha256=Dd7-6ka9pFf3fcWZyczamjOqQ91MOI-m7We3Oc9Ffmo,2927
|
55
55
|
langfun/core/llms/fake_test.py,sha256=ipKfdOcuqVcJ8lDXVpnBVb9HHG0hAVkFkMoHpWjC2cI,7212
|
56
56
|
langfun/core/llms/google_genai.py,sha256=H1GdarpoMb9RjQz7a4BqVF6loQf3S_mMv8G8TFYrCvw,8999
|
57
|
-
langfun/core/llms/google_genai_test.py,sha256=
|
57
|
+
langfun/core/llms/google_genai_test.py,sha256=VT_MMmyxHMe4sl4uK_UZzWyxKFFMlF3xc3v6SljJQE0,7529
|
58
58
|
langfun/core/llms/groq.py,sha256=NaGItVL_pkOpqPpI4bPGU27xLFRoaeizZ49v2s-4ERs,7844
|
59
59
|
langfun/core/llms/groq_test.py,sha256=M6GtlrsOvDun_j-sR8cPh4W_moHWZNSTiThu3kuwbbc,5281
|
60
60
|
langfun/core/llms/llama_cpp.py,sha256=Y_KkMUf3Xfac49koMUtUslKl3h-HWp3-ntq7Jaa3bdo,2385
|
61
61
|
langfun/core/llms/llama_cpp_test.py,sha256=ZxC6defGd_HX9SFRU9U4cJiQnBKundbOrchbXuC1Z2M,1683
|
62
62
|
langfun/core/llms/openai.py,sha256=IN46gIqfY6aEEfxCPNmyH1hrep3oWBhJDwVFilfqNkM,13657
|
63
|
-
langfun/core/llms/openai_test.py,sha256=
|
63
|
+
langfun/core/llms/openai_test.py,sha256=QWDzTgi8F2Z9u9ip6alK4rDEp_YraVTxWlDX5XOsKJk,14858
|
64
64
|
langfun/core/llms/vertexai.py,sha256=rrwHRtox-gayVBjrkR_lnko98b0iFIyxsRUPgB_09T8,9921
|
65
|
-
langfun/core/llms/vertexai_test.py,sha256=
|
65
|
+
langfun/core/llms/vertexai_test.py,sha256=PbkUTVYgbFhg5lDd3HgBJM0kr-OLVz10iph2C-SJblk,7645
|
66
66
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
67
67
|
langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
|
68
68
|
langfun/core/llms/cache/in_memory.py,sha256=YfFyJEhLs73cUiB0ZfhMxYpdE8Iuxxw-dvMFwGHTSHw,4742
|
@@ -81,7 +81,7 @@ langfun/core/modalities/video.py,sha256=6qADCwwv-pEtzxMs_1YvhWgX6NqTsjviQv6IZxQP
|
|
81
81
|
langfun/core/modalities/video_test.py,sha256=GbsoefSeO7y8kCYhTtp4s9E3ah_eYrb6Z-MXpS01RFc,2046
|
82
82
|
langfun/core/structured/__init__.py,sha256=Qg1ocwsb60od8fJky3F3JAOhwjwT9WA7IX3C2j2s3zA,3707
|
83
83
|
langfun/core/structured/completion.py,sha256=skBxt6V_fv2TBUKnzFgnPMbVY8HSYn8sY04MLok2yvs,7299
|
84
|
-
langfun/core/structured/completion_test.py,sha256=
|
84
|
+
langfun/core/structured/completion_test.py,sha256=2mUzDMKGF_WGfTtsnfmfMDx97dkJ-98y8leen__qWLA,19281
|
85
85
|
langfun/core/structured/description.py,sha256=SXW4MJvshFjbR-0gw6rE21o6WXq12UlRXawvDBXMZFA,5211
|
86
86
|
langfun/core/structured/description_test.py,sha256=UtZGjSFUaQ6130t1E5tcL7ODu0xIefkapb53TbnqsK8,7362
|
87
87
|
langfun/core/structured/function_generation.py,sha256=pFgS3vcRAWiuFBol2x5Eeip3XqoudONsOpeJpWyjT3s,7479
|
@@ -91,7 +91,7 @@ langfun/core/structured/mapping_test.py,sha256=PiXklMeIa8L6KtMi3ju7J9Y39gZy0hIGz
|
|
91
91
|
langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGXLaD8g,11492
|
92
92
|
langfun/core/structured/parsing_test.py,sha256=34wDrXaQ-EYhJLfDL8mX9K53oQMSzh5pVYdKjnESmK8,20895
|
93
93
|
langfun/core/structured/prompting.py,sha256=cswl9c93edsYnXsZQmMzPpmqOuKnBzbgebTYBbSxwzo,8815
|
94
|
-
langfun/core/structured/prompting_test.py,sha256=
|
94
|
+
langfun/core/structured/prompting_test.py,sha256=8orqsTVDpDb_7oFZtGHtV_zRU_j_9RaOGH1QR8IurIU,21756
|
95
95
|
langfun/core/structured/schema.py,sha256=HDb6N7zB4z83kUYW4-ic84QgIHKpR4LZCivMeALDBVo,25967
|
96
96
|
langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
|
97
97
|
langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
|
@@ -107,8 +107,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
107
107
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
108
108
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
109
109
|
langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
|
110
|
-
langfun-0.0.2.
|
111
|
-
langfun-0.0.2.
|
112
|
-
langfun-0.0.2.
|
113
|
-
langfun-0.0.2.
|
114
|
-
langfun-0.0.2.
|
110
|
+
langfun-0.0.2.dev20240529.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
111
|
+
langfun-0.0.2.dev20240529.dist-info/METADATA,sha256=ZN0dC6pIlryIYt3Ky_clS5em_0DJVzj08ckp3gmyca8,3452
|
112
|
+
langfun-0.0.2.dev20240529.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
113
|
+
langfun-0.0.2.dev20240529.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
114
|
+
langfun-0.0.2.dev20240529.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|