mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
chore(web): fix lint
This commit is contained in:
parent
756606f478
commit
231783eebe
@ -97,7 +97,7 @@ const AppInfoDetailPanel = ({
|
|||||||
<ContentDialog
|
<ContentDialog
|
||||||
show={show}
|
show={show}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
className="absolute bottom-2 left-2 top-2 flex w-[420px] flex-col rounded-2xl p-0!"
|
className="absolute top-2 bottom-2 left-2 flex w-[420px] flex-col rounded-2xl p-0!"
|
||||||
>
|
>
|
||||||
<div className="flex shrink-0 flex-col items-start justify-center gap-3 self-stretch p-4">
|
<div className="flex shrink-0 flex-col items-start justify-center gap-3 self-stretch p-4">
|
||||||
<div className="flex items-center gap-3 self-stretch">
|
<div className="flex items-center gap-3 self-stretch">
|
||||||
@ -109,14 +109,14 @@ const AppInfoDetailPanel = ({
|
|||||||
imageUrl={appDetail.icon_url}
|
imageUrl={appDetail.icon_url}
|
||||||
/>
|
/>
|
||||||
<div className="flex flex-1 flex-col items-start justify-center overflow-hidden">
|
<div className="flex flex-1 flex-col items-start justify-center overflow-hidden">
|
||||||
<div className="w-full truncate text-text-secondary system-md-semibold">{appDetail.name}</div>
|
<div className="w-full truncate system-md-semibold text-text-secondary">{appDetail.name}</div>
|
||||||
<div className="text-text-tertiary system-2xs-medium-uppercase">
|
<div className="system-2xs-medium-uppercase text-text-tertiary">
|
||||||
{getAppModeLabel(appDetail.mode, t)}
|
{getAppModeLabel(appDetail.mode, t)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{appDetail.description && (
|
{appDetail.description && (
|
||||||
<div className="overflow-wrap-anywhere max-h-[105px] w-full max-w-full overflow-y-auto whitespace-normal wrap-break-word text-text-tertiary system-xs-regular">
|
<div className="overflow-wrap-anywhere max-h-[105px] w-full max-w-full overflow-y-auto system-xs-regular wrap-break-word whitespace-normal text-text-tertiary">
|
||||||
{appDetail.description}
|
{appDetail.description}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -142,7 +142,7 @@ const AppInfoDetailPanel = ({
|
|||||||
onClick={switchOperation.onClick}
|
onClick={switchOperation.onClick}
|
||||||
>
|
>
|
||||||
{switchOperation.icon}
|
{switchOperation.icon}
|
||||||
<span className="text-text-tertiary system-sm-medium">{switchOperation.title}</span>
|
<span className="system-sm-medium text-text-tertiary">{switchOperation.title}</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { ModelAndParameter } from '../configuration/debug/types'
|
import type { ModelAndParameter } from '../configuration/debug/types'
|
||||||
import type { InputVar, Variable } from '@/app/components/workflow/types'
|
import type { InputVar, Variable } from '@/app/components/workflow/types'
|
||||||
import type { I18nKeysByPrefix } from '@/types/i18n'
|
import type { I18nKeysByPrefix } from '@/types/i18n'
|
||||||
import type { PublishWorkflowParams } from '@/types/workflow'
|
import type { PublishWorkflowParams, WorkflowTypeConversionTarget } from '@/types/workflow'
|
||||||
import { useKeyPress } from 'ahooks'
|
import { useKeyPress } from 'ahooks'
|
||||||
import {
|
import {
|
||||||
memo,
|
memo,
|
||||||
@ -82,7 +82,7 @@ const AccessModeDisplay: React.FC<{ mode?: AccessMode }> = ({ mode }) => {
|
|||||||
<>
|
<>
|
||||||
<span className={`${icon} h-4 w-4 shrink-0 text-text-secondary`} />
|
<span className={`${icon} h-4 w-4 shrink-0 text-text-secondary`} />
|
||||||
<div className="grow truncate">
|
<div className="grow truncate">
|
||||||
<span className="text-text-secondary system-sm-medium">{t(`accessControlDialog.accessItems.${label}`, { ns: 'app' })}</span>
|
<span className="system-sm-medium text-text-secondary">{t(`accessControlDialog.accessItems.${label}`, { ns: 'app' })}</span>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
@ -270,7 +270,7 @@ const AppPublisher = ({
|
|||||||
appId: appDetail.id,
|
appId: appDetail.id,
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
target_type: workflowTypeSwitchConfig.targetType,
|
target_type: workflowTypeSwitchConfig.targetType as WorkflowTypeConversionTarget,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ const AppPublisher = ({
|
|||||||
<PortalToFollowElemTrigger onClick={handleTrigger}>
|
<PortalToFollowElemTrigger onClick={handleTrigger}>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
className="py-2 pl-3 pr-2"
|
className="py-2 pr-2 pl-3"
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
{t('common.publish', { ns: 'workflow' })}
|
{t('common.publish', { ns: 'workflow' })}
|
||||||
@ -331,13 +331,13 @@ const AppPublisher = ({
|
|||||||
<PortalToFollowElemContent className="z-11">
|
<PortalToFollowElemContent className="z-11">
|
||||||
<div className="w-[320px] rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl shadow-shadow-shadow-5">
|
<div className="w-[320px] rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl shadow-shadow-shadow-5">
|
||||||
<div className="p-4 pt-3">
|
<div className="p-4 pt-3">
|
||||||
<div className="flex h-6 items-center text-text-tertiary system-xs-medium-uppercase">
|
<div className="flex h-6 items-center system-xs-medium-uppercase text-text-tertiary">
|
||||||
{publishedAt ? t('common.latestPublished', { ns: 'workflow' }) : t('common.currentDraftUnpublished', { ns: 'workflow' })}
|
{publishedAt ? t('common.latestPublished', { ns: 'workflow' }) : t('common.currentDraftUnpublished', { ns: 'workflow' })}
|
||||||
</div>
|
</div>
|
||||||
{publishedAt
|
{publishedAt
|
||||||
? (
|
? (
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<div className="flex items-center text-text-secondary system-sm-medium">
|
<div className="flex items-center system-sm-medium text-text-secondary">
|
||||||
{t('common.publishedAt', { ns: 'workflow' })}
|
{t('common.publishedAt', { ns: 'workflow' })}
|
||||||
{' '}
|
{' '}
|
||||||
{formatTimeFromNow(publishedAt)}
|
{formatTimeFromNow(publishedAt)}
|
||||||
@ -355,7 +355,7 @@ const AppPublisher = ({
|
|||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
: (
|
: (
|
||||||
<div className="flex items-center text-text-secondary system-sm-medium">
|
<div className="flex items-center system-sm-medium text-text-secondary">
|
||||||
{t('common.autoSaved', { ns: 'workflow' })}
|
{t('common.autoSaved', { ns: 'workflow' })}
|
||||||
{' '}
|
{' '}
|
||||||
·
|
·
|
||||||
@ -392,7 +392,7 @@ const AppPublisher = ({
|
|||||||
{workflowTypeSwitchConfig && (
|
{workflowTypeSwitchConfig && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="flex h-8 w-full items-center justify-center gap-0.5 rounded-lg px-3 py-2 text-text-tertiary system-sm-medium hover:bg-state-base-hover disabled:cursor-not-allowed disabled:opacity-50"
|
className="flex h-8 w-full items-center justify-center gap-0.5 rounded-lg px-3 py-2 system-sm-medium text-text-tertiary hover:bg-state-base-hover disabled:cursor-not-allowed disabled:opacity-50"
|
||||||
onClick={handleWorkflowTypeSwitch}
|
onClick={handleWorkflowTypeSwitch}
|
||||||
disabled={publishDisabled || published || isConvertingWorkflowType}
|
disabled={publishDisabled || published || isConvertingWorkflowType}
|
||||||
>
|
>
|
||||||
@ -431,7 +431,7 @@ const AppPublisher = ({
|
|||||||
{showStartNodeLimitHint && (
|
{showStartNodeLimitHint && (
|
||||||
<div className="mt-3 flex flex-col items-stretch">
|
<div className="mt-3 flex flex-col items-stretch">
|
||||||
<p
|
<p
|
||||||
className="text-sm font-semibold leading-5 text-transparent"
|
className="text-sm leading-5 font-semibold text-transparent"
|
||||||
style={upgradeHighlightStyle}
|
style={upgradeHighlightStyle}
|
||||||
>
|
>
|
||||||
<span className="block">{t('publishLimit.startNodeTitlePrefix', { ns: 'workflow' })}</span>
|
<span className="block">{t('publishLimit.startNodeTitlePrefix', { ns: 'workflow' })}</span>
|
||||||
@ -442,7 +442,7 @@ const AppPublisher = ({
|
|||||||
</p>
|
</p>
|
||||||
<UpgradeBtn
|
<UpgradeBtn
|
||||||
isShort
|
isShort
|
||||||
className="mb-[12px] mt-[9px] h-[32px] w-[93px] self-start"
|
className="mt-[9px] mb-[12px] h-[32px] w-[93px] self-start"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -457,10 +457,10 @@ const AppPublisher = ({
|
|||||||
{systemFeatures.webapp_auth.enabled && (
|
{systemFeatures.webapp_auth.enabled && (
|
||||||
<div className="p-4 pt-3">
|
<div className="p-4 pt-3">
|
||||||
<div className="flex h-6 items-center">
|
<div className="flex h-6 items-center">
|
||||||
<p className="text-text-tertiary system-xs-medium">{t('publishApp.title', { ns: 'app' })}</p>
|
<p className="system-xs-medium text-text-tertiary">{t('publishApp.title', { ns: 'app' })}</p>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
className="flex h-8 cursor-pointer items-center gap-x-0.5 rounded-lg bg-components-input-bg-normal py-1 pl-2.5 pr-2 hover:bg-primary-50 hover:text-text-accent"
|
className="flex h-8 cursor-pointer items-center gap-x-0.5 rounded-lg bg-components-input-bg-normal py-1 pr-2 pl-2.5 hover:bg-primary-50 hover:text-text-accent"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setShowAppAccessControl(true)
|
setShowAppAccessControl(true)
|
||||||
}}
|
}}
|
||||||
@ -468,12 +468,12 @@ const AppPublisher = ({
|
|||||||
<div className="flex grow items-center gap-x-1.5 overflow-hidden pr-1">
|
<div className="flex grow items-center gap-x-1.5 overflow-hidden pr-1">
|
||||||
<AccessModeDisplay mode={appDetail?.access_mode} />
|
<AccessModeDisplay mode={appDetail?.access_mode} />
|
||||||
</div>
|
</div>
|
||||||
{!isAppAccessSet && <p className="shrink-0 text-text-tertiary system-xs-regular">{t('publishApp.notSet', { ns: 'app' })}</p>}
|
{!isAppAccessSet && <p className="shrink-0 system-xs-regular text-text-tertiary">{t('publishApp.notSet', { ns: 'app' })}</p>}
|
||||||
<div className="flex h-4 w-4 shrink-0 items-center justify-center">
|
<div className="flex h-4 w-4 shrink-0 items-center justify-center">
|
||||||
<span className="i-ri-arrow-right-s-line h-4 w-4 text-text-quaternary" />
|
<span className="i-ri-arrow-right-s-line h-4 w-4 text-text-quaternary" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{!isAppAccessSet && <p className="mt-1 text-text-warning system-xs-regular">{t('publishApp.notSetDesc', { ns: 'app' })}</p>}
|
{!isAppAccessSet && <p className="mt-1 system-xs-regular text-text-warning">{t('publishApp.notSetDesc', { ns: 'app' })}</p>}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
|
|||||||
@ -62,7 +62,7 @@ const TryLabel: FC<{
|
|||||||
}> = ({ Icon, text, onClick }) => {
|
}> = ({ Icon, text, onClick }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="mr-1 mt-2 flex h-7 shrink-0 cursor-pointer items-center rounded-lg bg-components-button-secondary-bg px-2"
|
className="mt-2 mr-1 flex h-7 shrink-0 cursor-pointer items-center rounded-lg bg-components-button-secondary-bg px-2"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
<Icon className="h-4 w-4 text-text-tertiary"></Icon>
|
<Icon className="h-4 w-4 text-text-tertiary"></Icon>
|
||||||
@ -89,7 +89,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
|
|||||||
const [model, setModel] = React.useState<Model>(localModel || {
|
const [model, setModel] = React.useState<Model>(localModel || {
|
||||||
name: '',
|
name: '',
|
||||||
provider: '',
|
provider: '',
|
||||||
mode: mode as unknown as ModelModeType.chat,
|
mode: mode as unknown as ModelModeType,
|
||||||
completion_params: {} as CompletionParams,
|
completion_params: {} as CompletionParams,
|
||||||
})
|
})
|
||||||
const {
|
const {
|
||||||
@ -283,7 +283,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
|
|||||||
<div className="flex h-[680px] flex-wrap">
|
<div className="flex h-[680px] flex-wrap">
|
||||||
<div className="h-full w-[570px] shrink-0 overflow-y-auto border-r border-divider-regular p-6">
|
<div className="h-full w-[570px] shrink-0 overflow-y-auto border-r border-divider-regular p-6">
|
||||||
<div className="mb-5">
|
<div className="mb-5">
|
||||||
<div className={`text-lg font-bold leading-[28px] ${s.textGradient}`}>{t('generate.title', { ns: 'appDebug' })}</div>
|
<div className={`text-lg leading-[28px] font-bold ${s.textGradient}`}>{t('generate.title', { ns: 'appDebug' })}</div>
|
||||||
<div className="mt-1 text-[13px] font-normal text-text-tertiary">{t('generate.description', { ns: 'appDebug' })}</div>
|
<div className="mt-1 text-[13px] font-normal text-text-tertiary">{t('generate.description', { ns: 'appDebug' })}</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -301,7 +301,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
|
|||||||
{isBasicMode && (
|
{isBasicMode && (
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<div className="mr-3 shrink-0 text-xs font-semibold uppercase leading-[18px] text-text-tertiary">{t('generate.tryIt', { ns: 'appDebug' })}</div>
|
<div className="mr-3 shrink-0 text-xs leading-[18px] font-semibold text-text-tertiary uppercase">{t('generate.tryIt', { ns: 'appDebug' })}</div>
|
||||||
<div
|
<div
|
||||||
className="h-px grow"
|
className="h-px grow"
|
||||||
style={{
|
style={{
|
||||||
@ -326,7 +326,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
|
|||||||
{/* inputs */}
|
{/* inputs */}
|
||||||
<div className="mt-4">
|
<div className="mt-4">
|
||||||
<div>
|
<div>
|
||||||
<div className="system-sm-semibold-uppercase mb-1.5 text-text-secondary">{t('generate.instruction', { ns: 'appDebug' })}</div>
|
<div className="mb-1.5 system-sm-semibold-uppercase text-text-secondary">{t('generate.instruction', { ns: 'appDebug' })}</div>
|
||||||
{isBasicMode
|
{isBasicMode
|
||||||
? (
|
? (
|
||||||
<InstructionEditorInBasic
|
<InstructionEditorInBasic
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
const [model, setModel] = React.useState<Model>(localModel || {
|
const [model, setModel] = React.useState<Model>(localModel || {
|
||||||
name: '',
|
name: '',
|
||||||
provider: '',
|
provider: '',
|
||||||
mode: mode as unknown as ModelModeType.chat,
|
mode: mode as unknown as ModelModeType,
|
||||||
completion_params: defaultCompletionParams,
|
completion_params: defaultCompletionParams,
|
||||||
})
|
})
|
||||||
const {
|
const {
|
||||||
@ -202,7 +202,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
<div className="relative flex h-[680px] flex-wrap">
|
<div className="relative flex h-[680px] flex-wrap">
|
||||||
<div className="h-full w-[570px] shrink-0 overflow-y-auto border-r border-divider-regular p-6">
|
<div className="h-full w-[570px] shrink-0 overflow-y-auto border-r border-divider-regular p-6">
|
||||||
<div className="mb-5">
|
<div className="mb-5">
|
||||||
<div className={`text-lg font-bold leading-[28px] ${s.textGradient}`}>{t('codegen.title', { ns: 'appDebug' })}</div>
|
<div className={`text-lg leading-[28px] font-bold ${s.textGradient}`}>{t('codegen.title', { ns: 'appDebug' })}</div>
|
||||||
<div className="mt-1 text-[13px] font-normal text-text-tertiary">{t('codegen.description', { ns: 'appDebug' })}</div>
|
<div className="mt-1 text-[13px] font-normal text-text-tertiary">{t('codegen.description', { ns: 'appDebug' })}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
@ -219,7 +219,7 @@ export const GetCodeGeneratorResModal: FC<IGetCodeGeneratorResProps> = (
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-[0px]">
|
<div className="text-[0px]">
|
||||||
<div className="mb-1.5 text-text-secondary system-sm-semibold-uppercase">{t('codegen.instruction', { ns: 'appDebug' })}</div>
|
<div className="mb-1.5 system-sm-semibold-uppercase text-text-secondary">{t('codegen.instruction', { ns: 'appDebug' })}</div>
|
||||||
<InstructionEditor
|
<InstructionEditor
|
||||||
editorKey={editorKey}
|
editorKey={editorKey}
|
||||||
value={instruction}
|
value={instruction}
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { parseAsStringLiteral } from 'nuqs'
|
import { parseAsStringLiteral } from 'nuqs'
|
||||||
import { AppModes } from '@/types/app'
|
import { AppModes } from '@/types/app'
|
||||||
|
|
||||||
export const APP_LIST_CATEGORY_VALUES = ['all', ...AppModes] as const
|
const APP_LIST_CATEGORY_VALUES = ['all', ...AppModes] as const
|
||||||
export type AppListCategory = typeof APP_LIST_CATEGORY_VALUES[number]
|
type AppListCategory = typeof APP_LIST_CATEGORY_VALUES[number]
|
||||||
|
export type { AppListCategory }
|
||||||
|
|
||||||
const appListCategorySet = new Set<string>(APP_LIST_CATEGORY_VALUES)
|
const appListCategorySet = new Set<string>(APP_LIST_CATEGORY_VALUES)
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import type { AppListCategory } from './app-type-filter-shared'
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import {
|
import {
|
||||||
@ -17,8 +18,8 @@ import { isAppListCategory } from './app-type-filter-shared'
|
|||||||
const chipClassName = 'flex h-8 items-center gap-1 rounded-lg border-[0.5px] border-transparent bg-components-input-bg-normal px-2 text-[13px] leading-[18px] text-text-secondary hover:bg-components-input-bg-hover'
|
const chipClassName = 'flex h-8 items-center gap-1 rounded-lg border-[0.5px] border-transparent bg-components-input-bg-normal px-2 text-[13px] leading-[18px] text-text-secondary hover:bg-components-input-bg-hover'
|
||||||
|
|
||||||
type AppTypeFilterProps = {
|
type AppTypeFilterProps = {
|
||||||
activeTab: import('./app-type-filter-shared').AppListCategory
|
activeTab: AppListCategory
|
||||||
onChange: (value: import('./app-type-filter-shared').AppListCategory) => void
|
onChange: (value: AppListCategory) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppTypeFilter = ({
|
const AppTypeFilter = ({
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import { parsePlacement } from '@/app/components/base/ui/placement'
|
|||||||
import { cn } from '@/utils/classnames'
|
import { cn } from '@/utils/classnames'
|
||||||
|
|
||||||
export const Select = BaseSelect.Root
|
export const Select = BaseSelect.Root
|
||||||
|
export const SelectGroup = BaseSelect.Group
|
||||||
|
export const SelectGroupLabel = BaseSelect.GroupLabel
|
||||||
export const SelectValue = BaseSelect.Value
|
export const SelectValue = BaseSelect.Value
|
||||||
|
|
||||||
const selectTriggerVariants = cva(
|
const selectTriggerVariants = cva(
|
||||||
@ -78,7 +80,7 @@ export function SelectTrigger({
|
|||||||
role="button"
|
role="button"
|
||||||
aria-label="Clear selection"
|
aria-label="Clear selection"
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
className="shrink-0 cursor-pointer text-text-quaternary hover:text-text-secondary group-data-disabled:hidden group-data-readonly:hidden"
|
className="shrink-0 cursor-pointer text-text-quaternary group-data-disabled:hidden group-data-readonly:hidden hover:text-text-secondary"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
onClear?.()
|
onClear?.()
|
||||||
@ -91,7 +93,7 @@ export function SelectTrigger({
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trailingIcon = (
|
trailingIcon = (
|
||||||
<BaseSelect.Icon className="shrink-0 text-text-quaternary transition-colors group-hover:text-text-secondary data-open:text-text-secondary group-data-readonly:hidden">
|
<BaseSelect.Icon className="shrink-0 text-text-quaternary transition-colors group-hover:text-text-secondary group-data-readonly:hidden data-open:text-text-secondary">
|
||||||
<span className="i-ri-arrow-down-s-line h-4 w-4" aria-hidden="true" />
|
<span className="i-ri-arrow-down-s-line h-4 w-4" aria-hidden="true" />
|
||||||
</BaseSelect.Icon>
|
</BaseSelect.Icon>
|
||||||
)
|
)
|
||||||
@ -169,7 +171,7 @@ export function SelectContent({
|
|||||||
<BaseSelect.Popup
|
<BaseSelect.Popup
|
||||||
className={cn(
|
className={cn(
|
||||||
'rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg',
|
'rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-lg',
|
||||||
'origin-(--transform-origin) transition-[transform,scale,opacity] data-ending-style:scale-95 data-starting-style:scale-95 data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none',
|
'origin-(--transform-origin) transition-[transform,scale,opacity] data-ending-style:scale-95 data-ending-style:opacity-0 data-starting-style:scale-95 data-starting-style:opacity-0 motion-reduce:transition-none',
|
||||||
popupClassName,
|
popupClassName,
|
||||||
)}
|
)}
|
||||||
{...popupProps}
|
{...popupProps}
|
||||||
@ -194,8 +196,8 @@ export function SelectItem({
|
|||||||
return (
|
return (
|
||||||
<BaseSelect.Item
|
<BaseSelect.Item
|
||||||
className={cn(
|
className={cn(
|
||||||
'flex h-8 cursor-pointer items-center rounded-lg px-2 text-text-secondary outline-hidden system-sm-medium',
|
'flex h-8 cursor-pointer items-center rounded-lg px-2 system-sm-medium text-text-secondary outline-hidden',
|
||||||
'data-disabled:cursor-not-allowed data-highlighted:bg-state-base-hover data-disabled:opacity-50',
|
'data-disabled:cursor-not-allowed data-disabled:opacity-50 data-highlighted:bg-state-base-hover',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export const toEvaluationTargetType = (resourceType: 'workflow' | 'snippet'): Ev
|
|||||||
return resourceType === 'snippet' ? 'snippets' : 'app'
|
return resourceType === 'snippet' ? 'snippets' : 'app'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const humanizeMetricId = (metricId: string) => {
|
const humanizeMetricId = (metricId: string) => {
|
||||||
return metricId
|
return metricId
|
||||||
.split(/[-_]/g)
|
.split(/[-_]/g)
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|||||||
@ -12,13 +12,13 @@ import type {
|
|||||||
import type { NodeInfo } from '@/types/evaluation'
|
import type { NodeInfo } from '@/types/evaluation'
|
||||||
import { getComparisonOperators, getDefaultOperator, getEvaluationMockConfig } from './mock'
|
import { getComparisonOperators, getDefaultOperator, getEvaluationMockConfig } from './mock'
|
||||||
|
|
||||||
export type EvaluationStoreResources = Record<string, EvaluationResourceState>
|
type EvaluationStoreResources = Record<string, EvaluationResourceState>
|
||||||
|
|
||||||
const createId = (prefix: string) => `${prefix}-${Math.random().toString(36).slice(2, 10)}`
|
const createId = (prefix: string) => `${prefix}-${Math.random().toString(36).slice(2, 10)}`
|
||||||
|
|
||||||
export const buildResourceKey = (resourceType: EvaluationResourceType, resourceId: string) => `${resourceType}:${resourceId}`
|
export const buildResourceKey = (resourceType: EvaluationResourceType, resourceId: string) => `${resourceType}:${resourceId}`
|
||||||
|
|
||||||
export const conditionOperatorsWithoutValue: ComparisonOperator[] = ['is_empty', 'is_not_empty']
|
const conditionOperatorsWithoutValue: ComparisonOperator[] = ['is_empty', 'is_not_empty']
|
||||||
|
|
||||||
export const requiresConditionValue = (operator: ComparisonOperator) => !conditionOperatorsWithoutValue.includes(operator)
|
export const requiresConditionValue = (operator: ComparisonOperator) => !conditionOperatorsWithoutValue.includes(operator)
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ export const buildInitialState = (resourceType: EvaluationResourceType): Evaluat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getResourceState = (
|
const getResourceState = (
|
||||||
resources: EvaluationStoreResources,
|
resources: EvaluationStoreResources,
|
||||||
resourceType: EvaluationResourceType,
|
resourceType: EvaluationResourceType,
|
||||||
resourceId: string,
|
resourceId: string,
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export type CreateSnippetDialogPayload = {
|
|||||||
graph: SnippetCanvasData
|
graph: SnippetCanvasData
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateSnippetDialogInitialValue = {
|
type CreateSnippetDialogInitialValue = {
|
||||||
name?: string
|
name?: string
|
||||||
description?: string
|
description?: string
|
||||||
icon?: AppIconSelection
|
icon?: AppIconSelection
|
||||||
@ -111,8 +111,8 @@ const CreateSnippetDialog: FC<CreateSnippetDialogProps> = ({
|
|||||||
<DialogContent className="w-[520px] max-w-[520px] p-0">
|
<DialogContent className="w-[520px] max-w-[520px] p-0">
|
||||||
<DialogCloseButton />
|
<DialogCloseButton />
|
||||||
|
|
||||||
<div className="px-6 pb-3 pt-6">
|
<div className="px-6 pt-6 pb-3">
|
||||||
<DialogTitle className="text-text-primary title-2xl-semi-bold">
|
<DialogTitle className="title-2xl-semi-bold text-text-primary">
|
||||||
{title || t('snippet.createDialogTitle', { ns: 'workflow' })}
|
{title || t('snippet.createDialogTitle', { ns: 'workflow' })}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
</div>
|
</div>
|
||||||
@ -120,7 +120,7 @@ const CreateSnippetDialog: FC<CreateSnippetDialogProps> = ({
|
|||||||
<div className="space-y-4 px-6 py-2">
|
<div className="space-y-4 px-6 py-2">
|
||||||
<div className="flex items-end gap-3">
|
<div className="flex items-end gap-3">
|
||||||
<div className="flex-1 pb-0.5">
|
<div className="flex-1 pb-0.5">
|
||||||
<div className="mb-1 flex h-6 items-center text-text-secondary system-sm-medium">
|
<div className="mb-1 flex h-6 items-center system-sm-medium text-text-secondary">
|
||||||
{t('snippet.nameLabel', { ns: 'workflow' })}
|
{t('snippet.nameLabel', { ns: 'workflow' })}
|
||||||
</div>
|
</div>
|
||||||
<Input
|
<Input
|
||||||
@ -144,7 +144,7 @@ const CreateSnippetDialog: FC<CreateSnippetDialogProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className="mb-1 flex h-6 items-center text-text-secondary system-sm-medium">
|
<div className="mb-1 flex h-6 items-center system-sm-medium text-text-secondary">
|
||||||
{t('snippet.descriptionLabel', { ns: 'workflow' })}
|
{t('snippet.descriptionLabel', { ns: 'workflow' })}
|
||||||
</div>
|
</div>
|
||||||
<Textarea
|
<Textarea
|
||||||
@ -157,7 +157,7 @@ const CreateSnippetDialog: FC<CreateSnippetDialogProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center justify-end gap-2 px-6 pb-6 pt-5">
|
<div className="flex items-center justify-end gap-2 px-6 pt-5 pb-6">
|
||||||
<Button disabled={isSubmitting} onClick={handleClose}>
|
<Button disabled={isSubmitting} onClick={handleClose}>
|
||||||
{t('operation.cancel', { ns: 'common' })}
|
{t('operation.cancel', { ns: 'common' })}
|
||||||
</Button>
|
</Button>
|
||||||
@ -174,7 +174,7 @@ const CreateSnippetDialog: FC<CreateSnippetDialogProps> = ({
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
<div className="pointer-events-none fixed left-1/2 top-1/2 z-[1002] flex -translate-x-1/2 translate-y-[170px] items-center gap-1 text-text-quaternary body-xs-regular">
|
<div className="pointer-events-none fixed top-1/2 left-1/2 z-[1002] flex -translate-x-1/2 translate-y-[170px] items-center gap-1 body-xs-regular text-text-quaternary">
|
||||||
<span>{t('snippet.shortcuts.press', { ns: 'workflow' })}</span>
|
<span>{t('snippet.shortcuts.press', { ns: 'workflow' })}</span>
|
||||||
<ShortcutsName keys={['ctrl', 'enter']} textColor="secondary" />
|
<ShortcutsName keys={['ctrl', 'enter']} textColor="secondary" />
|
||||||
<span>{t('snippet.shortcuts.toConfirm', { ns: 'workflow' })}</span>
|
<span>{t('snippet.shortcuts.toConfirm', { ns: 'workflow' })}</span>
|
||||||
|
|||||||
@ -76,10 +76,13 @@ describe('useConvertWorkflowTypeMutation', () => {
|
|||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(convertWorkflowTypeMutationFn).toHaveBeenCalledWith({
|
expect(convertWorkflowTypeMutationFn).toHaveBeenCalledWith(
|
||||||
params: { appId: 'app-1' },
|
{
|
||||||
query: { target_type: 'evaluation' },
|
params: { appId: 'app-1' },
|
||||||
})
|
query: { target_type: 'evaluation' },
|
||||||
|
},
|
||||||
|
expect.any(Object),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(invalidateQueries).toHaveBeenCalledWith({
|
expect(invalidateQueries).toHaveBeenCalledWith({
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import type {
|
|||||||
WorkflowDailyConversationsResponse,
|
WorkflowDailyConversationsResponse,
|
||||||
} from '@/models/app'
|
} from '@/models/app'
|
||||||
import type { App } from '@/types/app'
|
import type { App } from '@/types/app'
|
||||||
import type { WorkflowTypeConversionTarget } from '@/types/workflow'
|
|
||||||
import {
|
import {
|
||||||
keepPreviousData,
|
keepPreviousData,
|
||||||
useInfiniteQuery,
|
useInfiniteQuery,
|
||||||
@ -171,8 +170,6 @@ export const useConvertWorkflowTypeMutation = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { WorkflowTypeConversionTarget }
|
|
||||||
|
|
||||||
const useAppStatisticsQuery = <T>(metric: string, appId: string, params?: DateRangeParams) => {
|
const useAppStatisticsQuery = <T>(metric: string, appId: string, params?: DateRangeParams) => {
|
||||||
return useQuery<T>({
|
return useQuery<T>({
|
||||||
queryKey: [NAME_SPACE, 'statistics', metric, appId, params],
|
queryKey: [NAME_SPACE, 'statistics', metric, appId, params],
|
||||||
|
|||||||
@ -1,107 +1,6 @@
|
|||||||
import type {
|
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||||
EvaluationConfigData,
|
|
||||||
EvaluationNodeInfoRequest,
|
|
||||||
EvaluationTargetType,
|
|
||||||
} from '@/types/evaluation'
|
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
||||||
import { consoleQuery } from '@/service/client'
|
import { consoleQuery } from '@/service/client'
|
||||||
|
|
||||||
export type EvaluationResourceType = 'workflow' | 'pipeline' | 'snippet'
|
|
||||||
|
|
||||||
type EvaluationLogsParams = {
|
|
||||||
page?: number
|
|
||||||
page_size?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
type EvaluationRunDetailParams = {
|
|
||||||
page?: number
|
|
||||||
page_size?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const toEvaluationTargetType = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>): EvaluationTargetType => {
|
|
||||||
return resourceType === 'snippet' ? 'snippets' : 'app'
|
|
||||||
}
|
|
||||||
|
|
||||||
const invalidateEvaluationQueries = async (
|
|
||||||
queryClient: ReturnType<typeof useQueryClient>,
|
|
||||||
resourceType: EvaluationResourceType,
|
|
||||||
) => {
|
|
||||||
const queryKey = resourceType === 'pipeline'
|
|
||||||
? consoleQuery.datasetEvaluation.key()
|
|
||||||
: consoleQuery.evaluation.key()
|
|
||||||
|
|
||||||
await queryClient.invalidateQueries({ queryKey })
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useEvaluationConfig = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>, resourceId: string) => {
|
|
||||||
return useQuery(consoleQuery.evaluation.config.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
targetType: toEvaluationTargetType(resourceType),
|
|
||||||
targetId: resourceId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
enabled: !!resourceId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useDatasetEvaluationConfig = (datasetId: string) => {
|
|
||||||
return useQuery(consoleQuery.datasetEvaluation.config.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: { datasetId },
|
|
||||||
},
|
|
||||||
enabled: !!datasetId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useEvaluationLogs = (
|
|
||||||
resourceType: Exclude<EvaluationResourceType, 'pipeline'>,
|
|
||||||
resourceId: string,
|
|
||||||
params: EvaluationLogsParams = {},
|
|
||||||
) => {
|
|
||||||
return useQuery(consoleQuery.evaluation.logs.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
targetType: toEvaluationTargetType(resourceType),
|
|
||||||
targetId: resourceId,
|
|
||||||
},
|
|
||||||
query: params,
|
|
||||||
},
|
|
||||||
enabled: !!resourceId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useDatasetEvaluationLogs = (datasetId: string, params: EvaluationLogsParams = {}) => {
|
|
||||||
return useQuery(consoleQuery.datasetEvaluation.logs.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: { datasetId },
|
|
||||||
query: params,
|
|
||||||
},
|
|
||||||
enabled: !!datasetId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useEvaluationMetrics = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>, resourceId: string) => {
|
|
||||||
return useQuery(consoleQuery.evaluation.metrics.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
targetType: toEvaluationTargetType(resourceType),
|
|
||||||
targetId: resourceId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
enabled: !!resourceId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useDatasetEvaluationMetrics = (datasetId: string) => {
|
|
||||||
return useQuery(consoleQuery.datasetEvaluation.metrics.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: { datasetId },
|
|
||||||
},
|
|
||||||
enabled: !!datasetId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useAvailableEvaluationMetrics = (enabled = true) => {
|
export const useAvailableEvaluationMetrics = (enabled = true) => {
|
||||||
return useQuery(consoleQuery.evaluation.availableMetrics.queryOptions({
|
return useQuery(consoleQuery.evaluation.availableMetrics.queryOptions({
|
||||||
enabled,
|
enabled,
|
||||||
@ -111,112 +10,3 @@ export const useAvailableEvaluationMetrics = (enabled = true) => {
|
|||||||
export const useEvaluationNodeInfoMutation = () => {
|
export const useEvaluationNodeInfoMutation = () => {
|
||||||
return useMutation(consoleQuery.evaluation.nodeInfo.mutationOptions())
|
return useMutation(consoleQuery.evaluation.nodeInfo.mutationOptions())
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSaveEvaluationConfigMutation = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>) => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.evaluation.saveConfig.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, resourceType)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSaveDatasetEvaluationConfigMutation = () => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.datasetEvaluation.saveConfig.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, 'pipeline')
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useStartEvaluationRunMutation = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>) => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.evaluation.startRun.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, resourceType)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useStartDatasetEvaluationRunMutation = () => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.datasetEvaluation.startRun.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, 'pipeline')
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useCancelEvaluationRunMutation = (resourceType: Exclude<EvaluationResourceType, 'pipeline'>) => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.evaluation.cancelRun.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, resourceType)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useCancelDatasetEvaluationRunMutation = () => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.datasetEvaluation.cancelRun.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateEvaluationQueries(queryClient, 'pipeline')
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useEvaluationRunDetail = (
|
|
||||||
resourceType: Exclude<EvaluationResourceType, 'pipeline'>,
|
|
||||||
resourceId: string,
|
|
||||||
runId: string,
|
|
||||||
params: EvaluationRunDetailParams = {},
|
|
||||||
) => {
|
|
||||||
return useQuery(consoleQuery.evaluation.runDetail.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
targetType: toEvaluationTargetType(resourceType),
|
|
||||||
targetId: resourceId,
|
|
||||||
runId,
|
|
||||||
},
|
|
||||||
query: params,
|
|
||||||
},
|
|
||||||
enabled: !!resourceId && !!runId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useDatasetEvaluationRunDetail = (datasetId: string, runId: string, params: EvaluationRunDetailParams = {}) => {
|
|
||||||
return useQuery(consoleQuery.datasetEvaluation.runDetail.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
datasetId,
|
|
||||||
runId,
|
|
||||||
},
|
|
||||||
query: params,
|
|
||||||
},
|
|
||||||
enabled: !!datasetId && !!runId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export type {
|
|
||||||
EvaluationConfigData,
|
|
||||||
EvaluationNodeInfoRequest,
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,11 +2,6 @@ import type { SnippetWorkflow } from '@/types/snippet'
|
|||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { consoleQuery } from '@/service/client'
|
import { consoleQuery } from '@/service/client'
|
||||||
|
|
||||||
type WorkflowRunsParams = {
|
|
||||||
last_id?: string
|
|
||||||
limit?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const isNotFoundError = (error: unknown) => {
|
const isNotFoundError = (error: unknown) => {
|
||||||
return !!error && typeof error === 'object' && 'status' in error && error.status === 404
|
return !!error && typeof error === 'object' && 'status' in error && error.status === 404
|
||||||
}
|
}
|
||||||
@ -68,15 +63,6 @@ export const useSnippetDraftWorkflow = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSnippetDraftConfig = (snippetId: string) => {
|
|
||||||
return useQuery(consoleQuery.snippets.draftConfig.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: { snippetId },
|
|
||||||
},
|
|
||||||
enabled: !!snippetId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSnippetPublishedWorkflow = (
|
export const useSnippetPublishedWorkflow = (
|
||||||
snippetId: string,
|
snippetId: string,
|
||||||
onSuccess?: (publishedWorkflow: SnippetWorkflow) => void,
|
onSuccess?: (publishedWorkflow: SnippetWorkflow) => void,
|
||||||
@ -119,65 +105,6 @@ export const useSnippetDefaultBlockConfigs = (
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSnippetWorkflowRuns = (snippetId: string, params: WorkflowRunsParams = {}) => {
|
|
||||||
return useQuery(consoleQuery.snippets.workflowRuns.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: { snippetId },
|
|
||||||
query: params,
|
|
||||||
},
|
|
||||||
enabled: !!snippetId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSnippetWorkflowRunDetail = (snippetId: string, runId: string) => {
|
|
||||||
return useQuery(consoleQuery.snippets.workflowRunDetail.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
snippetId,
|
|
||||||
runId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
enabled: !!snippetId && !!runId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSnippetWorkflowRunNodeExecutions = (snippetId: string, runId: string) => {
|
|
||||||
return useQuery(consoleQuery.snippets.workflowRunNodeExecutions.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
snippetId,
|
|
||||||
runId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
enabled: !!snippetId && !!runId,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSnippetDraftNodeLastRun = (snippetId: string, nodeId: string, enabled = true) => {
|
|
||||||
return useQuery(consoleQuery.snippets.lastDraftNodeRun.queryOptions({
|
|
||||||
input: {
|
|
||||||
params: {
|
|
||||||
snippetId,
|
|
||||||
nodeId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
enabled: !!snippetId && !!nodeId && enabled,
|
|
||||||
retry: 0,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSyncSnippetDraftWorkflowMutation = (snippetId: string) => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.snippets.syncDraftWorkflow.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateSnippetWorkflowQueries(queryClient, snippetId)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const usePublishSnippetWorkflowMutation = (snippetId: string) => {
|
export const usePublishSnippetWorkflowMutation = (snippetId: string) => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
@ -189,31 +116,3 @@ export const usePublishSnippetWorkflowMutation = (snippetId: string) => {
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useRunSnippetDraftNodeMutation = () => {
|
|
||||||
return useMutation(consoleQuery.snippets.runDraftNode.mutationOptions())
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useRunSnippetDraftIterationNodeMutation = () => {
|
|
||||||
return useMutation(consoleQuery.snippets.runDraftIterationNode.mutationOptions())
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useRunSnippetDraftLoopNodeMutation = () => {
|
|
||||||
return useMutation(consoleQuery.snippets.runDraftLoopNode.mutationOptions())
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useRunSnippetDraftWorkflowMutation = () => {
|
|
||||||
return useMutation(consoleQuery.snippets.runDraftWorkflow.mutationOptions())
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useStopSnippetWorkflowTaskMutation = (snippetId: string) => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.snippets.stopWorkflowTask.mutationOptions({
|
|
||||||
onSuccess: async () => {
|
|
||||||
await invalidateSnippetWorkflowQueries(queryClient, snippetId)
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import type { Node } from '@/app/components/workflow/types'
|
import type { Node } from '@/app/components/workflow/types'
|
||||||
import type { SnippetDetailPayload, SnippetInputField, SnippetListItem } from '@/models/snippet'
|
import type { SnippetDetailPayload, SnippetInputField, SnippetListItem } from '@/models/snippet'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
|
||||||
import codeDefault from '@/app/components/workflow/nodes/code/default'
|
import codeDefault from '@/app/components/workflow/nodes/code/default'
|
||||||
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||||
import httpDefault from '@/app/components/workflow/nodes/http/default'
|
import httpDefault from '@/app/components/workflow/nodes/http/default'
|
||||||
@ -11,9 +10,7 @@ import { BlockEnum, PromptRole } from '@/app/components/workflow/types'
|
|||||||
import { PipelineInputVarType } from '@/models/pipeline'
|
import { PipelineInputVarType } from '@/models/pipeline'
|
||||||
import { AppModeEnum } from '@/types/app'
|
import { AppModeEnum } from '@/types/app'
|
||||||
|
|
||||||
const NAME_SPACE = 'snippets'
|
const getSnippetListMock = (): SnippetListItem[] => ([
|
||||||
|
|
||||||
export const getSnippetListMock = (): SnippetListItem[] => ([
|
|
||||||
{
|
{
|
||||||
id: 'snippet-1',
|
id: 'snippet-1',
|
||||||
name: 'Tone Rewriter',
|
name: 'Tone Rewriter',
|
||||||
@ -206,23 +203,3 @@ export const getSnippetDetailMock = (snippetId: string): SnippetDetailPayload |
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSnippetDetail = (snippetId: string) => {
|
|
||||||
return useQuery({
|
|
||||||
queryKey: [NAME_SPACE, 'detail', snippetId],
|
|
||||||
queryFn: async () => getSnippetDetailMock(snippetId),
|
|
||||||
enabled: !!snippetId,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const publishSnippet = async (_snippetId: string) => {
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
export const runSnippet = async (_snippetId: string) => {
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|
||||||
export const updateSnippetInputFields = async (_snippetId: string, _fields: SnippetInputField[]) => {
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
|
||||||
|
|||||||
@ -127,35 +127,8 @@ const normalizeSnippetListParams = (params: SnippetListParams) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isNotFoundError = (error: unknown) => {
|
|
||||||
return !!error && typeof error === 'object' && 'status' in error && error.status === 404
|
|
||||||
}
|
|
||||||
|
|
||||||
const snippetListKey = (params: SnippetListParams) => ['snippets', 'list', params]
|
const snippetListKey = (params: SnippetListParams) => ['snippets', 'list', params]
|
||||||
|
|
||||||
export const useSnippetList = (params: SnippetListParams = {}, options?: { enabled?: boolean }) => {
|
|
||||||
const query = normalizeSnippetListParams(params)
|
|
||||||
|
|
||||||
return useQuery(consoleQuery.snippets.list.queryOptions({
|
|
||||||
input: { query },
|
|
||||||
enabled: options?.enabled ?? true,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useSnippetListItems = (params: SnippetListParams = {}, options?: { enabled?: boolean }) => {
|
|
||||||
return useQuery<SnippetListItemUIModel[]>({
|
|
||||||
queryKey: [...consoleQuery.snippets.list.queryKey({ input: { query: normalizeSnippetListParams(params) } }), 'items'],
|
|
||||||
queryFn: async () => {
|
|
||||||
const response = await consoleClient.snippets.list({
|
|
||||||
query: normalizeSnippetListParams(params),
|
|
||||||
})
|
|
||||||
|
|
||||||
return response.data.map(toSnippetListItem)
|
|
||||||
},
|
|
||||||
enabled: options?.enabled ?? true,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useInfiniteSnippetList = (params: SnippetListParams = {}, options?: { enabled?: boolean }) => {
|
export const useInfiniteSnippetList = (params: SnippetListParams = {}, options?: { enabled?: boolean }) => {
|
||||||
const normalizedParams = normalizeSnippetListParams(params)
|
const normalizedParams = normalizeSnippetListParams(params)
|
||||||
|
|
||||||
@ -185,42 +158,6 @@ export const useSnippetApiDetail = (snippetId: string) => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSnippetDetail = (snippetId: string) => {
|
|
||||||
return useQuery<SnippetDetailPayload | null>({
|
|
||||||
queryKey: [...consoleQuery.snippets.detail.queryKey({
|
|
||||||
input: {
|
|
||||||
params: { snippetId },
|
|
||||||
},
|
|
||||||
}), 'payload'],
|
|
||||||
enabled: !!snippetId,
|
|
||||||
queryFn: async () => {
|
|
||||||
try {
|
|
||||||
const [snippet, workflow] = await Promise.all([
|
|
||||||
consoleClient.snippets.detail({
|
|
||||||
params: { snippetId },
|
|
||||||
}),
|
|
||||||
consoleClient.snippets.draftWorkflow({
|
|
||||||
params: { snippetId },
|
|
||||||
}).catch((error) => {
|
|
||||||
if (isNotFoundError(error))
|
|
||||||
return undefined
|
|
||||||
|
|
||||||
throw error
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
|
|
||||||
return buildSnippetDetailPayload(snippet, workflow)
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if (isNotFoundError(error))
|
|
||||||
return null
|
|
||||||
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useCreateSnippetMutation = () => {
|
export const useCreateSnippetMutation = () => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
@ -272,34 +209,6 @@ export const useExportSnippetMutation = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const usePublishSnippetMutation = () => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.snippets.publishWorkflow.mutationOptions({
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: consoleQuery.snippets.key(),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useIncrementSnippetUseCountMutation = () => {
|
|
||||||
const queryClient = useQueryClient()
|
|
||||||
|
|
||||||
return useMutation({
|
|
||||||
...consoleQuery.snippets.incrementUseCount.mutationOptions({
|
|
||||||
onSuccess: () => {
|
|
||||||
queryClient.invalidateQueries({
|
|
||||||
queryKey: consoleQuery.snippets.key(),
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useImportSnippetDSLMutation = () => {
|
export const useImportSnippetDSLMutation = () => {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
|
||||||
|
|||||||
129
web/types/app.ts
129
web/types/app.ts
@ -10,50 +10,71 @@ import type {
|
|||||||
} from '@/models/datasets'
|
} from '@/models/datasets'
|
||||||
import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug'
|
import type { AnnotationReplyConfig, ChatPromptConfig, CompletionPromptConfig, DatasetConfigs, PromptMode } from '@/models/debug'
|
||||||
|
|
||||||
export enum Theme {
|
export type Theme = 'light' | 'dark' | 'system'
|
||||||
light = 'light',
|
export const Theme = {
|
||||||
dark = 'dark',
|
light: 'light' as Theme,
|
||||||
system = 'system',
|
dark: 'dark' as Theme,
|
||||||
}
|
system: 'system' as Theme,
|
||||||
|
} as const
|
||||||
|
|
||||||
export enum ModelModeType {
|
export type ModelModeType = 'chat' | 'completion' | ''
|
||||||
chat = 'chat',
|
export const ModelModeType = {
|
||||||
completion = 'completion',
|
chat: 'chat' as ModelModeType,
|
||||||
unset = '',
|
completion: 'completion' as ModelModeType,
|
||||||
}
|
unset: '' as ModelModeType,
|
||||||
|
} as const
|
||||||
|
|
||||||
export enum RETRIEVE_TYPE {
|
export type RETRIEVE_TYPE = 'single' | 'multiple'
|
||||||
oneWay = 'single',
|
export const RETRIEVE_TYPE = {
|
||||||
multiWay = 'multiple',
|
oneWay: 'single' as RETRIEVE_TYPE,
|
||||||
}
|
multiWay: 'multiple' as RETRIEVE_TYPE,
|
||||||
|
} as const
|
||||||
|
|
||||||
export enum RETRIEVE_METHOD {
|
export type RETRIEVE_METHOD
|
||||||
semantic = 'semantic_search',
|
= | 'semantic_search'
|
||||||
fullText = 'full_text_search',
|
| 'full_text_search'
|
||||||
hybrid = 'hybrid_search',
|
| 'hybrid_search'
|
||||||
invertedIndex = 'invertedIndex',
|
| 'invertedIndex'
|
||||||
keywordSearch = 'keyword_search',
|
| 'keyword_search'
|
||||||
}
|
export const RETRIEVE_METHOD = {
|
||||||
|
semantic: 'semantic_search' as RETRIEVE_METHOD,
|
||||||
|
fullText: 'full_text_search' as RETRIEVE_METHOD,
|
||||||
|
hybrid: 'hybrid_search' as RETRIEVE_METHOD,
|
||||||
|
invertedIndex: 'invertedIndex' as RETRIEVE_METHOD,
|
||||||
|
keywordSearch: 'keyword_search' as RETRIEVE_METHOD,
|
||||||
|
} as const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App modes
|
* App modes
|
||||||
*/
|
*/
|
||||||
export enum AppModeEnum {
|
export type AppModeEnum
|
||||||
COMPLETION = 'completion',
|
= | 'completion'
|
||||||
WORKFLOW = 'workflow',
|
| 'workflow'
|
||||||
CHAT = 'chat',
|
| 'chat'
|
||||||
ADVANCED_CHAT = 'advanced-chat',
|
| 'advanced-chat'
|
||||||
AGENT_CHAT = 'agent-chat',
|
| 'agent-chat'
|
||||||
}
|
export const AppModeEnum = {
|
||||||
|
COMPLETION: 'completion' as AppModeEnum,
|
||||||
|
WORKFLOW: 'workflow' as AppModeEnum,
|
||||||
|
CHAT: 'chat' as AppModeEnum,
|
||||||
|
ADVANCED_CHAT: 'advanced-chat' as AppModeEnum,
|
||||||
|
AGENT_CHAT: 'agent-chat' as AppModeEnum,
|
||||||
|
} as const
|
||||||
export const AppModes = [AppModeEnum.COMPLETION, AppModeEnum.WORKFLOW, AppModeEnum.CHAT, AppModeEnum.ADVANCED_CHAT, AppModeEnum.AGENT_CHAT] as const
|
export const AppModes = [AppModeEnum.COMPLETION, AppModeEnum.WORKFLOW, AppModeEnum.CHAT, AppModeEnum.ADVANCED_CHAT, AppModeEnum.AGENT_CHAT] as const
|
||||||
|
|
||||||
export enum AppTypeEnum {
|
export type AppTypeEnum
|
||||||
WORKFLOW = 'workflow',
|
= | 'workflow'
|
||||||
CHAT = 'chat',
|
| 'chat'
|
||||||
RAG_PIPELINE = 'rag-pipeline',
|
| 'rag-pipeline'
|
||||||
SNIPPET = 'snippet',
|
| 'snippet'
|
||||||
EVALUATION = 'evaluation',
|
| 'evaluation'
|
||||||
}
|
export const AppTypeEnum = {
|
||||||
|
WORKFLOW: 'workflow' as AppTypeEnum,
|
||||||
|
CHAT: 'chat' as AppTypeEnum,
|
||||||
|
RAG_PIPELINE: 'rag-pipeline' as AppTypeEnum,
|
||||||
|
SNIPPET: 'snippet' as AppTypeEnum,
|
||||||
|
EVALUATION: 'evaluation' as AppTypeEnum,
|
||||||
|
} as const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Variable type
|
* Variable type
|
||||||
@ -131,10 +152,11 @@ export type ToolItem = {
|
|||||||
}
|
}
|
||||||
} | AgentTool
|
} | AgentTool
|
||||||
|
|
||||||
export enum AgentStrategy {
|
export type AgentStrategy = 'function_call' | 'react'
|
||||||
functionCall = 'function_call',
|
export const AgentStrategy = {
|
||||||
react = 'react',
|
functionCall: 'function_call' as AgentStrategy,
|
||||||
}
|
react: 'react' as AgentStrategy,
|
||||||
|
} as const
|
||||||
|
|
||||||
export type CompletionParams = {
|
export type CompletionParams = {
|
||||||
/** Maximum number of tokens in the answer message returned by Completion */
|
/** Maximum number of tokens in the answer message returned by Completion */
|
||||||
@ -376,21 +398,24 @@ export type AppSSO = {
|
|||||||
enable_sso: boolean
|
enable_sso: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Resolution {
|
export type Resolution = 'low' | 'high'
|
||||||
low = 'low',
|
export const Resolution = {
|
||||||
high = 'high',
|
low: 'low' as Resolution,
|
||||||
}
|
high: 'high' as Resolution,
|
||||||
|
} as const
|
||||||
|
|
||||||
export enum TransferMethod {
|
export type TransferMethod = 'all' | 'local_file' | 'remote_url'
|
||||||
all = 'all',
|
export const TransferMethod = {
|
||||||
local_file = 'local_file',
|
all: 'all' as TransferMethod,
|
||||||
remote_url = 'remote_url',
|
local_file: 'local_file' as TransferMethod,
|
||||||
}
|
remote_url: 'remote_url' as TransferMethod,
|
||||||
|
} as const
|
||||||
|
|
||||||
export enum TtsAutoPlay {
|
export type TtsAutoPlay = 'enabled' | 'disabled'
|
||||||
enabled = 'enabled',
|
export const TtsAutoPlay = {
|
||||||
disabled = 'disabled',
|
enabled: 'enabled' as TtsAutoPlay,
|
||||||
}
|
disabled: 'disabled' as TtsAutoPlay,
|
||||||
|
} as const
|
||||||
|
|
||||||
export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif']
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user