From 5537f6fbc4ec7c75fbd7f869189b5335502bef7b Mon Sep 17 00:00:00 2001 From: FlamingFury00 Date: Tue, 2 May 2023 19:18:31 +0200 Subject: [PATCH 1/2] Update --- .devcontainer/Dockerfile | 19 +++++++++++++++ .devcontainer/devcontainer.json | 40 ++++++++++++++++++++++++++++++++ .devcontainer/docker-compose.yml | 12 ++++++++++ .env | 13 +++++++++++ AUTOGPT.py | 29 +++++++++++++---------- requirements.txt | 3 ++- 6 files changed, 103 insertions(+), 13 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 .env diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..d1eedff --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,19 @@ +# Use an official Python base image from the Docker Hub +FROM python:3.10 + +# Install browsers +RUN apt-get update && apt-get install -y \ + chromium-driver firefox-esr \ + ca-certificates + +# Install utilities +RUN apt-get install -y curl jq wget git + +# Declare working directory +WORKDIR /workspace/FreeAutoGPT + +# Copy the current directory contents into the Workspace. +COPY . /workspace/FreeAutoGPT + +# Install any necessary packages specified in requirements.txt. +RUN pip install -r requirements.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..1d0f727 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +{ + "dockerComposeFile": "./docker-compose.yml", + "service": "free-autogpt", + "workspaceFolder": "/workspace/FreeAutoGPT", + "shutdownAction": "stopCompose", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "username": "vscode", + "userUid": "6942", + "userGid": "6942", + "upgradePackages": "true" + }, + "ghcr.io/devcontainers/features/desktop-lite:1": {}, + "ghcr.io/devcontainers/features/python:1": "none", + "ghcr.io/devcontainers/features/node:1": "none", + "ghcr.io/devcontainers/features/git:1": { + "version": "latest", + "ppa": "false" + } + }, + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python" + } + } + }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..192e764 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,12 @@ +# To boot the app run the following: +# docker-compose run auto-gpt +version: '3.10' + +services: + free-autogpt: + build: + dockerfile: .devcontainer/Dockerfile + context: ../ + tty: true + volumes: + - ../:/workspace/FreeAutoGPT diff --git a/.env b/.env new file mode 100644 index 0000000..8ab7e7a --- /dev/null +++ b/.env @@ -0,0 +1,13 @@ +################################################################################ +### FREE-AUTOGPT - GENERAL SETTINGS +################################################################################ + +### CHATGPT +## CHATGPT_TOKEN - ChatGPT Token (Go to https://chat.openai.com/chat and open the developer tools by F12. +## Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com +## Copy the value in the Cooki2e Value field.) +CHATGPT_TOKEN=your-chatgpt-token + +### HUGGINGFACE +## HUGGINGFACE_TOKEN - HuggingFace Token (Check https://huggingface.co/settings/tokens to get your token) +HUGGINGFACE_TOKEN=your-huggingface-token \ No newline at end of file diff --git a/AUTOGPT.py b/AUTOGPT.py index c8305a1..80bb5fc 100644 --- a/AUTOGPT.py +++ b/AUTOGPT.py @@ -4,6 +4,7 @@ # General import os import pandas as pd +from dotenv import load_dotenv from langchain.experimental.autonomous_agents.autogpt.agent import AutoGPT from FreeLLM import ChatGPTAPI # FREE CHATGPT API from FreeLLM import HuggingChatAPI # FREE HUGGINGCHAT API @@ -17,6 +18,7 @@ import nest_asyncio # Needed synce jupyter runs an async eventloop nest_asyncio.apply() +load_dotenv() select_model = input("Select the model you want to use (1 or 2) \n \ 1) ChatGPT \n \ @@ -24,12 +26,13 @@ select_model = input("Select the model you want to use (1 or 2) \n \ >>> ") if select_model == "1": - print("Chatgpt token : \n \ - Go to https://chat.openai.com/chat and open the developer tools by F12. \n \ - Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com \n \ - Copy the value in the Cooki2e Value field.") - CG_TOKEN = input("Insert chatgpt token >>> ") - os.environ["CHATGPT_TOKEN"] = CG_TOKEN + CG_TOKEN = os.getenv("CHATGPT_TOKEN", "your-chatgpt-token") + + if (CG_TOKEN != "your-chatgpt-token"): + os.environ["CHATGPT_TOKEN"] = CG_TOKEN + else: + raise ValueError("ChatGPT Token EMPTY. Edit the .env file and put your ChatGPT token") + start_chat = input("Do you want start a chat from existing chat? (y/n): ") # ask if you want start a chat from existing chat if start_chat == "y": chat_id = input("Insert chat-id (chat.openai.com/c/(IS THIS ->)58XXXX0f-XXXX-XXXX-XXXX-faXXXXd2b50f) ->") # ask the chat id @@ -38,13 +41,15 @@ if select_model == "1": llm= ChatGPTAPI.ChatGPT(token=os.environ["CHATGPT_TOKEN"]) elif select_model == "2": llm=HuggingChatAPI.HuggingChat() - - -print("You must provide the huggingface token and chatgpt token") -print("Huggingface token, check https://huggingface.co/settings/tokens for get your token") -HF_TOKEN = input("Insert huggingface token >>> ") -os.environ["HUGGINGFACEHUB_API_TOKEN"] = HF_TOKEN + + +HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN", "your-huggingface-token") + +if (HF_TOKEN != "your-huggingface-token"): + os.environ["HUGGINGFACEHUB_API_TOKEN"] = HF_TOKEN +else: + raise ValueError("HuggingFace Token EMPTY. Edit the .env file and put your HuggingFace token") # Tools import os diff --git a/requirements.txt b/requirements.txt index a374505..222aad4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,5 @@ torch pytest-playwright undetected-chromedriver>=3.2.1 markdownify>=0.11.6 -hugchat \ No newline at end of file +hugchat +python-dotenv \ No newline at end of file From 887212399387548aa2aa91d5422140e505a98038 Mon Sep 17 00:00:00 2001 From: FlamingFury00 Date: Tue, 2 May 2023 19:26:09 +0200 Subject: [PATCH 2/2] Update --- BABYAGI.py | 26 ++++++++++++++++---------- MetaPrompt.py | 15 +++++++++------ 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/BABYAGI.py b/BABYAGI.py index 002971f..9645d69 100644 --- a/BABYAGI.py +++ b/BABYAGI.py @@ -1,4 +1,5 @@ import os +from dotenv import load_dotenv from collections import deque from typing import Dict, List, Optional, Any from langchain.vectorstores import FAISS @@ -14,18 +15,21 @@ from langchain.chains.base import Chain from langchain.experimental import BabyAGI import faiss +load_dotenv() + select_model = input("Select the model you want to use (1 or 2) \n \ 1) ChatGPT \n \ 2) HuggingChat \n \ >>> ") if select_model == "1": - print("Chatgpt token : \n \ - Go to https://chat.openai.com/chat and open the developer tools by F12. \n \ - Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com \n \ - Copy the value in the Cooki2e Value field.") - CG_TOKEN = input("Insert chatgpt token >>> ") - os.environ["CHATGPT_TOKEN"] = CG_TOKEN + CG_TOKEN = os.getenv("CHATGPT_TOKEN", "your-chatgpt-token") + + if (CG_TOKEN != "your-chatgpt-token"): + os.environ["CHATGPT_TOKEN"] = CG_TOKEN + else: + raise ValueError("ChatGPT Token EMPTY. Edit the .env file and put your ChatGPT token") + start_chat = input("Do you want start a chat from existing chat? (y/n): ") # ask if you want start a chat from existing chat if start_chat == "y": chat_id = input("Insert chat-id (chat.openai.com/c/(IS THIS ->)58XXXX0f-XXXX-XXXX-XXXX-faXXXXd2b50f) ->") # ask the chat id @@ -37,10 +41,12 @@ elif select_model == "2": -print("You must provide the huggingface token and chatgpt token") -print("Huggingface token, check https://huggingface.co/settings/tokens for get your token") -HF_TOKEN = input("Insert huggingface token >>> ") -os.environ["HUGGINGFACEHUB_API_TOKEN"] = HF_TOKEN +HF_TOKEN = os.getenv("HUGGINGFACE_TOKEN", "your-huggingface-token") + +if (HF_TOKEN != "your-huggingface-token"): + os.environ["HUGGINGFACEHUB_API_TOKEN"] = HF_TOKEN +else: + raise ValueError("HuggingFace Token EMPTY. Edit the .env file and put your HuggingFace token") diff --git a/MetaPrompt.py b/MetaPrompt.py index 6420802..8cb5392 100644 --- a/MetaPrompt.py +++ b/MetaPrompt.py @@ -1,9 +1,11 @@ +from dotenv import load_dotenv from langchain import LLMChain, PromptTemplate from FreeLLM import ChatGPTAPI # FREE CHATGPT API from FreeLLM import HuggingChatAPI # FREE HUGGINGCHAT API from langchain.memory import ConversationBufferWindowMemory import os +load_dotenv() #### LOG IN FOR CHATGPT FREE LLM select_model = input("Select the model you want to use (1 or 2) \n \ @@ -12,12 +14,13 @@ select_model = input("Select the model you want to use (1 or 2) \n \ >>> ") if select_model == "1": - print("Chatgpt token : \n \ - Go to https://chat.openai.com/chat and open the developer tools by F12. \n \ - Find the __Secure-next-auth.session-token cookie in Application > Storage > Cookies > https://chat.openai.com \n \ - Copy the value in the Cooki2e Value field.") - CG_TOKEN = input("Insert chatgpt token >>> ") - os.environ["CHATGPT_TOKEN"] = CG_TOKEN + CG_TOKEN = os.getenv("CHATGPT_TOKEN", "your-chatgpt-token") + + if (CG_TOKEN != "your-chatgpt-token"): + os.environ["CHATGPT_TOKEN"] = CG_TOKEN + else: + raise ValueError("ChatGPT Token EMPTY. Edit the .env file and put your ChatGPT token") + start_chat = input("Do you want start a chat from existing chat? (y/n): ") # ask if you want start a chat from existing chat if start_chat == "y": chat_id = input("Insert chat-id (chat.openai.com/c/(IS THIS ->)58XXXX0f-XXXX-XXXX-XXXX-faXXXXd2b50f) ->") # ask the chat id