langfun 0.1.2.dev202411030804__py3-none-any.whl → 0.1.2.dev202411050804__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/component.py +7 -4
- langfun/core/logging.py +4 -4
- langfun/core/message.py +11 -7
- langfun/core/modality.py +1 -1
- langfun/core/structured/mapping.py +3 -1
- langfun/core/structured/schema.py +5 -2
- langfun/core/template.py +2 -1
- {langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/RECORD +12 -12
- {langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/top_level.txt +0 -0
langfun/core/component.py
CHANGED
@@ -253,7 +253,9 @@ def _get_scoped_value(
|
|
253
253
|
return scoped_values.get(var_name, default)
|
254
254
|
|
255
255
|
|
256
|
-
class ContextualAttribute(
|
256
|
+
class ContextualAttribute(
|
257
|
+
pg.symbolic.ValueFromParentChain, pg.views.HtmlTreeView.Extension
|
258
|
+
):
|
257
259
|
"""Attributes whose values are inferred from the context of the component.
|
258
260
|
|
259
261
|
Please see go/langfun-component#attribute-value-retrieval for details.
|
@@ -290,8 +292,8 @@ class ContextualAttribute(pg.symbolic.ValueFromParentChain):
|
|
290
292
|
self,
|
291
293
|
*,
|
292
294
|
view: pg.views.HtmlTreeView,
|
293
|
-
parent: Any,
|
294
|
-
root_path: pg.KeyPath,
|
295
|
+
parent: Any = None,
|
296
|
+
root_path: pg.KeyPath | None = None,
|
295
297
|
**kwargs,
|
296
298
|
) -> pg.Html:
|
297
299
|
inferred_value = pg.MISSING_VALUE
|
@@ -301,7 +303,8 @@ class ContextualAttribute(pg.symbolic.ValueFromParentChain):
|
|
301
303
|
if inferred_value is not pg.MISSING_VALUE:
|
302
304
|
kwargs.pop('name', None)
|
303
305
|
return view.render(
|
304
|
-
inferred_value, parent=self,
|
306
|
+
inferred_value, parent=self,
|
307
|
+
root_path=pg.KeyPath('<inferred>', root_path),
|
305
308
|
**view.get_passthrough_kwargs(**kwargs)
|
306
309
|
)
|
307
310
|
return pg.Html.element(
|
langfun/core/logging.py
CHANGED
@@ -43,7 +43,7 @@ def get_log_level() -> LogLevel:
|
|
43
43
|
return component.context_value('__event_log_level__', 'info')
|
44
44
|
|
45
45
|
|
46
|
-
class LogEntry(pg.Object):
|
46
|
+
class LogEntry(pg.Object, pg.views.HtmlTreeView.Extension):
|
47
47
|
"""Event log entry."""
|
48
48
|
time: datetime.datetime
|
49
49
|
level: LogLevel
|
@@ -60,7 +60,7 @@ class LogEntry(pg.Object):
|
|
60
60
|
title: str | pg.Html | None = None,
|
61
61
|
max_summary_len_for_str: int = 80,
|
62
62
|
**kwargs
|
63
|
-
|
63
|
+
) -> pg.Html | None:
|
64
64
|
if len(self.message) > max_summary_len_for_str:
|
65
65
|
message = self.message[:max_summary_len_for_str] + '...'
|
66
66
|
else:
|
@@ -89,7 +89,7 @@ class LogEntry(pg.Object):
|
|
89
89
|
def _html_tree_view_content(
|
90
90
|
self,
|
91
91
|
view: pg.views.HtmlTreeView,
|
92
|
-
root_path: pg.KeyPath,
|
92
|
+
root_path: pg.KeyPath | None = None,
|
93
93
|
max_summary_len_for_str: int = 80,
|
94
94
|
collapse_level: int | None = 1,
|
95
95
|
extra_flags: dict[str, Any] | None = None,
|
@@ -118,7 +118,7 @@ class LogEntry(pg.Object):
|
|
118
118
|
view.render(
|
119
119
|
self.metadata,
|
120
120
|
name='metadata',
|
121
|
-
root_path=
|
121
|
+
root_path=pg.KeyPath('metadata', root_path),
|
122
122
|
parent=self,
|
123
123
|
collapse_level=view.get_collapse_level(
|
124
124
|
(collapse_level, -1), collapse_log_metadata_level,
|
langfun/core/message.py
CHANGED
@@ -23,7 +23,11 @@ from langfun.core import natural_language
|
|
23
23
|
import pyglove as pg
|
24
24
|
|
25
25
|
|
26
|
-
class Message(
|
26
|
+
class Message(
|
27
|
+
natural_language.NaturalLanguageFormattable,
|
28
|
+
pg.Object,
|
29
|
+
pg.views.HtmlTreeView.Extension
|
30
|
+
):
|
27
31
|
"""Message.
|
28
32
|
|
29
33
|
``Message`` is the protocol for users and the system to interact with
|
@@ -511,7 +515,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
511
515
|
self,
|
512
516
|
*,
|
513
517
|
view: pg.views.HtmlTreeView,
|
514
|
-
root_path: pg.KeyPath,
|
518
|
+
root_path: pg.KeyPath | None = None,
|
515
519
|
collapse_level: int | None = None,
|
516
520
|
extra_flags: dict[str, Any] | None = None,
|
517
521
|
**kwargs,
|
@@ -582,7 +586,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
582
586
|
s.write(s.escape(chunk))
|
583
587
|
else:
|
584
588
|
assert isinstance(chunk, modality.Modality), chunk
|
585
|
-
child_path =
|
589
|
+
child_path = pg.KeyPath(['metadata', chunk.referred_name], root_path)
|
586
590
|
s.write(
|
587
591
|
pg.Html.element(
|
588
592
|
'div',
|
@@ -610,7 +614,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
610
614
|
def render_result():
|
611
615
|
if 'result' not in self.metadata:
|
612
616
|
return None
|
613
|
-
child_path =
|
617
|
+
child_path = pg.KeyPath(['metadata', 'result'], root_path)
|
614
618
|
return pg.Html.element(
|
615
619
|
'div',
|
616
620
|
[
|
@@ -632,7 +636,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
632
636
|
def render_usage():
|
633
637
|
if 'usage' not in self.metadata:
|
634
638
|
return None
|
635
|
-
child_path =
|
639
|
+
child_path = pg.KeyPath(['metadata', 'usage'], root_path)
|
636
640
|
return pg.Html.element(
|
637
641
|
'div',
|
638
642
|
[
|
@@ -661,7 +665,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
661
665
|
and not source.has_tag(source_tag)):
|
662
666
|
source = source.source
|
663
667
|
if source is not None:
|
664
|
-
child_path =
|
668
|
+
child_path = pg.KeyPath('source', root_path)
|
665
669
|
child_extra_flags = extra_flags.copy()
|
666
670
|
child_extra_flags['collapse_source_message_level'] = (
|
667
671
|
view.get_collapse_level(
|
@@ -684,7 +688,7 @@ class Message(natural_language.NaturalLanguageFormattable, pg.Object):
|
|
684
688
|
def render_metadata():
|
685
689
|
if not include_message_metadata:
|
686
690
|
return None
|
687
|
-
child_path =
|
691
|
+
child_path = pg.KeyPath('metadata', root_path)
|
688
692
|
return pg.Html.element(
|
689
693
|
'div',
|
690
694
|
[
|
langfun/core/modality.py
CHANGED
@@ -31,7 +31,7 @@ def format_modality_as_ref(enabled: bool = True) -> ContextManager[None]:
|
|
31
31
|
)
|
32
32
|
|
33
33
|
|
34
|
-
class Modality(component.Component):
|
34
|
+
class Modality(component.Component, pg.views.HtmlTreeView.Extension):
|
35
35
|
"""Base class for multimodal object."""
|
36
36
|
|
37
37
|
REF_START = '<<[['
|
@@ -59,7 +59,9 @@ class MappingError(Exception): # pylint: disable=g-bad-exception-name
|
|
59
59
|
|
60
60
|
|
61
61
|
@pg.use_init_args(['input', 'output', 'schema', 'context'])
|
62
|
-
class MappingExample(lf.NaturalLanguageFormattable,
|
62
|
+
class MappingExample(lf.NaturalLanguageFormattable,
|
63
|
+
lf.Component,
|
64
|
+
pg.views.HtmlTreeView.Extension):
|
63
65
|
"""Mapping example between text, schema and structured value."""
|
64
66
|
|
65
67
|
input: pg.typing.Annotated[
|
@@ -110,7 +110,11 @@ class SchemaError(Exception): # pylint: disable=g-bad-exception-name
|
|
110
110
|
return r.getvalue()
|
111
111
|
|
112
112
|
|
113
|
-
class Schema(
|
113
|
+
class Schema(
|
114
|
+
lf.NaturalLanguageFormattable,
|
115
|
+
pg.Object,
|
116
|
+
pg.views.HtmlTreeView.Extension
|
117
|
+
):
|
114
118
|
"""Base class for structured data schema."""
|
115
119
|
|
116
120
|
spec: pg.typing.Annotated[
|
@@ -193,7 +197,6 @@ class Schema(lf.NaturalLanguageFormattable, pg.Object):
|
|
193
197
|
self,
|
194
198
|
*,
|
195
199
|
view: pg.views.HtmlTreeView,
|
196
|
-
root_path: pg.KeyPath,
|
197
200
|
**kwargs,
|
198
201
|
):
|
199
202
|
return pg.Html.element(
|
langfun/core/template.py
CHANGED
@@ -47,6 +47,7 @@ class Template(
|
|
47
47
|
natural_language.NaturalLanguageFormattable,
|
48
48
|
component.Component,
|
49
49
|
pg.typing.CustomTyping,
|
50
|
+
pg.views.HtmlTreeView.Extension
|
50
51
|
):
|
51
52
|
"""Langfun string template.
|
52
53
|
|
@@ -530,7 +531,7 @@ class Template(
|
|
530
531
|
self,
|
531
532
|
*,
|
532
533
|
view: pg.views.HtmlTreeView,
|
533
|
-
root_path: pg.KeyPath,
|
534
|
+
root_path: pg.KeyPath | None = None,
|
534
535
|
collapse_level: int | None = None,
|
535
536
|
extra_flags: dict[str, Any] | None = None,
|
536
537
|
debug: bool = False,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
langfun/__init__.py,sha256=mCES7t3R7Z-ZQYvG38-yrVqZubrXNfGCa8tI5HGB7mE,2274
|
2
2
|
langfun/core/__init__.py,sha256=xlvFTXc7IKUTs8aCFRFhzOLTmmeuhXgk9yx2InBLNiA,4937
|
3
|
-
langfun/core/component.py,sha256=
|
3
|
+
langfun/core/component.py,sha256=HVrEoTL1Y01iqOHC3FYdbAOnffqfHHtGJXoK1vkdEwo,11583
|
4
4
|
langfun/core/component_test.py,sha256=sG-T2wpvBfHqWGZE7sc4NayJj2aj5QFBzSwFiwrGEIc,10376
|
5
5
|
langfun/core/concurrent.py,sha256=QMNYhB_PyjvVJtabMokpzotZRYvyE9iYu2QsgwDk7M4,29552
|
6
6
|
langfun/core/concurrent_test.py,sha256=ILlAjfhV84yJfY1QLe3N9aYry1sCjY-ywfIlXGafenI,17336
|
@@ -10,12 +10,12 @@ langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,1114
|
|
10
10
|
langfun/core/langfunc_test.py,sha256=fKIAqcSNI_7M6nwoZW77HEam8Oa6vcWhsCNgVJanzb4,8822
|
11
11
|
langfun/core/language_model.py,sha256=jOvWyiKvcv2yJGBNPWmxV8wyzuWnCcrc1FhldYBtPkE,30219
|
12
12
|
langfun/core/language_model_test.py,sha256=cgoSdKwicnvHYo-tQeTdONXAVM-bvWLzgTlqxvace-A,28424
|
13
|
-
langfun/core/logging.py,sha256=
|
13
|
+
langfun/core/logging.py,sha256=uslllP0RTGN223oro1m4nZZ0bFppcL07OwbFKm2iG6k,7519
|
14
14
|
langfun/core/logging_test.py,sha256=b5bPTSUoYeICATaO6I8dOVumodwRbxSp1Oz96Sf3KcE,6104
|
15
15
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
16
|
-
langfun/core/message.py,sha256=
|
16
|
+
langfun/core/message.py,sha256=awwQW19zonvNmutXBjgCv7Oq4EcGGNfMknHMn2a0rrY,25708
|
17
17
|
langfun/core/message_test.py,sha256=HaJ7zB0rtB_RF8mOfXH18csIViP8_QY12GD6ZV7k3H0,32603
|
18
|
-
langfun/core/modality.py,sha256=
|
18
|
+
langfun/core/modality.py,sha256=K8pUGuMpfWcOtVcXC_OqVjro1-RhHF6ddQni61DuYzM,4166
|
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
|
@@ -25,7 +25,7 @@ langfun/core/sampling.py,sha256=SCnS5PFJWNVxSKvSkSCNRUmruvScun8UcNN4gafuXcw,5866
|
|
25
25
|
langfun/core/sampling_test.py,sha256=U7PANpMsl9E_pa4_Y4FzesSjcwg-u-LKHGCWSgv-8FY,3663
|
26
26
|
langfun/core/subscription.py,sha256=euawEuSZP-BHydaT-AQpfYFL0m5pWPGcW0upFhrojqc,10930
|
27
27
|
langfun/core/subscription_test.py,sha256=Y4ZdbZEwm83YNZBxHff0QR4QUa4rdaNXA3_jfIcArBo,8717
|
28
|
-
langfun/core/template.py,sha256=
|
28
|
+
langfun/core/template.py,sha256=_Sae_WsRo_yvwul0nqAPTOa0NOjW1zNYbW0CQpvg7l0,25389
|
29
29
|
langfun/core/template_test.py,sha256=Qokz1hQFhRYaTZWBWGqvPJ0NXC9B9ennUpnRYHEf0hE,20542
|
30
30
|
langfun/core/text_formatting.py,sha256=d7t9vaY6aCn1dkfkikpNYnBy5E_i93vHbfyDWFclGZU,5284
|
31
31
|
langfun/core/text_formatting_test.py,sha256=ck0Xzdd4YF4CtCUj7VE0GybfbAyKQ8p3xkM1FBGrqIk,2096
|
@@ -96,13 +96,13 @@ langfun/core/structured/description.py,sha256=SXW4MJvshFjbR-0gw6rE21o6WXq12UlRXa
|
|
96
96
|
langfun/core/structured/description_test.py,sha256=UtZGjSFUaQ6130t1E5tcL7ODu0xIefkapb53TbnqsK8,7362
|
97
97
|
langfun/core/structured/function_generation.py,sha256=pFgS3vcRAWiuFBol2x5Eeip3XqoudONsOpeJpWyjT3s,7479
|
98
98
|
langfun/core/structured/function_generation_test.py,sha256=ZJI-aaGgWWszn92u7h5IZ9Pl70N2DgAGGJrIxPzsvwg,10065
|
99
|
-
langfun/core/structured/mapping.py,sha256=
|
99
|
+
langfun/core/structured/mapping.py,sha256=vLKH79UT-j0qkQdvqlQBO7SkXXuM-yr2Idm8_HH8qwM,13649
|
100
100
|
langfun/core/structured/mapping_test.py,sha256=bHm2ZCXBITq_G8Lvw_olFHeUUc4s_lGXZm9v9JhoPB4,9630
|
101
101
|
langfun/core/structured/parsing.py,sha256=D58wBWOC6r6DCJNychCDkiHPrsy1XJfBDCDDZtug00k,11765
|
102
102
|
langfun/core/structured/parsing_test.py,sha256=i0i090FVgM8ngGqYjds0hjEm1v7q4gv18k-z1kaNr7E,21467
|
103
103
|
langfun/core/structured/prompting.py,sha256=huwwh01AQQCwPBQESOMI_V1V5PZkVQ8C89Yjk67_4Uw,10677
|
104
104
|
langfun/core/structured/prompting_test.py,sha256=pviyb8yTnxkWPAZodLIlQT8y2ScE6FfSHKWf1NUtV-Y,26718
|
105
|
-
langfun/core/structured/schema.py,sha256=
|
105
|
+
langfun/core/structured/schema.py,sha256=XHA-m_ENT_J0k8Q7WCiCL51xm7oXHOqskhO8RpPIurc,28174
|
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
|
108
108
|
langfun/core/structured/schema_test.py,sha256=RjYhwTgktQgyqAjzLvo967nTiIK9KWgP-aNGg4e7ihE,25258
|
@@ -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=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
|
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.dev202411050804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
123
|
+
langfun-0.1.2.dev202411050804.dist-info/METADATA,sha256=_8_wvN5LF-XFde3PL2AjWXFNa_SMN8mdcuvqlBL6j04,8890
|
124
|
+
langfun-0.1.2.dev202411050804.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
125
|
+
langfun-0.1.2.dev202411050804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
126
|
+
langfun-0.1.2.dev202411050804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202411030804.dist-info → langfun-0.1.2.dev202411050804.dist-info}/top_level.txt
RENAMED
File without changes
|