mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-20 22:51:06 +08:00
Feat: Add the user_id field to the agent log table and the embedded page. (#13596)
### What problem does this PR solve? Feat: Add the `user_id` field to the agent log table and the embedded page. ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useParams } from 'react-router';
|
||||
import { useParams, useSearchParams } from 'react-router';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import { BeginId } from '../constant';
|
||||
import { AgentChatLogContext } from '../context';
|
||||
@@ -272,6 +272,10 @@ export const useSendAgentMessage = ({
|
||||
removeFile,
|
||||
} = useSetUploadResponseData();
|
||||
|
||||
const [searchParams] = useSearchParams();
|
||||
|
||||
const userId = searchParams.get('userId');
|
||||
|
||||
const { stopMessage } = useStopMessage();
|
||||
|
||||
const stopConversation = useCallback(() => {
|
||||
@@ -315,6 +319,10 @@ export const useSendAgentMessage = ({
|
||||
if (releaseMode) {
|
||||
params.release = releaseMode;
|
||||
}
|
||||
|
||||
if (userId) {
|
||||
params.user_id = userId;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -341,12 +349,13 @@ export const useSendAgentMessage = ({
|
||||
beginParams,
|
||||
uploadResponseList,
|
||||
sessionId,
|
||||
releaseMode,
|
||||
userId,
|
||||
send,
|
||||
clearUploadResponseList,
|
||||
setValue,
|
||||
removeLatestMessage,
|
||||
refetch,
|
||||
releaseMode,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -32,8 +32,7 @@ interface SharedChatSearchParams {
|
||||
export const useGetSharedChatSearchParams = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
const data = Object.fromEntries(
|
||||
searchParams
|
||||
.entries()
|
||||
Array.from(searchParams.entries())
|
||||
.filter(([key]) => key.startsWith(DATA_PREFIX))
|
||||
.map(([key, value]) => [key.replace(DATA_PREFIX, ''), value]),
|
||||
);
|
||||
@@ -74,7 +73,7 @@ export const useSendNextSharedMessage = (
|
||||
showModal: showParameterDialog,
|
||||
} = useSetModalState();
|
||||
|
||||
const ret = useSendAgentMessage({
|
||||
const { handlePressEnter, ...ret } = useSendAgentMessage({
|
||||
url,
|
||||
addEventList,
|
||||
beginParams: params,
|
||||
@@ -100,6 +99,10 @@ export const useSendNextSharedMessage = (
|
||||
[hideParameterDialog, isTaskMode, ret],
|
||||
);
|
||||
|
||||
const onPressEnter = useCallback(() => {
|
||||
handlePressEnter();
|
||||
}, [handlePressEnter]);
|
||||
|
||||
const runTask = useCallback(() => {
|
||||
if (
|
||||
isTaskMode &&
|
||||
@@ -124,5 +127,6 @@ export const useSendNextSharedMessage = (
|
||||
hideParameterDialog,
|
||||
showParameterDialog,
|
||||
ok,
|
||||
handlePressEnter: onPressEnter,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
} from '@/components/ui/breadcrumb';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SearchInput } from '@/components/ui/input';
|
||||
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
|
||||
import { Spin } from '@/components/ui/spin';
|
||||
@@ -20,6 +21,7 @@ import {
|
||||
import { IReferenceObject } from '@/interfaces/database/chat';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useParams } from 'react-router';
|
||||
import { DateRange } from '../../components/originui/calendar/index';
|
||||
import {
|
||||
@@ -44,6 +46,7 @@ const getEndOfToday = (): Date => {
|
||||
return today;
|
||||
};
|
||||
const AgentLogPage: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { navigateToAgents, navigateToAgent } = useNavigatePage();
|
||||
const { flowDetail: agentDetail } = useFetchDataOnMount();
|
||||
const { id: canvasId } = useParams();
|
||||
@@ -58,17 +61,24 @@ const AgentLogPage: React.FC = () => {
|
||||
page_size: 10,
|
||||
};
|
||||
const [searchParams, setSearchParams] = useState(init);
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'ID',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
},
|
||||
{
|
||||
title: 'User ID',
|
||||
dataIndex: 'user_id',
|
||||
key: 'user_id',
|
||||
render: (text: string) => <span>{text}</span>,
|
||||
},
|
||||
{
|
||||
title: 'Title',
|
||||
dataIndex: 'title',
|
||||
key: 'title',
|
||||
render: (text, record: IAgentLogResponse) => (
|
||||
render: (_text: string, record: IAgentLogResponse) => (
|
||||
<span>
|
||||
{record?.message?.length ? record?.message[0]?.content : ''}
|
||||
</span>
|
||||
@@ -78,7 +88,7 @@ const AgentLogPage: React.FC = () => {
|
||||
title: 'State',
|
||||
dataIndex: 'state',
|
||||
key: 'state',
|
||||
render: (text, record: IAgentLogResponse) => (
|
||||
render: (_text: string, record: IAgentLogResponse) => (
|
||||
<div
|
||||
className="size-2 rounded-full"
|
||||
style={{ backgroundColor: record.errors ? 'red' : 'green' }}
|
||||
@@ -102,6 +112,11 @@ const AgentLogPage: React.FC = () => {
|
||||
key: 'create_date',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: 'Version',
|
||||
dataIndex: 'version',
|
||||
key: 'version',
|
||||
},
|
||||
];
|
||||
|
||||
const { data: logData, loading } = useFetchAgentLog(searchParams);
|
||||
@@ -231,6 +246,7 @@ const AgentLogPage: React.FC = () => {
|
||||
|
||||
<div className="flex justify-end space-x-2 mb-4 text-foreground">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button>{t('flow.export')}</Button>
|
||||
<span>ID/Title</span>
|
||||
<SearchInput
|
||||
value={keywords}
|
||||
@@ -319,8 +335,13 @@ const AgentLogPage: React.FC = () => {
|
||||
{columns.map((column) => (
|
||||
<TableCell key={column.dataIndex}>
|
||||
{column.render
|
||||
? column.render(item[column.dataIndex], item)
|
||||
: item[column.dataIndex]}
|
||||
? column.render(
|
||||
item[column.dataIndex as keyof IAgentLogResponse],
|
||||
item,
|
||||
)
|
||||
: (item[
|
||||
column.dataIndex as keyof typeof item
|
||||
] as string)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user