From 22663e96a97e5cfa35675bd99bda9bfd01864fe6 Mon Sep 17 00:00:00 2001 From: Daiyi Peng Date: Fri, 6 Oct 2023 12:11:21 -0700 Subject: [PATCH] Enable field docstr for `lf.complete`. PiperOrigin-RevId: 571401560 --- langfun/core/structured/completion_test.py | 14 +++++++++++++- langfun/core/structured/mapping.py | 3 ++- requirements.txt | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/langfun/core/structured/completion_test.py b/langfun/core/structured/completion_test.py index 88a87dc4..44e45816 100644 --- a/langfun/core/structured/completion_test.py +++ b/langfun/core/structured/completion_test.py @@ -30,7 +30,10 @@ class Activity(pg.Object): class Itinerary(pg.Object): day: pg.typing.Int[1, None] - type: pg.typing.Enum['daytime', 'nighttime'] + type: pg.typing.Annotated[ + pg.typing.Enum['daytime', 'nighttime'], + 'Type of itinerary.' + ] activities: list[Activity] hotel: pg.typing.Str['.*Hotel'] | None @@ -73,18 +76,21 @@ def test_render_no_examples(self): itineraries=[ Itinerary( day=1, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None ), Itinerary( day=2, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None ), Itinerary( day=3, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None @@ -134,6 +140,7 @@ def test_render_no_class_definitions(self): itineraries=[ Itinerary( day=1, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=[ Activity( @@ -144,6 +151,7 @@ def test_render_no_class_definitions(self): ), Itinerary( day=2, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=[ Activity( @@ -154,6 +162,7 @@ def test_render_no_class_definitions(self): ), Itinerary( day=3, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=[ Activity( @@ -238,18 +247,21 @@ class _Date: itineraries=[ Itinerary( day=1, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None ), Itinerary( day=2, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None ), Itinerary( day=3, + # Type of itinerary. type=MISSING(Literal['daytime', 'nighttime']), activities=MISSING(list[Activity]), hotel=None diff --git a/langfun/core/structured/mapping.py b/langfun/core/structured/mapping.py index 206c0aaf..61f932bf 100644 --- a/langfun/core/structured/mapping.py +++ b/langfun/core/structured/mapping.py @@ -379,7 +379,8 @@ def input_value(self) -> Any: return schema_lib.mark_missing(self.message.result) def value_str(self, value: Any) -> str: - return schema_lib.value_repr('python').repr(value, compact=False) + return schema_lib.value_repr('python').repr( + value, compact=False, verbose=True) def missing_type_dependencies(self, value: Any) -> list[Type[Any]]: value_specs = tuple( diff --git a/requirements.txt b/requirements.txt index 0a192cf2..56d4057a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ jinja2>=3.1.2 openai==0.27.2 -pyglove>=0.4.4.dev20230926 +pyglove>=0.4.4.dev20231006 termcolor==1.1.0 tqdm>=4.64.1 \ No newline at end of file