Skip to content

Commit

Permalink
Disabled markup for rich. Additional inst 'Only one of send_text, sen…
Browse files Browse the repository at this point in the history
…d_specials, send_ascii should be provided'. Enabling FindAndReplace tool
  • Loading branch information
Aman Rusia committed Nov 16, 2024
1 parent f1bbae5 commit 32c5afc
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 12 deletions.
71 changes: 70 additions & 1 deletion gpt_action_json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions gpt_instructions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
15 changes: 10 additions & 5 deletions src/wcgw/client/anthropic_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 11 additions & 6 deletions src/wcgw/client/openai_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 32c5afc

Please sign in to comment.