langfun 0.1.2.dev202409240804__py3-none-any.whl → 0.1.2.dev202409260804__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/matching.py +9 -2
- langfun/core/modality.py +7 -0
- langfun/core/repr_utils.py +9 -2
- {langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/RECORD +8 -8
- {langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/top_level.txt +0 -0
langfun/core/eval/matching.py
CHANGED
@@ -266,20 +266,27 @@ class Matching(base.Evaluation):
|
|
266
266
|
'<td>Prompt/Response Chain</td>'
|
267
267
|
'</tr>'
|
268
268
|
)
|
269
|
+
def _maybe_html(v, root_indent: int):
|
270
|
+
del root_indent
|
271
|
+
if hasattr(v, '_repr_html_'):
|
272
|
+
return v._repr_html_() # pylint: disable=protected-access
|
273
|
+
# Fall back to the default format.
|
274
|
+
return None
|
275
|
+
|
269
276
|
for i, (example, output, message) in enumerate(self.matches):
|
270
277
|
bgcolor = 'white' if i % 2 == 0 else '#DDDDDD'
|
271
278
|
s.write(f'<tr style="background-color: {bgcolor}"><td>{i + 1}</td>')
|
272
279
|
input_str = lf.repr_utils.escape_quoted(
|
273
280
|
pg.format(
|
274
281
|
example, verbose=False, max_bytes_len=32,
|
275
|
-
custom_format=
|
282
|
+
custom_format=_maybe_html
|
276
283
|
)
|
277
284
|
)
|
278
285
|
s.write(f'<td style="color:green;white-space:pre-wrap">{input_str}</td>')
|
279
286
|
output_str = lf.repr_utils.escape_quoted(
|
280
287
|
pg.format(
|
281
288
|
output, verbose=False, max_bytes_len=32,
|
282
|
-
custom_format=
|
289
|
+
custom_format=_maybe_html
|
283
290
|
)
|
284
291
|
)
|
285
292
|
s.write(f'<td style="color:blue;white-space:pre-wrap">{output_str}</td>')
|
langfun/core/modality.py
CHANGED
@@ -49,6 +49,13 @@ class Modality(component.Component):
|
|
49
49
|
return super().format(*args, **kwargs)
|
50
50
|
return Modality.text_marker(self.referred_name)
|
51
51
|
|
52
|
+
def __str_kwargs__(self) -> dict[str, Any]:
|
53
|
+
# For modality objects, we don't want to use markdown format when they
|
54
|
+
# are rendered as parts of the prompt.
|
55
|
+
kwargs = super().__str_kwargs__()
|
56
|
+
kwargs.pop('markdown', None)
|
57
|
+
return kwargs
|
58
|
+
|
52
59
|
@abc.abstractmethod
|
53
60
|
def to_bytes(self) -> bytes:
|
54
61
|
"""Returns content in bytes."""
|
langfun/core/repr_utils.py
CHANGED
@@ -121,8 +121,15 @@ def html_repr(
|
|
121
121
|
s.write('<table style="border-top: 1px solid #EEEEEE;">')
|
122
122
|
item_color = item_color or (lambda k, v: (None, '#F1C40F', None, None))
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
def maybe_html_format(v: Any, root_indent: int) -> str | None:
|
125
|
+
del root_indent
|
126
|
+
if hasattr(v, '_repr_html_'):
|
127
|
+
return v._repr_html_() # pylint: disable=protected-access
|
128
|
+
# Fall back to the default format.
|
129
|
+
return None
|
130
|
+
|
131
|
+
with (pg.str_format(custom_format=maybe_html_format),
|
132
|
+
pg.repr_format(custom_format=maybe_html_format)):
|
126
133
|
for k, v in pg.object_utils.flatten(value).items():
|
127
134
|
if isinstance(v, pg.Ref):
|
128
135
|
v = v.value
|
@@ -15,11 +15,11 @@ langfun/core/logging_test.py,sha256=poSsNGKi6G9LWOcWnTY0BQjj0BtaQknH-NK6FcQrVT4,
|
|
15
15
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
16
16
|
langfun/core/message.py,sha256=7UOxNMA1Le0ZGkleryqwXcWojZ-l_hku5Sc58BsIOGw,18586
|
17
17
|
langfun/core/message_test.py,sha256=2o4WvE-WL67OsVY-O5g__67OIJ73vvg6MuojSc2uVRs,12504
|
18
|
-
langfun/core/modality.py,sha256=
|
18
|
+
langfun/core/modality.py,sha256=hC0LF8EGCU2GJxTNbfzR441oOk2-HnHnAVWbwkLG0bI,4133
|
19
19
|
langfun/core/modality_test.py,sha256=7SwhixFME2Q1sIXRgJx97EZFiIyC31A9NVr6_nDtFv4,2441
|
20
20
|
langfun/core/natural_language.py,sha256=3ynSnaYQnjE60LIPK5fyMgdIjubnPYZwzGq4rWPeloE,1177
|
21
21
|
langfun/core/natural_language_test.py,sha256=LHGU_1ytbkGuSZQFIFP7vP3dBlcY4-A12fT6dbjUA0E,1424
|
22
|
-
langfun/core/repr_utils.py,sha256=
|
22
|
+
langfun/core/repr_utils.py,sha256=yyc2xeK8sKQOOLcxwIV9E50Wf-B0TjXrnS07tSx_ea8,6491
|
23
23
|
langfun/core/repr_utils_test.py,sha256=ULG7gvgoyqQFWi0m6g2-E0GorNEr1nnZ0J_sZVQKz80,3036
|
24
24
|
langfun/core/sampling.py,sha256=vygWvgC8MFw0_AKNSmz-ywMXJYWf8cl0tI8QycvAmyI,5795
|
25
25
|
langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY,3663
|
@@ -46,7 +46,7 @@ langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg
|
|
46
46
|
langfun/core/eval/__init__.py,sha256=Ogdr9OtTywhhLPHi3AZzOD2mXX2oyaHWflrSTMm96uA,1899
|
47
47
|
langfun/core/eval/base.py,sha256=4GX9kBbgzNPxa5G9n_b6tYSMqz4qFEdio-FMdd3q68A,74898
|
48
48
|
langfun/core/eval/base_test.py,sha256=iL-EEGnBD_HigClBwo34HVyOycupgw9r4S61eIZMShI,26929
|
49
|
-
langfun/core/eval/matching.py,sha256=
|
49
|
+
langfun/core/eval/matching.py,sha256=8p1W_sA0I3XpRgw7Rf8Jbko_Ym-JAALeM2wpSmu4jKQ,10063
|
50
50
|
langfun/core/eval/matching_test.py,sha256=f7iVyXH5KGJBWt4Wp14Bt9J3X59A6Ayfog9MbuFvPew,5532
|
51
51
|
langfun/core/eval/patching.py,sha256=R0s2eAd1m97exQt06dmUL0V_MBG0W2Hxg7fhNB7cXW0,3866
|
52
52
|
langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrCG1L6w,4775
|
@@ -119,8 +119,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
119
119
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
120
120
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
121
121
|
langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
|
122
|
-
langfun-0.1.2.
|
123
|
-
langfun-0.1.2.
|
124
|
-
langfun-0.1.2.
|
125
|
-
langfun-0.1.2.
|
126
|
-
langfun-0.1.2.
|
122
|
+
langfun-0.1.2.dev202409260804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
123
|
+
langfun-0.1.2.dev202409260804.dist-info/METADATA,sha256=SpKDemUW6pUQaAVReLibrxQJoXvGsRkCXJVlPAqh-YM,8890
|
124
|
+
langfun-0.1.2.dev202409260804.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
125
|
+
langfun-0.1.2.dev202409260804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
126
|
+
langfun-0.1.2.dev202409260804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202409240804.dist-info → langfun-0.1.2.dev202409260804.dist-info}/top_level.txt
RENAMED
File without changes
|