CoolFace
Apppublic

coding-alt/AutoGPT

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
cli.py146 linesDownload Raw Back to autogpt
1"""Main script for the autogpt package."""2import click3 4 5@click.group(invoke_without_command=True)6@click.option("-c", "--continuous", is_flag=True, help="Enable Continuous Mode")7@click.option(8    "--skip-reprompt",9    "-y",10    is_flag=True,11    help="Skips the re-prompting messages at the beginning of the script",12)13@click.option(14    "--ai-settings",15    "-C",16    help="Specifies which ai_settings.yaml file to use, will also automatically skip the re-prompt.",17)18@click.option(19    "-l",20    "--continuous-limit",21    type=int,22    help="Defines the number of times to run in continuous mode",23)24@click.option("--speak", is_flag=True, help="Enable Speak Mode")25@click.option("--debug", is_flag=True, help="Enable Debug Mode")26@click.option("--gpt3only", is_flag=True, help="Enable GPT3.5 Only Mode")27@click.option("--gpt4only", is_flag=True, help="Enable GPT4 Only Mode")28@click.option(29    "--use-memory",30    "-m",31    "memory_type",32    type=str,33    help="Defines which Memory backend to use",34)35@click.option(36    "-b",37    "--browser-name",38    help="Specifies which web-browser to use when using selenium to scrape the web.",39)40@click.option(41    "--allow-downloads",42    is_flag=True,43    help="Dangerous: Allows Auto-GPT to download files natively.",44)45@click.option(46    "--skip-news",47    is_flag=True,48    help="Specifies whether to suppress the output of latest news on startup.",49)50@click.pass_context51def main(52    ctx: click.Context,53    continuous: bool,54    continuous_limit: int,55    ai_settings: str,56    skip_reprompt: bool,57    speak: bool,58    debug: bool,59    gpt3only: bool,60    gpt4only: bool,61    memory_type: str,62    browser_name: str,63    allow_downloads: bool,64    skip_news: bool,65) -> None:66    """67    Welcome to AutoGPT an experimental open-source application showcasing the capabilities of the GPT-4 pushing the boundaries of AI.68 69    Start an Auto-GPT assistant.70    """71    # Put imports inside function to avoid importing everything when starting the CLI72    import logging73 74    from colorama import Fore75 76    from autogpt.agent.agent import Agent77    from autogpt.config import Config, check_openai_api_key78    from autogpt.configurator import create_config79    from autogpt.logs import logger80    from autogpt.memory import get_memory81    from autogpt.prompt import construct_prompt82    from autogpt.utils import get_current_git_branch, get_latest_bulletin83 84    if ctx.invoked_subcommand is None:85        cfg = Config()86        # TODO: fill in llm values here87        check_openai_api_key()88        create_config(89            continuous,90            continuous_limit,91            ai_settings,92            skip_reprompt,93            speak,94            debug,95            gpt3only,96            gpt4only,97            memory_type,98            browser_name,99            allow_downloads,100            skip_news,101        )102        logger.set_level(logging.DEBUG if cfg.debug_mode else logging.INFO)103        ai_name = ""104        if not cfg.skip_news:105            motd = get_latest_bulletin()106            if motd:107                logger.typewriter_log("NEWS: ", Fore.GREEN, motd)108            git_branch = get_current_git_branch()109            if git_branch and git_branch != "stable":110                logger.typewriter_log(111                    "WARNING: ",112                    Fore.RED,113                    f"You are running on `{git_branch}` branch "114                    "- this is not a supported branch.",115                )116        system_prompt = construct_prompt()117        # print(prompt)118        # Initialize variables119        full_message_history = []120        next_action_count = 0121        # Make a constant:122        triggering_prompt = (123            "Determine which next command to use, and respond using the"124            " format specified above:"125        )126        # Initialize memory and make sure it is empty.127        # this is particularly important for indexing and referencing pinecone memory128        memory = get_memory(cfg, init=True)129        logger.typewriter_log(130            "Using memory of type:", Fore.GREEN, f"{memory.__class__.__name__}"131        )132        logger.typewriter_log("Using Browser:", Fore.GREEN, cfg.selenium_web_browser)133        agent = Agent(134            ai_name=ai_name,135            memory=memory,136            full_message_history=full_message_history,137            next_action_count=next_action_count,138            system_prompt=system_prompt,139            triggering_prompt=triggering_prompt,140        )141        agent.start_interaction_loop()142 143 144if __name__ == "__main__":145    main()146