|
|
@ -48,22 +48,22 @@ class CodeEditor(BaseToolSet):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return output
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
@tool(
|
|
|
|
# @tool(
|
|
|
|
name="CodeEditor.APPEND",
|
|
|
|
# name="CodeEditor.APPEND",
|
|
|
|
description="Append code to the existing file. "
|
|
|
|
# description="Append code to the existing file. "
|
|
|
|
"If the code is completed, use the Terminal tool to execute it, if not, append the code through the this tool. "
|
|
|
|
# "If the code is completed, use the Terminal tool to execute it, if not, append the code through the this tool. "
|
|
|
|
"Input should be filename and code to append. "
|
|
|
|
# "Input should be filename and code to append. "
|
|
|
|
"Input code must be the code that should be appended, NOT whole code. "
|
|
|
|
# "Input code must be the code that should be appended, NOT whole code. "
|
|
|
|
"ex. test.py\nprint('hello world')\n "
|
|
|
|
# "ex. test.py\nprint('hello world')\n "
|
|
|
|
"and the output will be last 3 line.",
|
|
|
|
# "and the output will be last 3 line.",
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
def append(self, inputs: str) -> str:
|
|
|
|
def append(self, inputs: str) -> str:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
code = CodeWriter.append(inputs)
|
|
|
|
code = CodeWriter.append(inputs)
|
|
|
|
output = (
|
|
|
|
output = (
|
|
|
|
"Last 3 line was:\n"
|
|
|
|
"Last 3 line was:\n"
|
|
|
|
+ "\n".join(code.split("\n")[-3:])
|
|
|
|
+ "\n".join(code.split("\n")[-3:])
|
|
|
|
+ "\nYou can use CodeEditor.APPEND tool to append the code if it is not completed."
|
|
|
|
# + "\nYou can use CodeEditor.APPEND tool to append the code if it is not completed."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
output = str(e)
|
|
|
|
output = str(e)
|
|
|
@ -88,7 +88,7 @@ class CodeEditor(BaseToolSet):
|
|
|
|
output = (
|
|
|
|
output = (
|
|
|
|
"Last 3 line was:\n"
|
|
|
|
"Last 3 line was:\n"
|
|
|
|
+ "\n".join(code.split("\n")[-3:])
|
|
|
|
+ "\n".join(code.split("\n")[-3:])
|
|
|
|
+ "\nYou can use CodeEditor.APPEND tool to append the code if it is not completed."
|
|
|
|
# + "\nYou can use CodeEditor.APPEND tool to append the code if it is not completed."
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
output = str(e)
|
|
|
|
output = str(e)
|
|
|
|