fix: 修复了在else语句中调用'schema_str'之前未定义的问题 (#1719)

重新排列了方法中的条件返回语句,以确保在使用之前始终定义了'schema_str'。
This commit is contained in:
owo 2024-04-18 16:26:13 +08:00 committed by GitHub
parent 5c5f442649
commit f0e15bd710
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -62,8 +62,8 @@ class GptJsonIO():
if "type" in reduced_schema:
del reduced_schema["type"]
# Ensure json in context is well-formed with double quotes.
schema_str = json.dumps(reduced_schema)
if self.example_instruction:
schema_str = json.dumps(reduced_schema)
return PYDANTIC_FORMAT_INSTRUCTIONS.format(schema=schema_str)
else:
return PYDANTIC_FORMAT_INSTRUCTIONS_SIMPLE.format(schema=schema_str)