Skip to content

Commit

Permalink
feat: use show_workflow_steps
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywoola committed Jun 21, 2024
1 parent 5ff620e commit fde7261
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions api/controllers/console/app/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/web/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions api/fields/app_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -20,14 +20,14 @@
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 ###


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 ###
2 changes: 1 addition & 1 deletion api/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions web/app/components/app/overview/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -48,8 +48,8 @@ const SettingsModal: FC<ISettingsModalProps> = ({
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()
Expand All @@ -58,7 +58,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
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])
Expand Down Expand Up @@ -86,7 +86,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
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)
Expand Down Expand Up @@ -139,9 +139,9 @@ const SettingsModal: FC<ISettingsModalProps> = ({
{(appInfo.mode === 'workflow' || appInfo.mode === 'advanced-chat') && <>
<div className={`mt-6 mb-2 font-medium ${s.settingTitle} text-gray-900 `}>{t(`${prefixSettings}.workflow.title`)}</div>
<SimpleSelect
items={[{ name: t(`${prefixSettings}.workflow.show`), value: 'show' }, { name: t(`${prefixSettings}.workflow.hide`), value: 'hide' }]}
defaultValue={inputInfo.workflow}
onSelect={item => 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 && <div className='w-full cursor-pointer mt-8' onClick={() => setIsShowMore(true)}>
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/app/text-generate/item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
}
<div className={`flex ${contentClassName}`}>
<div className='grow w-0'>
{siteInfo && siteInfo.workflow === 'show' && workflowProcessData && (
{siteInfo && siteInfo.show_workflow_steps && workflowProcessData && (
<WorkflowProcessItem grayBg hideInfo data={workflowProcessData} expand={workflowProcessData.expand} hideProcessDetail={hideProcessDetail} />
)}
{workflowProcessData && !isError && (
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/base/chat/chat-with-history/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/base/chat/chat/answer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const Answer: FC<AnswerProps> = ({
}
{/** Hide workflow steps by it's settings in siteInfo */}
{
workflowProcess && hideProcessDetail && appData && appData.site.workflow === 'show' && (
workflowProcess && hideProcessDetail && appData && appData.site.show_workflow_steps && (
<WorkflowProcess
data={workflowProcess}
item={item}
Expand Down
2 changes: 1 addition & 1 deletion web/models/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type SiteInfo = {
copyright?: string
privacy_policy?: string
custom_disclaimer?: string
workflow?: string
show_workflow_steps?: boolean
}

export type AppMeta = {
Expand Down
2 changes: 1 addition & 1 deletion web/types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export type SiteConfig = {
icon: string
icon_background: string

workflow: string
show_workflow_steps: boolean
}

/**
Expand Down

0 comments on commit fde7261

Please sign in to comment.