diff --git a/api/controllers/console/app/site.py b/api/controllers/console/app/site.py index 28860bd6cb82ec..2024db65b29975 100644 --- a/api/controllers/console/app/site.py +++ b/api/controllers/console/app/site.py @@ -28,7 +28,7 @@ def parse_app_site_args(): required=False, location='json') parser.add_argument('prompt_public', type=bool, required=False, location='json') - parser.add_argument('workflow', type=str, choices=['show', 'hide'], required=False, location='json') + parser.add_argument('show_workflow_steps', type=bool, required=False, location='json') return parser.parse_args() @@ -61,7 +61,7 @@ def post(self, app_model): 'custom_disclaimer', 'customize_token_strategy', 'prompt_public', - 'workflow' + 'show_workflow_steps' ]: value = args.get(attr_name) if value is not None: diff --git a/api/controllers/web/site.py b/api/controllers/web/site.py index 6df5d08d259f00..c5c70d810a3a5b 100644 --- a/api/controllers/web/site.py +++ b/api/controllers/web/site.py @@ -34,7 +34,7 @@ class AppSiteApi(WebApiResource): 'custom_disclaimer': fields.String, 'default_language': fields.String, 'prompt_public': fields.Boolean, - 'workflow': fields.String, + 'show_workflow_steps': fields.Boolean, } app_fields = { diff --git a/api/fields/app_fields.py b/api/fields/app_fields.py index 578b304ae6b5ee..e314fa21a38bce 100644 --- a/api/fields/app_fields.py +++ b/api/fields/app_fields.py @@ -117,7 +117,7 @@ 'customize_token_strategy': fields.String, 'prompt_public': fields.Boolean, 'app_base_url': fields.String, - 'workflow': fields.String, + 'show_workflow_steps': fields.Boolean, } app_detail_fields_with_site = { @@ -151,5 +151,5 @@ 'custom_disclaimer': fields.String, 'customize_token_strategy': fields.String, 'prompt_public': fields.Boolean, - 'workflow': fields.String, + 'show_workflow_steps': fields.Boolean, } diff --git a/api/migrations/versions/a31f72360d4f_add_workflow_to_site.py b/api/migrations/versions/4ff534e1eb11_add_workflow_to_site.py similarity index 69% rename from api/migrations/versions/a31f72360d4f_add_workflow_to_site.py rename to api/migrations/versions/4ff534e1eb11_add_workflow_to_site.py index 31ea1949b9b8cc..da3e45cc4e187a 100644 --- a/api/migrations/versions/a31f72360d4f_add_workflow_to_site.py +++ b/api/migrations/versions/4ff534e1eb11_add_workflow_to_site.py @@ -1,8 +1,8 @@ """add workflow to site -Revision ID: a31f72360d4f +Revision ID: 4ff534e1eb11 Revises: 7b45942e39bb -Create Date: 2024-06-20 05:28:22.081291 +Create Date: 2024-06-21 04:16:03.419634 """ import sqlalchemy as sa @@ -11,7 +11,7 @@ import models as models # revision identifiers, used by Alembic. -revision = 'a31f72360d4f' +revision = '4ff534e1eb11' down_revision = '7b45942e39bb' branch_labels = None depends_on = None @@ -20,7 +20,7 @@ def upgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('sites', schema=None) as batch_op: - batch_op.add_column(sa.Column('workflow', sa.String(length=255), nullable=True, server_default='show')) + batch_op.add_column(sa.Column('show_workflow_steps', sa.Boolean(), server_default=sa.text('false'), nullable=False)) # ### end Alembic commands ### @@ -28,6 +28,6 @@ def upgrade(): def downgrade(): # ### commands auto generated by Alembic - please adjust! ### with op.batch_alter_table('sites', schema=None) as batch_op: - batch_op.drop_column('workflow') + batch_op.drop_column('show_workflow_steps') # ### end Alembic commands ### diff --git a/api/models/model.py b/api/models/model.py index 58fdb571533d8e..efe387734317f6 100644 --- a/api/models/model.py +++ b/api/models/model.py @@ -1043,7 +1043,7 @@ class Site(db.Model): default_language = db.Column(db.String(255), nullable=False) copyright = db.Column(db.String(255)) privacy_policy = db.Column(db.String(255)) - workflow = db.Column(db.String(255)) + show_workflow_steps = db.Column(db.Boolean, nullable=False, server_default=db.text('false')) custom_disclaimer = db.Column(db.String(255), nullable=True) customize_domain = db.Column(db.String(255)) customize_token_strategy = db.Column(db.String(255), nullable=False) diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx index 8af52e1fde4260..01bd5525e24428 100644 --- a/web/app/components/app/overview/settings/index.tsx +++ b/web/app/components/app/overview/settings/index.tsx @@ -34,7 +34,7 @@ export type ConfigParams = { custom_disclaimer: string icon: string icon_background: string - workflow: string + show_workflow_steps: boolean } const prefixSettings = 'appOverview.overview.appInfo.settings' @@ -48,8 +48,8 @@ const SettingsModal: FC = ({ const { notify } = useToastContext() const [isShowMore, setIsShowMore] = useState(false) const { icon, icon_background } = appInfo - const { title, description, copyright, privacy_policy, custom_disclaimer, default_language, workflow } = appInfo.site - const [inputInfo, setInputInfo] = useState({ title, desc: description, copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, workflow }) + const { title, description, copyright, privacy_policy, custom_disclaimer, default_language, show_workflow_steps } = appInfo.site + const [inputInfo, setInputInfo] = useState({ title, desc: description, copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, show_workflow_steps }) const [language, setLanguage] = useState(default_language) const [saveLoading, setSaveLoading] = useState(false) const { t } = useTranslation() @@ -58,7 +58,7 @@ const SettingsModal: FC = ({ const [emoji, setEmoji] = useState({ icon, icon_background }) useEffect(() => { - setInputInfo({ title, desc: description, copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, workflow }) + setInputInfo({ title, desc: description, copyright, privacyPolicy: privacy_policy, customDisclaimer: custom_disclaimer, show_workflow_steps }) setLanguage(default_language) setEmoji({ icon, icon_background }) }, [appInfo]) @@ -86,7 +86,7 @@ const SettingsModal: FC = ({ custom_disclaimer: inputInfo.customDisclaimer, icon: emoji.icon, icon_background: emoji.icon_background, - workflow: inputInfo.workflow, + show_workflow_steps: inputInfo.show_workflow_steps, } await onSave?.(params) setSaveLoading(false) @@ -139,9 +139,9 @@ const SettingsModal: FC = ({ {(appInfo.mode === 'workflow' || appInfo.mode === 'advanced-chat') && <>
{t(`${prefixSettings}.workflow.title`)}
setInputInfo({ ...inputInfo, workflow: item.value as string })} + items={[{ name: t(`${prefixSettings}.workflow.show`), value: 'true' }, { name: t(`${prefixSettings}.workflow.hide`), value: 'false' }]} + defaultValue={inputInfo.show_workflow_steps ? 'true' : 'false'} + onSelect={item => setInputInfo({ ...inputInfo, show_workflow_steps: item.value === 'true' })} /> } {!isShowMore &&
setIsShowMore(true)}> diff --git a/web/app/components/app/text-generate/item/index.tsx b/web/app/components/app/text-generate/item/index.tsx index 5d7a5831a2bd31..486ab90edbc560 100644 --- a/web/app/components/app/text-generate/item/index.tsx +++ b/web/app/components/app/text-generate/item/index.tsx @@ -301,7 +301,7 @@ const GenerationItem: FC = ({ }
- {siteInfo && siteInfo.workflow === 'show' && workflowProcessData && ( + {siteInfo && siteInfo.show_workflow_steps && workflowProcessData && ( )} {workflowProcessData && !isError && ( diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsx index dd9efb3e7e4c48..ab8b3648e7dae9 100644 --- a/web/app/components/base/chat/chat-with-history/hooks.tsx +++ b/web/app/components/base/chat/chat-with-history/hooks.tsx @@ -53,7 +53,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { icon_background: app.icon_background, prompt_public: false, copyright: '', - workflow: 'show', + show_workflow_steps: true, }, plan: 'basic', } as AppData diff --git a/web/app/components/base/chat/chat/answer/index.tsx b/web/app/components/base/chat/chat/answer/index.tsx index afd89e9b090de8..213ac99e28dfbd 100644 --- a/web/app/components/base/chat/chat/answer/index.tsx +++ b/web/app/components/base/chat/chat/answer/index.tsx @@ -145,7 +145,7 @@ const Answer: FC = ({ } {/** Hide workflow steps by it's settings in siteInfo */} { - workflowProcess && hideProcessDetail && appData && appData.site.workflow === 'show' && ( + workflowProcess && hideProcessDetail && appData && appData.site.show_workflow_steps && (