Skip to content

Commit

Permalink
Enable field docstr for lf.complete.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 571405501
  • Loading branch information
daiyip authored and langfun authors committed Oct 6, 2023
1 parent e4cc1a7 commit dbe61af
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
14 changes: 13 additions & 1 deletion langfun/core/structured/completion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -144,6 +151,7 @@ def test_render_no_class_definitions(self):
),
Itinerary(
day=2,
# Type of itinerary.
type=MISSING(Literal['daytime', 'nighttime']),
activities=[
Activity(
Expand All @@ -154,6 +162,7 @@ def test_render_no_class_definitions(self):
),
Itinerary(
day=3,
# Type of itinerary.
type=MISSING(Literal['daytime', 'nighttime']),
activities=[
Activity(
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion langfun/core/structured/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dbe61af

Please sign in to comment.