Skip to content

Commit

Permalink
Surface cleanup_json to be publicly accessible.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 572389961
  • Loading branch information
Langfun Authors committed Oct 11, 2023
1 parent c45def9 commit 53fd38e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions langfun/core/structured/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ def parse(self, text: str, schema: Schema | None = None, **kwargs) -> Any:
"""Parse a JSON string into a structured object."""
del schema
try:
text = self._cleanup_json(text)
text = self.cleanup_json(text)
v = pg.from_json_str(text)
except Exception as e:
raise JsonError(text, e) # pylint: disable=raise-missing-from
Expand All @@ -616,7 +616,7 @@ def parse(self, text: str, schema: Schema | None = None, **kwargs) -> Any:
))
return v['result']

def _cleanup_json(self, json_str: str) -> str:
def cleanup_json(self, json_str: str) -> str:
"""Clean up the LM responded JSON string."""
# Treatments:
# 1. Extract the JSON string with a top-level dict from the response.
Expand Down

0 comments on commit 53fd38e

Please sign in to comment.