@ -18,7 +18,8 @@ class Terminal(BaseToolSet):
@tool (
name = " Terminal " ,
description = " Executes commands in a terminal. "
" You can install packages with pip, apt, etc. "
" If linux errno occurs, we have to solve the problem with the terminal. "
" It can ' t execute interactive operations or blocking operations. "
" Input should be valid commands, "
" and the output will be any output from running that command. " ,
)
@ -34,6 +35,9 @@ class Terminal(BaseToolSet):
except Exception as e :
output = str ( e )
if len ( output ) > 1000 :
output = output [ : 1000 ] + " ... "
logger . debug (
f " \n Processed Terminal, Input Commands: { commands } "
f " Output Answer: { output } "
@ -89,15 +93,20 @@ class CodeEditor(BaseToolSet):
" ex. test.py \n print( ' hello world ' ) \n "
" and the output will be last 3 line. " ,
)
def write ( self , inputs : str ) - > str :
def append ( self , inputs : str ) - > str :
try :
code = CodeWriter . append ( inputs )
output = " Last 3 line was: \n " + " \n " . join ( code . split ( " \n " ) [ - 3 : ] )
output = (
" Last 3 line was: \n "
+ " \n " . join ( code . split ( " \n " ) [ - 3 : ] )
+ " \n You can use CodeEditor.APPEND tool to append the code if it is not completed. "
)
except Exception as e :
output = str ( e )
logger . debug (
f " \n Processed CodeEditor, Input: { inputs } " f " Output Answer: { output } "
f " \n Processed CodeEditor.APPEND, Input: { inputs } "
f " Output Answer: { output } "
)
return output
@ -105,19 +114,23 @@ class CodeEditor(BaseToolSet):
name = " CodeEditor.WRITE " ,
description = " Write code to create a new tool. "
" If the code is completed, use the Terminal tool to execute it, if not, append the code through the CodeEditor.APPEND tool. "
" Input should be filename and code. "
" Input should be filename and code. This file must be in playground folder. "
" ex. test.py \n print( ' hello world ' ) \n "
" and the output will be last 3 line. " ,
)
def write ( self , inputs : str ) - > str :
try :
code = CodeWriter . write ( inputs )
output = " Last 3 line was: \n " + " \n " . join ( code . split ( " \n " ) [ - 3 : ] )
output = (
" Last 3 line was: \n "
+ " \n " . join ( code . split ( " \n " ) [ - 3 : ] )
+ " \n You can use CodeEditor.APPEND tool to append the code if it is not completed. "
)
except Exception as e :
output = str ( e )
logger . debug (
f " \n Processed CodeEditor , Input: { inputs } " f " Output Answer: { output } "
f " \n Processed CodeEditor .WRITE , Input: { inputs } " f " Output Answer: { output } "
)
return output
@ -140,7 +153,7 @@ class CodeEditor(BaseToolSet):
output = str ( e )
logger . debug (
f " \n Processed CodeEditor , Input Patch: { patches } "
f " \n Processed CodeEditor .PATCH , Input Patch: { patches } "
f " Output Answer: { output } "
)
return output
@ -162,7 +175,7 @@ class CodeEditor(BaseToolSet):
output = str ( e )
logger . debug (
f " \n Processed CodeEditor , Input filename: { inputs } "
f " \n Processed CodeEditor .DELETE , Input filename: { inputs } "
f " Output Answer: { output } "
)
return output