diff --git a/apps/slackbot/Dockerfile b/apps/slackbot/Dockerfile index 98c09ec2..871ced36 100644 --- a/apps/slackbot/Dockerfile +++ b/apps/slackbot/Dockerfile @@ -18,7 +18,7 @@ RUN pip install --no-cache-dir -r requirements.txt COPY . . # Expose the port that the Flask app will listen on -EXPOSE 3000 +EXPOSE 80 # Run the Flask app CMD ["python", "bolt_app.py"] diff --git a/apps/slackbot/app.py b/apps/slackbot/app.py index 430c245f..c33e0441 100644 --- a/apps/slackbot/app.py +++ b/apps/slackbot/app.py @@ -22,6 +22,7 @@ from langchain.document_loaders import UnstructuredPDFLoader from langchain.indexes import VectorstoreIndexCreator from langchain.chains import RetrievalQA +from flask_cors import CORS import shutil import atexit @@ -32,6 +33,8 @@ # This `app` represents your existing Flask app app = Flask(__name__) +CORS(app) + greetings = ["hi", "hello", "hello there", "hey"] @@ -54,10 +57,14 @@ ########################################################################### # instantiating slack client -slack_client = WebClient(SLACK_OAUTH_TOKEN) +slack_client = WebClient(SLACK_OAUTH_TOKEN) os.environ['OPENAI_API_KEY'] = OPENAI_KEY +@app.route('/hello') +def hello(): + return "hello from slackbot app" + # An example of one of your Flask app's routes @app.route("/") def event_hook(request): @@ -190,4 +197,4 @@ def createIndex(pdf_folder_path): # qa = createLangchainQA(vectorstore) chain = createIndex("files") - app.run(port=3000) + app.run(host="0.0.0.0", port="80") diff --git a/apps/slackbot/requirements.txt b/apps/slackbot/requirements.txt index 0e3ea812..166337e5 100644 --- a/apps/slackbot/requirements.txt +++ b/apps/slackbot/requirements.txt @@ -10,4 +10,5 @@ openai chromadb tiktoken slack_bolt -pinecone-client \ No newline at end of file +pinecone-client +Flask-Cors==3.0.10 diff --git a/apps/slackbot/buildspec.prod.yml b/buildspec.prod.yml similarity index 85% rename from apps/slackbot/buildspec.prod.yml rename to buildspec.prod.yml index 7bfd83b6..a0f99e40 100644 --- a/apps/slackbot/buildspec.prod.yml +++ b/buildspec.prod.yml @@ -9,12 +9,15 @@ phases: - REPOSITORY_URI=387065515315.dkr.ecr.us-east-1.amazonaws.com/ai/slackbot - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7) - IMAGE_TAG=build-$(echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}') + - aws s3 sync s3://ai-config-one/slackbot ./ + - mv env-prod.properties production.env + - cp production.env ./apps/slackbot/.env build: commands: - echo Build started on `date` - echo Building the Docker image... - docker login --username aiscience --password 2E9nUhgCB5smmQsa - - docker build --cache-from $REPOSITORY_URI:latest -t $REPOSITORY_URI:latest . + - docker build --cache-from $REPOSITORY_URI:latest -t $REPOSITORY_URI:latest ./apps/slackbot - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG post_build: