mirror of
https://github.com/langgenius/dify.git
synced 2026-01-08 07:14:14 +00:00
chat list api
This commit is contained in:
@@ -15,7 +15,7 @@ const Record = () => {
|
||||
${isChatMode ? 'w-[320px]' : 'w-[400px]'}
|
||||
`}>
|
||||
<div className='flex items-center justify-between p-4 pb-1 text-base font-semibold text-gray-900'>
|
||||
{`Test Run#${currentSequenceNumber}`}
|
||||
{`Test ${isChatMode ? 'Chat' : 'Run'}#${currentSequenceNumber}`}
|
||||
</div>
|
||||
{
|
||||
isChatMode
|
||||
|
||||
@@ -4,6 +4,7 @@ import dayjs from 'dayjs'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import useSWR from 'swr'
|
||||
import { WorkflowRunningStatus } from '../types'
|
||||
import { useIsChatMode } from '../hooks'
|
||||
import { CheckCircle, XClose } from '@/app/components/base/icons/src/vender/line/general'
|
||||
import { AlertCircle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback'
|
||||
import {
|
||||
@@ -11,15 +12,21 @@ import {
|
||||
useWorkflowStore,
|
||||
} from '@/app/components/workflow/store'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import { fetchWorkflowRunHistory } from '@/service/workflow'
|
||||
import { fetcChatRunHistory, fetchWorkflowRunHistory } from '@/service/workflow'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
|
||||
const RunHistory = () => {
|
||||
const { t } = useTranslation()
|
||||
const workflowStore = useWorkflowStore()
|
||||
const isChatMode = useIsChatMode()
|
||||
const appDetail = useAppStore(state => state.appDetail)
|
||||
const workflowStore = useWorkflowStore()
|
||||
const workflowRunId = useRunHistoryStore(state => state.workflowRunId)
|
||||
const { data, isLoading } = useSWR(appDetail ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory)
|
||||
const { data: runList, isLoading: runListLoading } = useSWR((appDetail && !isChatMode) ? `/apps/${appDetail.id}/workflow-runs` : null, fetchWorkflowRunHistory)
|
||||
|
||||
const { data: chatList, isLoading: chatListLoading } = useSWR((appDetail && isChatMode) ? `/apps/${appDetail.id}/advanced-chat/workflow-runs` : null, fetcChatRunHistory)
|
||||
|
||||
const data = isChatMode ? chatList : runList
|
||||
const isLoading = isChatMode ? chatListLoading : runListLoading
|
||||
|
||||
if (!appDetail)
|
||||
return null
|
||||
@@ -54,16 +61,17 @@ const RunHistory = () => {
|
||||
onClick={() => workflowStore.setState({
|
||||
currentSequenceNumber: item.sequence_number,
|
||||
workflowRunId: item.id,
|
||||
currentConversationID: item.conversation_id,
|
||||
runningStatus: item.status as WorkflowRunningStatus,
|
||||
})}
|
||||
>
|
||||
{
|
||||
appDetail?.mode === 'workflow' && item.status === WorkflowRunningStatus.Failed && (
|
||||
!isChatMode && item.status === WorkflowRunningStatus.Failed && (
|
||||
<AlertCircle className='mt-0.5 mr-1.5 w-3.5 h-3.5 text-[#F79009]' />
|
||||
)
|
||||
}
|
||||
{
|
||||
appDetail?.mode === 'workflow' && item.status === WorkflowRunningStatus.Succeeded && (
|
||||
!isChatMode && item.status === WorkflowRunningStatus.Succeeded && (
|
||||
<CheckCircle className='mt-0.5 mr-1.5 w-3.5 h-3.5 text-[#12B76A]' />
|
||||
)
|
||||
}
|
||||
@@ -74,7 +82,7 @@ const RunHistory = () => {
|
||||
item.id === workflowRunId && 'text-primary-600',
|
||||
)}
|
||||
>
|
||||
Test Run#{item.sequence_number}
|
||||
{`Test ${isChatMode ? 'Chat' : 'Run'} Run#${item.sequence_number}`}
|
||||
</div>
|
||||
<div className='flex items-center text-xs text-gray-500 leading-[18px]'>
|
||||
{item.created_by_account.name} · {dayjs((item.finished_at || item.created_at) * 1000).fromNow()}
|
||||
|
||||
@@ -24,6 +24,7 @@ type State = {
|
||||
taskId: string
|
||||
currentSequenceNumber: number
|
||||
workflowRunId: string
|
||||
currentConversationID: string
|
||||
showRunHistory: boolean
|
||||
showFeaturesPanel: boolean
|
||||
helpLineHorizontal?: HelpLineHorizontalPosition
|
||||
@@ -49,6 +50,7 @@ type Action = {
|
||||
setTaskId: (taskId: string) => void
|
||||
setCurrentSequenceNumber: (currentSequenceNumber: number) => void
|
||||
setWorkflowRunId: (workflowRunId: string) => void
|
||||
setCurrentConversationID: (currentConversationID: string) => void
|
||||
setShowRunHistory: (showRunHistory: boolean) => void
|
||||
setShowFeaturesPanel: (showFeaturesPanel: boolean) => void
|
||||
setHelpLineHorizontal: (helpLineHorizontal?: HelpLineHorizontalPosition) => void
|
||||
@@ -74,6 +76,8 @@ export const createWorkflowStore = () => {
|
||||
setCurrentSequenceNumber: currentSequenceNumber => set(() => ({ currentSequenceNumber })),
|
||||
workflowRunId: '',
|
||||
setWorkflowRunId: workflowRunId => set(() => ({ workflowRunId })),
|
||||
currentConversationID: '',
|
||||
setCurrentConversationID: currentConversationID => set(() => ({ currentConversationID })),
|
||||
showRunHistory: false,
|
||||
setShowRunHistory: showRunHistory => set(() => ({ showRunHistory })),
|
||||
showFeaturesPanel: false,
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { Fetcher } from 'swr'
|
||||
import { get, post } from './base'
|
||||
import type { CommonResponse } from '@/models/common'
|
||||
import type {
|
||||
ChatRunHistoryResponse,
|
||||
FetchWorkflowDraftResponse,
|
||||
NodesDefaultConfigsResponse,
|
||||
WorkflowRunHistoryResponse,
|
||||
@@ -23,6 +24,10 @@ export const fetchWorkflowRunHistory: Fetcher<WorkflowRunHistoryResponse, string
|
||||
return get<WorkflowRunHistoryResponse>(url)
|
||||
}
|
||||
|
||||
export const fetcChatRunHistory: Fetcher<ChatRunHistoryResponse, string> = (url) => {
|
||||
return get<ChatRunHistoryResponse>(url)
|
||||
}
|
||||
|
||||
export const singleNodeRun = (appId: string, nodeId: string, params: object) => {
|
||||
return post(`apps/${appId}/workflows/draft/nodes/${nodeId}/run`, { body: params })
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ export type WorkflowRunHistory = {
|
||||
id: string
|
||||
sequence_number: number
|
||||
version: string
|
||||
conversation_id?: string
|
||||
message_id?: string
|
||||
graph: {
|
||||
nodes: Node[]
|
||||
edges: Edge[]
|
||||
@@ -161,6 +163,10 @@ export type WorkflowRunHistoryResponse = {
|
||||
data: WorkflowRunHistory[]
|
||||
}
|
||||
|
||||
export type ChatRunHistoryResponse = {
|
||||
data: WorkflowRunHistory[]
|
||||
}
|
||||
|
||||
export type NodesDefaultConfigsResponse = {
|
||||
type: string
|
||||
config: any
|
||||
|
||||
Reference in New Issue
Block a user