From f0e15bd710e64afb601b00d6294a19cf792073d4 Mon Sep 17 00:00:00 2001 From: owo <47293699+Keycatowo@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:26:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=9C=A8else?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5=E4=B8=AD=E8=B0=83=E7=94=A8'schema=5Fstr'?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=9C=AA=E5=AE=9A=E4=B9=89=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#1719)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 重新排列了方法中的条件返回语句,以确保在使用之前始终定义了'schema_str'。 --- crazy_functions/json_fns/pydantic_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crazy_functions/json_fns/pydantic_io.py b/crazy_functions/json_fns/pydantic_io.py index 66316d4..d709335 100644 --- a/crazy_functions/json_fns/pydantic_io.py +++ b/crazy_functions/json_fns/pydantic_io.py @@ -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)