From 25444bbe9e2a3900d0461856b615863006fab950 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 21 Jun 2023 19:11:05 -0700 Subject: [PATCH] aider: Modified schema to wrap "array" type inside an "object" type with a single property called "items". # Context: USER: I did `git reset --hard HEAD~1` to discard the last edits. ASSISTANT: Alright, the last commit has been discarded. If you need any further assistance or want to make any other changes, feel free to ask. USER: openai.error.InvalidRequestError: Invalid schema for function 'write_file': schema must be a JSON Schema of 'type: "object"', got 'type: "array"'. ASSISTANT: I apologize for the confusion. It seems that the schema must be of type "object" instead of "array". In this case, we can modify the schema to have a single property that contains the list of objects. Here's the updated schema: ```python aider/coders/func_coder.py <<<<<<< ORIGINAL parameters=dict( type="object", required=["explanation", "file_path", "file_content"], properties=dict( explanation=dict( type="string", description=( "Explanation of the changes to be made to the code (markdown format)" ), ), file_path=dict( type="string", description="Path of file to write", ), file_content=dict( type="string", description="Content to write to the file", ), ), ), ======= parameters=dict( type="object", properties=dict( items=dict( type="array", items=dict( type="object", required=["explanation", "file_path", "file_content"], properties=dict( explanation=dict( type="string", description=( "Explanation of the changes to be made to the code (markdown format)" ), ), file_path=dict( type="string", description="Path of file to write", ), file_content=dict( type="string", description="Content to write to the file", ), ), ), ), ), ), >>>>>>> UPDATED ``` This change wraps the "array" type inside an "object" type with a single property called "items". --- aider/coders/func_coder.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/aider/coders/func_coder.py b/aider/coders/func_coder.py index ff7ddd6e6..cbba13021 100644 --- a/aider/coders/func_coder.py +++ b/aider/coders/func_coder.py @@ -13,22 +13,30 @@ class FunctionCoder(Coder): description="create or update a file", parameters=dict( type="object", - required=["explanation", "file_path", "file_content"], properties=dict( - explanation=dict( - type="string", - description=( - "Explanation of the changes to be made to the code (markdown format)" + items=dict( + type="array", + items=dict( + type="object", + required=["explanation", "file_path", "file_content"], + properties=dict( + explanation=dict( + type="string", + description=( + "Explanation of the changes to be made to the code (markdown format)" + ), + ), + file_path=dict( + type="string", + description="Path of file to write", + ), + file_content=dict( + type="string", + description="Content to write to the file", + ), + ), ), ), - file_path=dict( - type="string", - description="Path of file to write", - ), - file_content=dict( - type="string", - description="Content to write to the file", - ), ), ), ),