mirror of https://github.com/langgenius/dify.git
chore: try app can use web app run
This commit is contained in:
parent
73845cbec5
commit
8353352bda
|
|
@ -52,7 +52,7 @@ export type IGenerationItemProps = {
|
|||
onFeedback?: (feedback: FeedbackType) => void
|
||||
onSave?: (messageId: string) => void
|
||||
isMobile?: boolean
|
||||
isInstalledApp: boolean
|
||||
appSourceType: AppSourceType
|
||||
installedAppId?: string
|
||||
taskId?: string
|
||||
controlClearMoreLikeThis?: number
|
||||
|
|
@ -86,7 +86,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||
onSave,
|
||||
depth = 1,
|
||||
isMobile,
|
||||
isInstalledApp,
|
||||
appSourceType,
|
||||
installedAppId,
|
||||
taskId,
|
||||
controlClearMoreLikeThis,
|
||||
|
|
@ -111,8 +111,6 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||
const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem)
|
||||
const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal)
|
||||
|
||||
const appSourceType = isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp
|
||||
|
||||
const handleFeedback = async (childFeedback: FeedbackType) => {
|
||||
await updateFeedback({ url: `/messages/${childMessageId}/feedbacks`, body: { rating: childFeedback.rating } }, appSourceType, installedAppId)
|
||||
setChildFeedback(childFeedback)
|
||||
|
|
@ -132,7 +130,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||
onSave,
|
||||
isShowTextToSpeech,
|
||||
isMobile,
|
||||
isInstalledApp,
|
||||
appSourceType,
|
||||
installedAppId,
|
||||
controlClearMoreLikeThis,
|
||||
isWorkflow,
|
||||
|
|
@ -294,7 +292,7 @@ const GenerationItem: FC<IGenerationItemProps> = ({
|
|||
{!isWorkflow && <span>{content?.length} {t('common.unit.char')}</span>}
|
||||
{/* action buttons */}
|
||||
<div className='absolute bottom-1 right-2 flex items-center'>
|
||||
{!isInWebApp && !isInstalledApp && !isResponding && (
|
||||
{!isInWebApp && (appSourceType !== AppSourceType.installedApp) && !isResponding && (
|
||||
<div className='ml-1 flex items-center gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-sm'>
|
||||
<ActionButton disabled={isError || !messageId} onClick={handleOpenLogModal}>
|
||||
<RiFileList3Line className='h-4 w-4' />
|
||||
|
|
|
|||
|
|
@ -401,8 +401,8 @@ const TextGeneration: FC<IMainProps> = ({
|
|||
isCallBatchAPI={isCallBatchAPI}
|
||||
isPC={isPC}
|
||||
isMobile={!isPC}
|
||||
isInstalledApp={isInstalledApp}
|
||||
installedAppInfo={installedAppInfo}
|
||||
appSourceType={isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp}
|
||||
appId={installedAppInfo?.id}
|
||||
isError={task?.status === TaskStatus.failed}
|
||||
promptConfig={promptConfig}
|
||||
moreLikeThisEnabled={!!moreLikeThisConfig?.enabled}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import produce from 'immer'
|
|||
import TextGenerationRes from '@/app/components/app/text-generate/item'
|
||||
import NoData from '@/app/components/share/text-generation/no-data'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { AppSourceType, sendCompletionMessage, sendWorkflowMessage, updateFeedback } from '@/service/share'
|
||||
import type { AppSourceType } from '@/service/share'
|
||||
import { sendCompletionMessage, sendWorkflowMessage, updateFeedback } from '@/service/share'
|
||||
import type { FeedbackType } from '@/app/components/base/chat/chat/type'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import type { PromptConfig } from '@/models/debug'
|
||||
import type { InstalledApp } from '@/models/explore'
|
||||
import { TransferMethod, type VisionFile, type VisionSettings } from '@/types/app'
|
||||
import { NodeRunningStatus, WorkflowRunningStatus } from '@/app/components/workflow/types'
|
||||
import type { WorkflowProcess } from '@/app/components/base/chat/types'
|
||||
|
|
@ -28,8 +28,8 @@ export type IResultProps = {
|
|||
isCallBatchAPI: boolean
|
||||
isPC: boolean
|
||||
isMobile: boolean
|
||||
isInstalledApp: boolean
|
||||
installedAppInfo?: InstalledApp
|
||||
appSourceType: AppSourceType
|
||||
appId?: string
|
||||
isError: boolean
|
||||
isShowTextToSpeech: boolean
|
||||
promptConfig: PromptConfig | null
|
||||
|
|
@ -53,8 +53,8 @@ const Result: FC<IResultProps> = ({
|
|||
isCallBatchAPI,
|
||||
isPC,
|
||||
isMobile,
|
||||
isInstalledApp,
|
||||
installedAppInfo,
|
||||
appSourceType,
|
||||
appId,
|
||||
isError,
|
||||
isShowTextToSpeech,
|
||||
promptConfig,
|
||||
|
|
@ -72,7 +72,6 @@ const Result: FC<IResultProps> = ({
|
|||
siteInfo,
|
||||
onRunStart,
|
||||
}) => {
|
||||
const appSourceType = isInstalledApp ? AppSourceType.installedApp : AppSourceType.webApp
|
||||
const [isResponding, { setTrue: setRespondingTrue, setFalse: setRespondingFalse }] = useBoolean(false)
|
||||
useEffect(() => {
|
||||
if (controlStopResponding)
|
||||
|
|
@ -103,7 +102,7 @@ const Result: FC<IResultProps> = ({
|
|||
})
|
||||
|
||||
const handleFeedback = async (feedback: FeedbackType) => {
|
||||
await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, appSourceType, installedAppInfo?.id)
|
||||
await updateFeedback({ url: `/messages/${messageId}/feedbacks`, body: { rating: feedback.rating, content: feedback.content } }, appSourceType, appId)
|
||||
setFeedback(feedback)
|
||||
}
|
||||
|
||||
|
|
@ -360,7 +359,7 @@ const Result: FC<IResultProps> = ({
|
|||
},
|
||||
},
|
||||
appSourceType,
|
||||
installedAppInfo?.id,
|
||||
appId,
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
|
@ -393,7 +392,7 @@ const Result: FC<IResultProps> = ({
|
|||
onCompleted(getCompletionRes(), taskId, false)
|
||||
isEnd = true
|
||||
},
|
||||
}, appSourceType, installedAppInfo?.id)
|
||||
}, appSourceType, appId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -424,8 +423,8 @@ const Result: FC<IResultProps> = ({
|
|||
feedback={feedback}
|
||||
onSave={handleSaveMessage}
|
||||
isMobile={isMobile}
|
||||
isInstalledApp={isInstalledApp}
|
||||
installedAppId={installedAppInfo?.id}
|
||||
appSourceType={appSourceType}
|
||||
installedAppId={appId}
|
||||
isLoading={isCallBatchAPI ? (!completionRes && isResponding) : false}
|
||||
taskId={isCallBatchAPI ? ((taskId as number) < 10 ? `0${taskId}` : `${taskId}`) : undefined}
|
||||
controlClearMoreLikeThis={controlClearMoreLikeThis}
|
||||
|
|
|
|||
|
|
@ -20,18 +20,19 @@ import Res from '@/app/components/share/text-generation/result'
|
|||
import type { Task } from '../../share/text-generation/types'
|
||||
import { TaskStatus } from '../../share/text-generation/types'
|
||||
import { noop } from 'lodash'
|
||||
import { AppSourceType } from '@/service/share'
|
||||
|
||||
type Props = {
|
||||
appId: string
|
||||
isWorkflow?: boolean
|
||||
className?: string
|
||||
}
|
||||
|
||||
const TextGeneration: FC<Props> = ({
|
||||
isWorkflow = false,
|
||||
appId,
|
||||
className,
|
||||
}) => {
|
||||
// const { t } = useTranslation()
|
||||
const isWorkflow = true // wait for detail app info to decide // app.mode === 'completion' | 'workflow'
|
||||
const media = useBreakpoints()
|
||||
const isPC = media === MediaType.pc
|
||||
|
||||
|
|
@ -54,7 +55,6 @@ const TextGeneration: FC<Props> = ({
|
|||
const [moreLikeThisConfig, setMoreLikeThisConfig] = useState<MoreLikeThisConfig | null>(null)
|
||||
const [textToSpeechConfig, setTextToSpeechConfig] = useState<TextToSpeechConfig | null>(null)
|
||||
const [controlSend, setControlSend] = useState(0)
|
||||
const [controlStopResponding, setControlStopResponding] = useState(0)
|
||||
const [visionConfig, setVisionConfig] = useState<VisionSettings>({
|
||||
enabled: false,
|
||||
number_limits: 2,
|
||||
|
|
@ -62,10 +62,7 @@ const TextGeneration: FC<Props> = ({
|
|||
transfer_methods: [TransferMethod.local_file],
|
||||
})
|
||||
const [completionFiles, setCompletionFiles] = useState<VisionFile[]>([])
|
||||
const [controlRetry, setControlRetry] = useState(0)
|
||||
const [isShowResultPanel, { setTrue: doShowResultPanel, setFalse: hideResultPanel }] = useBoolean(false)
|
||||
// to temp fix lint
|
||||
console.log(setControlStopResponding, setControlRetry)
|
||||
const showResultPanel = () => {
|
||||
// fix: useClickAway hideResSidebar will close sidebar
|
||||
setTimeout(() => {
|
||||
|
|
@ -125,15 +122,13 @@ const TextGeneration: FC<Props> = ({
|
|||
isCallBatchAPI={false}
|
||||
isPC={isPC}
|
||||
isMobile={!isPC}
|
||||
isInstalledApp={false}
|
||||
installedAppInfo={{}}
|
||||
appSourceType={AppSourceType.webApp} // todo for call the api
|
||||
appId={appId}
|
||||
isError={task?.status === TaskStatus.failed}
|
||||
promptConfig={promptConfig}
|
||||
moreLikeThisEnabled={!!moreLikeThisConfig?.enabled}
|
||||
inputs={inputs}
|
||||
controlSend={controlSend}
|
||||
controlRetry={task?.status === TaskStatus.failed ? controlRetry : 0}
|
||||
controlStopResponding={controlStopResponding}
|
||||
onShowRes={showResultPanel}
|
||||
handleSaveMessage={noop}
|
||||
taskId={task?.id}
|
||||
|
|
|
|||
|
|
@ -113,9 +113,9 @@ export const sendWorkflowMessage = async (
|
|||
onTextReplace: IOnTextReplace
|
||||
},
|
||||
appSourceType: AppSourceType,
|
||||
installedAppId = '',
|
||||
appId = '',
|
||||
) => {
|
||||
return ssePost(getUrl('workflows/run', appSourceType, installedAppId), {
|
||||
return ssePost(getUrl('workflows/run', appSourceType, appId), {
|
||||
body: {
|
||||
...body,
|
||||
response_mode: 'streaming',
|
||||
|
|
|
|||
Loading…
Reference in New Issue