Skip to content

Commit f0e15bd

Browse files
authored
fix: 修复了在else语句中调用'schema_str'之前未定义的问题 (#1719)
重新排列了方法中的条件返回语句,以确保在使用之前始终定义了'schema_str'。
1 parent 5c5f442 commit f0e15bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crazy_functions/json_fns/pydantic_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def generate_format_instructions(self):
6262
if "type" in reduced_schema:
6363
del reduced_schema["type"]
6464
# Ensure json in context is well-formed with double quotes.
65+
schema_str = json.dumps(reduced_schema)
6566
if self.example_instruction:
66-
schema_str = json.dumps(reduced_schema)
6767
return PYDANTIC_FORMAT_INSTRUCTIONS.format(schema=schema_str)
6868
else:
6969
return PYDANTIC_FORMAT_INSTRUCTIONS_SIMPLE.format(schema=schema_str)

0 commit comments

Comments
 (0)