instead of tool_call arguments being valid json, a literal function call is being returned?
tool_call.function.arguments == functions.rename_file(
old_name=“file-nC389OZzSf8oK37qwOQX0s7u”,
new_name=“FamousMusicGroupsIndex.txt”
Error Log:
Run status: requires_action
tool_call.function.arguments: functions.rename_file(
old_name="file-nC389OZzSf8oK37qwOQX0s7u",
new_name="FamousMusicGroupsIndex.txt"
Traceback (most recent call last):
File "file_renaming_asst.py", line 377, in <module>
main(parser.parse_args())
File "file_renaming_asst.py", line 346, in main
rename_files(args.files_rename)
File "file_renaming_asst.py", line 157, in rename_files
query_last_thread(f'Read {f_id}, generate a meaningful name based on the contents, and rename it using rename_file_interface.')
File "file_renaming_asst.py", line 329, in query_last_thread
return query(q, get_thread(lt_id))
File "file_renaming_asst.py", line 318, in query
run = call_tool(run, thread)
File "file_renaming_asst.py", line 247, in call_tool
arguments = json.loads(tool_call.function.arguments)
File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Asst details; I tried spelling it out in description too, but still won’t return json arguments:
asst_name = "File Renamer Assistant"
asst_instructions="""You help users rename uploaded files by analyzing their contents, generating a concise and descriptive new name based on the
file contents, and calling your rename_file function, according to your rename_file_interface, including valid json arguments.
asst_model="gpt-4-1106-preview" # cheaper, faster, dumber model: gpt-3.5-turbo
# assistant functions
def rename_file(old_name, new_name):
print(f'Renaming {old_name} to {new_name}')
command = ['cp', old_name, f'renamed/{new_name}']
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout if result.returncode == 0 else result.stderr
# assistant function interfaces
rename_file_interface = {
"name": "rename_file",
"description": """Renames the input file by passing old_name and new_name VALID JSON arguments,
e.g. \"arguments\": \"{\"old_name\":\"old_name.txt\", \"new_name\":\"new_name.txt\"}\"""",
"parameters": {
"type": "object",
"properties": {
"old_name": {
"type": "string",
"description": "The old name of the file, including it's extention; e.g. old_name.ext, NOT file_########"
"new_name": {
"type": "string",
"description": "The new name of the file, including it's extention; e.g. new_name.ext"
"required": ["old_name", "new_name"]
# assistant tools
asst_tools=[#{"type": "code_interpreter"},
{"type": "retrieval"},
{"type": "function", "function": rename_file_interface},
githubDOTcom/toadlyBroodle/asst-file-renamer