From 6e05f8ca93f501612cc879baae8d52d91d7c85f9 Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Thu, 19 Oct 2023 11:38:03 +0800 Subject: [PATCH 1/4] fix: npm run start (#1380) --- web/README.md | 12 ++++-------- web/package.json | 7 ++++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/web/README.md b/web/README.md index 1a24a135e795b0..f6d8e6cdb96193 100644 --- a/web/README.md +++ b/web/README.md @@ -64,24 +64,20 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the ## Deploy ### Deploy on server First, build the app for production: - ```bash npm run build ``` -Then, move the static files to standalone folder: +Then, start the server: ```bash -mv .next/static .next/standalone/.next -cp -r ./public .next/standalone/.next/ +npm run start ``` -Finally, start the app: +If you want to customize the host and port: ```bash -node .next/standalone/server.js +npm run start --port=3001 --host=0.0.0.0 ``` -If your project needs alternative port or hostname for listening, you can define PORT and HOSTNAME environment variables, before running server.js. For example, `PORT=3000 HOSTNAME=localhost node .next/standalone/server.js`. - ## Lint Code If your IDE is VSCode, rename `web/.vscode/settings.example.json` to `web/.vscode/settings.json` for lint code setting. diff --git a/web/package.json b/web/package.json index 7a225d397f6597..88a0d1dc965410 100644 --- a/web/package.json +++ b/web/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next dev", + "start": "cp -r .next/static .next/standalone/.next/static && cp -r public .next/standalone/public && cross-env PORT=$npm_config_port HOSTNAME=$npm_config_host node .next/standalone/server.js", "lint": "next lint", "fix": "next lint --fix", "eslint-fix": "eslint --fix", @@ -95,6 +95,8 @@ "@types/react-window-infinite-loader": "^1.0.6", "@types/recordrtc": "^5.6.11", "@types/sortablejs": "^1.15.1", + "autoprefixer": "^10.4.14", + "cross-env": "^7.0.3", "eslint": "8.36.0", "eslint-config-next": "^13.4.7", "husky": "^8.0.3", @@ -102,10 +104,9 @@ "miragejs": "^0.1.47", "postcss": "^8.4.21", "sass": "^1.61.0", - "uglify-js": "^3.17.4", "tailwindcss": "^3.3.3", "typescript": "4.9.5", - "autoprefixer": "^10.4.14" + "uglify-js": "^3.17.4" }, "lint-staged": { "**/*.js?(x)": [ From ff527a0190f77f631f1fc44f1ad510d181744805 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 19 Oct 2023 13:55:25 +0800 Subject: [PATCH 2/4] fix: not load dataset config (#1381) --- web/app/components/app/configuration/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/app/components/app/configuration/index.tsx b/web/app/components/app/configuration/index.tsx index 619a7e260079f9..801c91bdd20243 100644 --- a/web/app/components/app/configuration/index.tsx +++ b/web/app/components/app/configuration/index.tsx @@ -342,7 +342,7 @@ const Configuration: FC = () => { } syncToPublishedConfig(config) setPublishedConfig(config) - + setDatasetConfigs(modelConfig.dataset_configs) setHasFetchedDetail(true) }) }, [appId]) From 07ca0354f2d3150dd083aa385a7efb5e4071df55 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 19 Oct 2023 16:47:32 +0800 Subject: [PATCH 3/4] feat: missing waring ui --- .../config-prompt/advanced-prompt-input.tsx | 95 ++++++++++++------- .../app/configuration/config-prompt/index.tsx | 7 ++ .../config-prompt/style.module.css | 5 + web/i18n/lang/app-debug.en.ts | 1 + web/i18n/lang/app-debug.zh.ts | 1 + 5 files changed, 74 insertions(+), 35 deletions(-) diff --git a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx index 972cbf62fabe97..eac8303b312b60 100644 --- a/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx +++ b/web/app/components/app/configuration/config-prompt/advanced-prompt-input.tsx @@ -18,6 +18,7 @@ import PromptEditor from '@/app/components/base/prompt-editor' import ConfigContext from '@/context/debug-configuration' import { getNewVar, getVars } from '@/utils/var' import { AppType } from '@/types/app' +import { AlertCircle } from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback' type Props = { type: PromptRole @@ -28,6 +29,8 @@ type Props = { canDelete: boolean onDelete: () => void promptVariables: PromptVariable[] + isContextMissing: boolean + onHideContextMissingTip: () => void } const AdvancedPromptInput: FC = ({ @@ -39,6 +42,8 @@ const AdvancedPromptInput: FC = ({ canDelete, onDelete, promptVariables, + isContextMissing, + onHideContextMissingTip, }) => { const { t } = useTranslation() @@ -91,45 +96,65 @@ const AdvancedPromptInput: FC = ({ } const editorHeight = isChatMode ? 'h-[200px]' : 'h-[508px]' - + const contextMissing = ( +
+
+ +
{t('appDebug.promptMode.contextMissing')}
+
+
{t('common.operation.ok')}
+
+ ) return ( -
+
-
- {isChatMode - ? ( - - ) - : ( -
+ {isContextMissing + ? contextMissing + : ( +
+ {isChatMode + ? ( + + ) + : ( +
-
{t('appDebug.pageTitle.line1')} -
- - {t('appDebug.promptTip')} -
} - selector='config-prompt-tooltip'> - - -
)} -
- {canDelete && ( - - )} - {!isCopied - ? ( - { - copy(value) - setIsCopied(true) - }} /> - ) - : ( - - )} +
{t('appDebug.pageTitle.line1')} +
+ + {t('appDebug.promptTip')} +
} + selector='config-prompt-tooltip'> + + +
)} +
+ {canDelete && ( + + )} + {!isCopied + ? ( + { + copy(value) + setIsCopied(true) + }} /> + ) + : ( + + )} +
+
+ )} -
-
= ({ setCurrentAdvancedPrompt(newPrompt) } + const isContextMissing = true + const [isHideContextMissTip, setIsHideContextMissTip] = React.useState(false) + if (!isAdvancedMode) { return ( = ({ onDelete={() => handlePromptDelete(index)} onChange={value => handleValueChange(value, index)} promptVariables={promptVariables} + isContextMissing={isContextMissing && !isHideContextMissTip} + onHideContextMissingTip={() => setIsHideContextMissTip(true)} /> )) ) @@ -125,6 +130,8 @@ const Prompt: FC = ({ onDelete={() => handlePromptDelete(0)} onChange={value => handleValueChange(value)} promptVariables={promptVariables} + isContextMissing={isContextMissing && !isHideContextMissTip} + onHideContextMissingTip={() => setIsHideContextMissTip(true)} /> ) } diff --git a/web/app/components/app/configuration/config-prompt/style.module.css b/web/app/components/app/configuration/config-prompt/style.module.css index 2c9f0022ae0083..66785620b33d26 100644 --- a/web/app/components/app/configuration/config-prompt/style.module.css +++ b/web/app/components/app/configuration/config-prompt/style.module.css @@ -14,6 +14,11 @@ box-sizing: border-box; } +.warningBorder { + border: 2px solid #F79009; + border-radius: 12px; +} + .optionWrap { display: none; } diff --git a/web/i18n/lang/app-debug.en.ts b/web/i18n/lang/app-debug.en.ts index ac88c32175d87c..63c8d769174acd 100644 --- a/web/i18n/lang/app-debug.en.ts +++ b/web/i18n/lang/app-debug.en.ts @@ -16,6 +16,7 @@ const translation = { operation: { addMessage: 'Add Message', }, + contextMissing: 'Context component missed, the effectiveness of the prompt may not be good.', }, operation: { applyConfig: 'Publish', diff --git a/web/i18n/lang/app-debug.zh.ts b/web/i18n/lang/app-debug.zh.ts index 31bad3d7a7f66a..2f6ea41f07c196 100644 --- a/web/i18n/lang/app-debug.zh.ts +++ b/web/i18n/lang/app-debug.zh.ts @@ -16,6 +16,7 @@ const translation = { operation: { addMessage: '添加消息', }, + contextMissing: '上下文内容块缺失,提示词的有效性可能不好。', }, operation: { applyConfig: '发布', From 20e776c18e8d1d8a8ace247fe5a777a15ce3e958 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 19 Oct 2023 16:51:10 +0800 Subject: [PATCH 4/4] feat: show missing logic --- web/app/components/app/configuration/config-prompt/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/app/components/app/configuration/config-prompt/index.tsx b/web/app/components/app/configuration/config-prompt/index.tsx index 930af8ef830ac1..8c789ae58b2873 100644 --- a/web/app/components/app/configuration/config-prompt/index.tsx +++ b/web/app/components/app/configuration/config-prompt/index.tsx @@ -34,6 +34,8 @@ const Prompt: FC = ({ currentAdvancedPrompt, setCurrentAdvancedPrompt, modelModeType, + dataSets, + hasSetBlockStatus, } = useContext(ConfigContext) const handleMessageTypeChange = (index: number, role: PromptRole) => { @@ -84,7 +86,7 @@ const Prompt: FC = ({ setCurrentAdvancedPrompt(newPrompt) } - const isContextMissing = true + const isContextMissing = dataSets.length > 0 && !hasSetBlockStatus.context const [isHideContextMissTip, setIsHideContextMissTip] = React.useState(false) if (!isAdvancedMode) {