fix: remove unused tool_calls and debug logging, fix file ops

- Removed default `tool_calls` assignment from `Api.__call__` in `api.py`
- Removed `debug.error()` logging in two exception blocks in `api.py`
- Fixed malformed URL in `CohereForAI_C4AI_Command.url` by removing leading tab in `CohereForAI_C4AI_Command.py`
- Replaced incorrect `result.text_content` access with just `result` in `Backend_Api.upload_bucket` in `backend_api.py`
- Replaced `shutil.copyfile` with `os.rename`, and added fallback to `shutil.copyfile` on failure in `Backend_Api.upload_bucket` in `backend_api.py
This commit is contained in:
hlohaus 2025-04-24 16:44:48 +02:00
parent 8f63f656a2
commit ba20b2f302
3 changed files with 7 additions and 12 deletions

View file

@ -107,12 +107,6 @@ class Api:
model = json_data.get('model')
provider = json_data.get('provider')
messages = json_data.get('messages')
kwargs["tool_calls"] = [{
"function": {
"name": "bucket_tool"
},
"type": "function"
}]
action = json_data.get('action')
if action == "continue":
kwargs["tool_calls"].append({
@ -186,7 +180,6 @@ class Api:
yield self._format_json("conversation_id", conversation_id)
elif isinstance(chunk, Exception):
logger.exception(chunk)
debug.error(chunk)
yield self._format_json('message', get_error_message(chunk), error=type(chunk).__name__)
elif isinstance(chunk, RequestLogin):
yield self._format_json("preview", chunk.to_string())
@ -232,7 +225,6 @@ class Api:
yield self._format_json('auth', type(e).__name__, message=get_error_message(e))
except Exception as e:
logger.exception(e)
debug.error(e)
yield self._format_json('error', type(e).__name__, message=get_error_message(e))
finally:
yield from self._yield_logs()

View file

@ -318,7 +318,7 @@ class Backend_Api(Api):
md = MarkItDown()
result = md.convert(copyfile.name).text_content
with open(os.path.join(bucket_dir, f"{filename}.md"), 'w') as f:
f.write(f"{result.text_content}\n")
f.write(f"{result}\n")
filenames.append(f"{filename}.md")
except Exception as e:
logger.exception(e)
@ -333,6 +333,9 @@ class Backend_Api(Api):
else:
os.remove(copyfile.name)
continue
try:
os.rename(copyfile.name, newfile)
except OSError:
shutil.copyfile(copyfile.name, newfile)
os.remove(copyfile.name)
with open(os.path.join(bucket_dir, "files.txt"), 'w') as f: