diff --git a/app/Dockerfile b/app/Dockerfile index 37562a6c7..9d55c1479 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -12,6 +12,8 @@ ARG DOTNETRC ARG PROLIFIC_API_KEY ARG AWS_ACCESS_KEY_ID ARG AWS_SECRET_ACCESS_KEY +ARG APP_NAME +ARG APP_ENV SHELL ["/bin/bash", "-c"] diff --git a/app/docker-compose.yml b/app/docker-compose.yml index 615fa861d..b77b604e1 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -12,8 +12,13 @@ services: ports: - 3000:3000 - 3032:3032 + environment: + - APP_NAME=temp + - APP_ENV=dev volumes: - - ./webapp/src:/mephisto/app/webapp/src:cached +# - ./webapp/src:/mephisto/app/webapp/src:cached + - .:/mephisto/app:cached + - /mephisto/app/webapp/node_modules/ - ./data:/mephisto/data:cached - ../mephisto:/mephisto/mephisto:cached - ../examples:/mephisto/examples:cached diff --git a/app/webapp/package.json b/app/webapp/package.json index 006459a82..4f2013104 100644 --- a/app/webapp/package.json +++ b/app/webapp/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "webpack --mode development", "dev:watch": "webpack --mode development --watch", - "test": "cypress open" + "test": "cypress open", + "build": "webpack --mode production" }, "keywords": [], "author": "", diff --git a/app/webapp/src/app.jsx b/app/webapp/src/app.jsx index 0dbfa6f90..5517dad29 100644 --- a/app/webapp/src/app.jsx +++ b/app/webapp/src/app.jsx @@ -28,6 +28,7 @@ function MainApp() { isPreview, isLoading, initialTaskData, + fullData, handleSubmit, handleMetadataSubmit, handleFatalError, @@ -110,6 +111,7 @@ function MainApp() { { + const agentData = getAgentRegistration(); + const params = { + ...agentData, + provider: agentData.provider_type, + app_env: fullData?.app_env, + app_name: fullData?.app_name, + }; + const url = process.env.NODE_ENV === "production" ? "https://gpt.mephisto.aufederal2022.com" : "https://dev.gpt.mephisto.aufederal2022.com"; + return `${url}?${new URLSearchParams(params).toString()}`; + }; + + return ( + + ); +} + +export {ChatGPT}; \ No newline at end of file diff --git a/app/webapp/src/components/core_components.jsx b/app/webapp/src/components/core_components.jsx index 3cddbee68..6ff877c7e 100644 --- a/app/webapp/src/components/core_components.jsx +++ b/app/webapp/src/components/core_components.jsx @@ -7,6 +7,9 @@ */ import React from 'react'; +import { + ChatGPT, +} from "./ChatGPT.jsx"; function OnboardingComponent({onSubmit}) { return ( @@ -60,17 +63,11 @@ function Directions({children}) { ); } -function SimpleFrontend({taskData, isOnboarding, onSubmit, onError, getAgentRegistration}) { +function SimpleFrontend({taskData, fullData, isOnboarding, onSubmit, onError, getAgentRegistration}) { const [answers, setAnswers] = React.useState({ answer1: 'sample1', answer2: '', }); - const getLink = (getAgentRegistration) => { - const agentData = getAgentRegistration(); - const params = { ...agentData, provider: agentData.provider_type }; - return `https://gpt.mephisto.aufederal2022.com?${new URLSearchParams(params).toString()}`; - }; - const handleInputChange = (event) => { const {name, value} = event.target; setAnswers({...answers, [name]: value}); @@ -97,9 +94,7 @@ function SimpleFrontend({taskData, isOnboarding, onSubmit, onError, getAgentRegi
- +
); diff --git a/mephisto/operations/worker_pool.py b/mephisto/operations/worker_pool.py index 56aaabdf2..b3c2b0637 100644 --- a/mephisto/operations/worker_pool.py +++ b/mephisto/operations/worker_pool.py @@ -5,6 +5,7 @@ # LICENSE file in the root directory of this source tree. import time +import os from functools import partial from dataclasses import dataclass, fields from prometheus_client import Histogram, Gauge, Counter # type: ignore @@ -35,7 +36,8 @@ from mephisto.utils.logger_core import get_logger logger = get_logger(name=__name__) - +APP_NAME = os.getenv('APP_NAME', 'temp') +APP_ENV = os.getenv('APP_ENV', 'dev') AGENT_DETAILS_COUNT = Counter( "agent_details_responses", "Responses to agent details requests", ["response"] @@ -84,6 +86,8 @@ class AgentDetails: agent_id: Optional[str] = None init_task_data: Optional[Dict[str, Any]] = None failure_reason: Optional[str] = None + app_env: str = APP_ENV + app_name: str = APP_NAME def to_dict(self): return dict((field.name, getattr(self, field.name)) for field in fields(self)) diff --git a/mephisto/tools/scripts.py b/mephisto/tools/scripts.py index 25e93a421..6de68934e 100644 --- a/mephisto/tools/scripts.py +++ b/mephisto/tools/scripts.py @@ -42,6 +42,8 @@ if TYPE_CHECKING: from mephisto.abstractions.database import MephistoDB +APP_NAME = os.getenv('APP_NAME', 'temp') +APP_ENV = os.getenv('APP_ENV', 'dev') def load_db_and_process_config( cfg: DictConfig, print_config=False @@ -286,7 +288,11 @@ def build_custom_bundle( "The script should be able to be ran with bash" ) - webpack_complete = subprocess.call(["npm", "run", "dev"]) + if APP_ENV == 'prod': + webpack_complete = subprocess.call(["npm", "run", "build"]) + else: + webpack_complete = subprocess.call(["npm", "run", "dev"]) + if webpack_complete != 0: raise Exception( "Webpack appears to have failed to build your " diff --git a/packages/mephisto-task/src/index.js b/packages/mephisto-task/src/index.js index 9a69be7f7..8924c8772 100644 --- a/packages/mephisto-task/src/index.js +++ b/packages/mephisto-task/src/index.js @@ -49,6 +49,7 @@ const useMephistoTask = function () { blockedReason: null, blockedExplanation: null, initialTaskData: null, + fullData: null, isOnboarding: null, loaded: false, }; @@ -120,6 +121,7 @@ const useMephistoTask = function () { mephistoWorkerId: workerId, mephistoAgentId: agentId, initialTaskData: dataPacket.data.init_task_data, + fullData: dataPacket.data, loaded: true, }); }