diff --git a/gpt_action_json_schema.json b/gpt_action_json_schema.json index 6b825e0..cacee97 100644 --- a/gpt_action_json_schema.json +++ b/gpt_action_json_schema.json @@ -6,7 +6,7 @@ }, "servers": [ { - "url": "https://bf94-103-212-152-58.ngrok-free.app" + "url": "https://abe7-106-213-82-238.ngrok-free.app" } ], "paths": { @@ -50,6 +50,46 @@ } } }, + "/v1/file_edit_find_replace": { + "post": { + "x-openai-isConsequential": false, + "summary": "File Edit Find Replace", + "operationId": "file_edit_find_replace_v1_file_edit_find_replace_post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FileEditFindReplaceWithUUID" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "string", + "title": "Response File Edit Find Replace V1 File Edit Find Replace Post" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, "/v1/reset_shell": { "post": { "x-openai-isConsequential": false, @@ -255,6 +295,35 @@ ], "title": "CommandWithUUID" }, + "FileEditFindReplaceWithUUID": { + "properties": { + "file_path": { + "type": "string", + "title": "File Path" + }, + "find_lines": { + "type": "string", + "title": "Find Lines" + }, + "replace_with_lines": { + "type": "string", + "title": "Replace With Lines" + }, + "user_id": { + "type": "string", + "format": "uuid", + "title": "User Id" + } + }, + "type": "object", + "required": [ + "file_path", + "find_lines", + "replace_with_lines", + "user_id" + ], + "title": "FileEditFindReplaceWithUUID" + }, "HTTPValidationError": { "properties": { "detail": { diff --git a/gpt_instructions.txt b/gpt_instructions.txt index 3df64e3..fafb9b5 100644 --- a/gpt_instructions.txt +++ b/gpt_instructions.txt @@ -26,6 +26,10 @@ Instructions for `BashInteraction` - Interact with running program using this tool - Special keys like arrows, interrupts, enter, etc. - Send text input to the running program. +- Only one of send_text, send_specials, send_ascii should be provided. + +Instructions for `FileEditFindReplace` +- Find and replace text in a file. Use absolute file path only. Instructions for `ResetShell` - Resets the shell. Use only if all interrupts and prompt reset attempts have failed repeatedly. diff --git a/src/wcgw/client/anthropic_client.py b/src/wcgw/client/anthropic_client.py index 84cdcde..6a02438 100644 --- a/src/wcgw/client/anthropic_client.py +++ b/src/wcgw/client/anthropic_client.py @@ -93,7 +93,7 @@ def parse_user_message_special(msg: str) -> MessageParam: args = line[1:].strip().split(" ") command = args[0] assert command == "image" - image_path = args[1] + image_path = " ".join(args[1:]) with open(image_path, "rb") as f: image_bytes = f.read() image_b64 = base64.b64encode(image_bytes).decode("utf-8") @@ -174,6 +174,7 @@ def loop( - Special keys like arrows, interrupts, enter, etc. - Send text input to the running program. - Send send_specials=["Enter"] to recheck status of a running program. +- Only one of send_text, send_specials, send_ascii should be provided. """, ), ToolParam( @@ -232,10 +233,14 @@ def loop( cost: float = 0 input_toks = 0 output_toks = 0 - system_console = rich.console.Console(style="blue", highlight=False) - error_console = rich.console.Console(style="red", highlight=False) - user_console = rich.console.Console(style="bright_black", highlight=False) - assistant_console = rich.console.Console(style="white bold", highlight=False) + system_console = rich.console.Console(style="blue", highlight=False, markup=False) + error_console = rich.console.Console(style="red", highlight=False, markup=False) + user_console = rich.console.Console( + style="bright_black", highlight=False, markup=False + ) + assistant_console = rich.console.Console( + style="white bold", highlight=False, markup=False + ) while True: if cost > limit: system_console.print( diff --git a/src/wcgw/client/openai_client.py b/src/wcgw/client/openai_client.py index 2ee83bb..fd9e8ae 100644 --- a/src/wcgw/client/openai_client.py +++ b/src/wcgw/client/openai_client.py @@ -91,7 +91,7 @@ def parse_user_message_special(msg: str) -> ChatCompletionUserMessageParam: args = line[1:].strip().split(" ") command = args[0] assert command == "image" - image_path = args[1] + image_path = " ".join(args[1:]) with open(image_path, "rb") as f: image_bytes = f.read() image_b64 = base64.b64encode(image_bytes).decode("utf-8") @@ -170,7 +170,8 @@ def loop( description=""" - Interact with running program using this tool - Special keys like arrows, interrupts, enter, etc. -- Send text input to the running program.""", +- Send text input to the running program. +- Only one of send_text, send_specials, send_ascii should be provided.""", ), openai.pydantic_function_tool( Writefile, @@ -215,10 +216,14 @@ def loop( cost: float = 0 input_toks = 0 output_toks = 0 - system_console = rich.console.Console(style="blue", highlight=False) - error_console = rich.console.Console(style="red", highlight=False) - user_console = rich.console.Console(style="bright_black", highlight=False) - assistant_console = rich.console.Console(style="white bold", highlight=False) + system_console = rich.console.Console(style="blue", highlight=False, markup=False) + error_console = rich.console.Console(style="red", highlight=False, markup=False) + user_console = rich.console.Console( + style="bright_black", highlight=False, markup=False + ) + assistant_console = rich.console.Console( + style="white bold", highlight=False, markup=False + ) while True: if cost > limit: