mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-20 15:34:23 +01:00
Fix all commands and cleanup
This commit is contained in:
@@ -9,11 +9,13 @@ import requests
|
||||
from colorama import Back, Fore
|
||||
from requests.adapters import HTTPAdapter, Retry
|
||||
|
||||
from autogpt.config import Config
|
||||
from autogpt.commands.command import command
|
||||
from autogpt.spinner import Spinner
|
||||
from autogpt.utils import readable_file_size
|
||||
from autogpt.workspace import WORKSPACE_PATH, path_in_workspace
|
||||
|
||||
CFG = Config()
|
||||
LOG_FILE = "file_logger.txt"
|
||||
LOG_FILE_PATH = WORKSPACE_PATH / LOG_FILE
|
||||
|
||||
@@ -82,7 +84,7 @@ def split_file(
|
||||
start += max_length - overlap
|
||||
|
||||
|
||||
@command("read_file", "Read file", '"file": "<file>"')
|
||||
@command("read_file", "Read file", '"filename": "<filename>"')
|
||||
def read_file(filename: str) -> str:
|
||||
"""Read a file and return the contents
|
||||
|
||||
@@ -135,7 +137,7 @@ def ingest_file(
|
||||
print(f"Error while ingesting file '{filename}': {str(e)}")
|
||||
|
||||
|
||||
@command("write_to_file", "Write to file", '"file": "<file>", "text": "<text>"')
|
||||
@command("write_to_file", "Write to file", '"filename": "<filename>", "text": "<text>"')
|
||||
def write_to_file(filename: str, text: str) -> str:
|
||||
"""Write text to a file
|
||||
|
||||
@@ -161,7 +163,7 @@ def write_to_file(filename: str, text: str) -> str:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
|
||||
@command("append_to_file", "Append to file", '"file": "<file>", "text": "<text>"')
|
||||
@command("append_to_file", "Append to file", '"filename": "<filename>", "text": "<text>"')
|
||||
def append_to_file(filename: str, text: str, shouldLog: bool = True) -> str:
|
||||
"""Append text to a file
|
||||
|
||||
@@ -185,7 +187,7 @@ def append_to_file(filename: str, text: str, shouldLog: bool = True) -> str:
|
||||
return f"Error: {str(e)}"
|
||||
|
||||
|
||||
@command("delete_file", "Delete file", '"file": "<file>"')
|
||||
@command("delete_file", "Delete file", '"filename": "<filename>"')
|
||||
def delete_file(filename: str) -> str:
|
||||
"""Delete a file
|
||||
|
||||
@@ -233,6 +235,8 @@ def search_files(directory: str) -> list[str]:
|
||||
return found_files
|
||||
|
||||
|
||||
|
||||
@command("download_file", "Search Files", '"url": "<url>", "filename": "<filename>"', CFG.allow_downloads, "Error: You do not have user authorization to download files locally.")
|
||||
def download_file(url, filename):
|
||||
"""Downloads a file
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user