From 6d72c7885c1b865ec0356eafbdf4b7e89d992412 Mon Sep 17 00:00:00 2001 From: teome Date: Tue, 13 Feb 2024 19:58:28 +0000 Subject: [PATCH] fix: json modes - don't add json schema again in system message (#435) --- instructor/patch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/instructor/patch.py b/instructor/patch.py index 29c8a1e..e5adde1 100644 --- a/instructor/patch.py +++ b/instructor/patch.py @@ -159,9 +159,8 @@ def handle_response_model( "content": message, }, ) - - # if the first message is a system append the schema to the end - if new_kwargs["messages"][0]["role"] == "system": + # if it is, system append the schema to the end + else: new_kwargs["messages"][0]["content"] += f"\n\n{message}" else: raise ValueError(f"Invalid patch mode: {mode}")