show avatar dialog instead of default (#4033)
Browse filesshow avatar dialog instead of default
- [x] New Feature (non-breaking change which adds functionality)
---------
Co-authored-by: Kevin Hu <[email protected]>
- api/apps/canvas_app.py +15 -0
- api/apps/conversation_app.py +27 -2
- web/src/components/message-item/index.tsx +5 -1
- web/src/hooks/chat-hooks.ts +38 -3
- web/src/hooks/flow-hooks.ts +38 -1
- web/src/interfaces/database/chat.ts +1 -0
- web/src/interfaces/database/flow.ts +2 -2
- web/src/pages/chat/chat-container/index.tsx +1 -0
- web/src/pages/chat/share/large.tsx +12 -1
- web/src/pages/flow/chat/box.tsx +3 -0
- web/src/pages/knowledge/index.tsx +5 -2
- web/src/services/chat-service.ts +5 -0
- web/src/services/flow-service.ts +5 -0
- web/src/utils/api.ts +2 -0
api/apps/canvas_app.py
CHANGED
|
@@ -23,6 +23,7 @@ from api.utils import get_uuid
|
|
| 23 |
from api.utils.api_utils import get_json_result, server_error_response, validate_request, get_data_error_result
|
| 24 |
from agent.canvas import Canvas
|
| 25 |
from peewee import MySQLDatabase, PostgresqlDatabase
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
@manager.route('/templates', methods=['GET']) # noqa: F821
|
|
@@ -85,6 +86,20 @@ def get(canvas_id):
|
|
| 85 |
return get_data_error_result(message="canvas not found.")
|
| 86 |
return get_json_result(data=c.to_dict())
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
@manager.route('/completion', methods=['POST']) # noqa: F821
|
| 90 |
@validate_request("id")
|
|
|
|
| 23 |
from api.utils.api_utils import get_json_result, server_error_response, validate_request, get_data_error_result
|
| 24 |
from agent.canvas import Canvas
|
| 25 |
from peewee import MySQLDatabase, PostgresqlDatabase
|
| 26 |
+
from api.db.db_models import APIToken
|
| 27 |
|
| 28 |
|
| 29 |
@manager.route('/templates', methods=['GET']) # noqa: F821
|
|
|
|
| 86 |
return get_data_error_result(message="canvas not found.")
|
| 87 |
return get_json_result(data=c.to_dict())
|
| 88 |
|
| 89 |
+
@manager.route('/getsse/<canvas_id>', methods=['GET']) # type: ignore # noqa: F821
|
| 90 |
+
def getsse(canvas_id):
|
| 91 |
+
token = request.headers.get('Authorization').split()
|
| 92 |
+
if len(token) != 2:
|
| 93 |
+
return get_data_error_result(message='Authorization is not valid!"')
|
| 94 |
+
token = token[1]
|
| 95 |
+
objs = APIToken.query(beta=token)
|
| 96 |
+
if not objs:
|
| 97 |
+
return get_data_error_result(message='Token is not valid!"')
|
| 98 |
+
e, c = UserCanvasService.get_by_id(canvas_id)
|
| 99 |
+
if not e:
|
| 100 |
+
return get_data_error_result(message="canvas not found.")
|
| 101 |
+
return get_json_result(data=c.to_dict())
|
| 102 |
+
|
| 103 |
|
| 104 |
@manager.route('/completion', methods=['POST']) # noqa: F821
|
| 105 |
@validate_request("id")
|
api/apps/conversation_app.py
CHANGED
|
@@ -17,6 +17,7 @@ import json
|
|
| 17 |
import re
|
| 18 |
import traceback
|
| 19 |
from copy import deepcopy
|
|
|
|
| 20 |
|
| 21 |
from api.db.services.conversation_service import ConversationService, structure_answer
|
| 22 |
from api.db.services.user_service import UserTenantService
|
|
@@ -32,7 +33,6 @@ from api.utils.api_utils import get_json_result
|
|
| 32 |
from api.utils.api_utils import server_error_response, get_data_error_result, validate_request
|
| 33 |
from graphrag.mind_map_extractor import MindMapExtractor
|
| 34 |
|
| 35 |
-
|
| 36 |
@manager.route('/set', methods=['POST']) # noqa: F821
|
| 37 |
@login_required
|
| 38 |
def set_conversation():
|
|
@@ -79,12 +79,16 @@ def set_conversation():
|
|
| 79 |
def get():
|
| 80 |
conv_id = request.args["conversation_id"]
|
| 81 |
try:
|
|
|
|
| 82 |
e, conv = ConversationService.get_by_id(conv_id)
|
| 83 |
if not e:
|
| 84 |
return get_data_error_result(message="Conversation not found!")
|
| 85 |
tenants = UserTenantService.query(user_id=current_user.id)
|
|
|
|
| 86 |
for tenant in tenants:
|
| 87 |
-
|
|
|
|
|
|
|
| 88 |
break
|
| 89 |
else:
|
| 90 |
return get_json_result(
|
|
@@ -108,10 +112,31 @@ def get():
|
|
| 108 |
} for ck in ref.get("chunks", [])]
|
| 109 |
|
| 110 |
conv = conv.to_dict()
|
|
|
|
| 111 |
return get_json_result(data=conv)
|
| 112 |
except Exception as e:
|
| 113 |
return server_error_response(e)
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
@manager.route('/rm', methods=['POST']) # noqa: F821
|
| 117 |
@login_required
|
|
|
|
| 17 |
import re
|
| 18 |
import traceback
|
| 19 |
from copy import deepcopy
|
| 20 |
+
from api.db.db_models import APIToken
|
| 21 |
|
| 22 |
from api.db.services.conversation_service import ConversationService, structure_answer
|
| 23 |
from api.db.services.user_service import UserTenantService
|
|
|
|
| 33 |
from api.utils.api_utils import server_error_response, get_data_error_result, validate_request
|
| 34 |
from graphrag.mind_map_extractor import MindMapExtractor
|
| 35 |
|
|
|
|
| 36 |
@manager.route('/set', methods=['POST']) # noqa: F821
|
| 37 |
@login_required
|
| 38 |
def set_conversation():
|
|
|
|
| 79 |
def get():
|
| 80 |
conv_id = request.args["conversation_id"]
|
| 81 |
try:
|
| 82 |
+
|
| 83 |
e, conv = ConversationService.get_by_id(conv_id)
|
| 84 |
if not e:
|
| 85 |
return get_data_error_result(message="Conversation not found!")
|
| 86 |
tenants = UserTenantService.query(user_id=current_user.id)
|
| 87 |
+
avatar =None
|
| 88 |
for tenant in tenants:
|
| 89 |
+
dialog = DialogService.query(tenant_id=tenant.tenant_id, id=conv.dialog_id)
|
| 90 |
+
if dialog and len(dialog)>0:
|
| 91 |
+
avatar = dialog[0].icon
|
| 92 |
break
|
| 93 |
else:
|
| 94 |
return get_json_result(
|
|
|
|
| 112 |
} for ck in ref.get("chunks", [])]
|
| 113 |
|
| 114 |
conv = conv.to_dict()
|
| 115 |
+
conv["avatar"]=avatar
|
| 116 |
return get_json_result(data=conv)
|
| 117 |
except Exception as e:
|
| 118 |
return server_error_response(e)
|
| 119 |
|
| 120 |
+
@manager.route('/getsse/<dialog_id>', methods=['GET']) # type: ignore # noqa: F821
|
| 121 |
+
def getsse(dialog_id):
|
| 122 |
+
|
| 123 |
+
token = request.headers.get('Authorization').split()
|
| 124 |
+
if len(token) != 2:
|
| 125 |
+
return get_data_error_result(message='Authorization is not valid!"')
|
| 126 |
+
token = token[1]
|
| 127 |
+
objs = APIToken.query(beta=token)
|
| 128 |
+
if not objs:
|
| 129 |
+
return get_data_error_result(message='Token is not valid!"')
|
| 130 |
+
try:
|
| 131 |
+
e, conv = DialogService.get_by_id(dialog_id)
|
| 132 |
+
if not e:
|
| 133 |
+
return get_data_error_result(message="Dialog not found!")
|
| 134 |
+
conv = conv.to_dict()
|
| 135 |
+
conv["avatar"]= conv["icon"]
|
| 136 |
+
del conv["icon"]
|
| 137 |
+
return get_json_result(data=conv)
|
| 138 |
+
except Exception as e:
|
| 139 |
+
return server_error_response(e)
|
| 140 |
|
| 141 |
@manager.route('/rm', methods=['POST']) # noqa: F821
|
| 142 |
@login_required
|
web/src/components/message-item/index.tsx
CHANGED
|
@@ -30,6 +30,7 @@ interface IProps extends Partial<IRemoveMessageById>, IRegenerateMessage {
|
|
| 30 |
sendLoading?: boolean;
|
| 31 |
nickname?: string;
|
| 32 |
avatar?: string;
|
|
|
|
| 33 |
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
| 34 |
index: number;
|
| 35 |
showLikeButton?: boolean;
|
|
@@ -40,6 +41,7 @@ const MessageItem = ({
|
|
| 40 |
reference,
|
| 41 |
loading = false,
|
| 42 |
avatar,
|
|
|
|
| 43 |
sendLoading = false,
|
| 44 |
clickDocumentButton,
|
| 45 |
index,
|
|
@@ -103,8 +105,10 @@ const MessageItem = ({
|
|
| 103 |
>
|
| 104 |
{item.role === MessageType.User ? (
|
| 105 |
<Avatar size={40} src={avatar ?? '/logo.svg'} />
|
|
|
|
|
|
|
| 106 |
) : (
|
| 107 |
-
<AssistantIcon
|
| 108 |
)}
|
| 109 |
<Flex vertical gap={8} flex={1}>
|
| 110 |
<Space>
|
|
|
|
| 30 |
sendLoading?: boolean;
|
| 31 |
nickname?: string;
|
| 32 |
avatar?: string;
|
| 33 |
+
avatardialog?: string | null;
|
| 34 |
clickDocumentButton?: (documentId: string, chunk: IReferenceChunk) => void;
|
| 35 |
index: number;
|
| 36 |
showLikeButton?: boolean;
|
|
|
|
| 41 |
reference,
|
| 42 |
loading = false,
|
| 43 |
avatar,
|
| 44 |
+
avatardialog,
|
| 45 |
sendLoading = false,
|
| 46 |
clickDocumentButton,
|
| 47 |
index,
|
|
|
|
| 105 |
>
|
| 106 |
{item.role === MessageType.User ? (
|
| 107 |
<Avatar size={40} src={avatar ?? '/logo.svg'} />
|
| 108 |
+
) : avatardialog ? (
|
| 109 |
+
<Avatar size={40} src={avatardialog} />
|
| 110 |
) : (
|
| 111 |
+
<AssistantIcon />
|
| 112 |
)}
|
| 113 |
<Flex vertical gap={8} flex={1}>
|
| 114 |
<Space>
|
web/src/hooks/chat-hooks.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
| 11 |
} from '@/interfaces/request/chat';
|
| 12 |
import i18n from '@/locales/config';
|
| 13 |
import { IClientConversation } from '@/pages/chat/interface';
|
|
|
|
| 14 |
import chatService from '@/services/chat-service';
|
| 15 |
import {
|
| 16 |
buildMessageListWithUuid,
|
|
@@ -27,6 +28,7 @@ import { history, useSearchParams } from 'umi';
|
|
| 27 |
//#region logic
|
| 28 |
|
| 29 |
export const useClickDialogCard = () => {
|
|
|
|
| 30 |
const [_, setSearchParams] = useSearchParams();
|
| 31 |
|
| 32 |
const newQueryParameters: URLSearchParams = useMemo(() => {
|
|
@@ -243,6 +245,7 @@ export const useFetchNextConversationList = () => {
|
|
| 243 |
|
| 244 |
export const useFetchNextConversation = () => {
|
| 245 |
const { isNew, conversationId } = useGetChatSearchParams();
|
|
|
|
| 246 |
const {
|
| 247 |
data,
|
| 248 |
isFetching: loading,
|
|
@@ -254,8 +257,13 @@ export const useFetchNextConversation = () => {
|
|
| 254 |
gcTime: 0,
|
| 255 |
refetchOnWindowFocus: false,
|
| 256 |
queryFn: async () => {
|
| 257 |
-
if (
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
|
| 260 |
const conversation = data?.data ?? {};
|
| 261 |
|
|
@@ -270,6 +278,33 @@ export const useFetchNextConversation = () => {
|
|
| 270 |
return { data, loading, refetch };
|
| 271 |
};
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
export const useFetchManualConversation = () => {
|
| 274 |
const {
|
| 275 |
data,
|
|
@@ -547,7 +582,7 @@ export const useFetchMindMap = () => {
|
|
| 547 |
try {
|
| 548 |
const ret = await chatService.getMindMap(params);
|
| 549 |
return ret?.data?.data ?? {};
|
| 550 |
-
} catch (error) {
|
| 551 |
if (has(error, 'message')) {
|
| 552 |
message.error(error.message);
|
| 553 |
}
|
|
|
|
| 11 |
} from '@/interfaces/request/chat';
|
| 12 |
import i18n from '@/locales/config';
|
| 13 |
import { IClientConversation } from '@/pages/chat/interface';
|
| 14 |
+
import { useGetSharedChatSearchParams } from '@/pages/chat/shared-hooks';
|
| 15 |
import chatService from '@/services/chat-service';
|
| 16 |
import {
|
| 17 |
buildMessageListWithUuid,
|
|
|
|
| 28 |
//#region logic
|
| 29 |
|
| 30 |
export const useClickDialogCard = () => {
|
| 31 |
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
| 32 |
const [_, setSearchParams] = useSearchParams();
|
| 33 |
|
| 34 |
const newQueryParameters: URLSearchParams = useMemo(() => {
|
|
|
|
| 245 |
|
| 246 |
export const useFetchNextConversation = () => {
|
| 247 |
const { isNew, conversationId } = useGetChatSearchParams();
|
| 248 |
+
const { sharedId } = useGetSharedChatSearchParams();
|
| 249 |
const {
|
| 250 |
data,
|
| 251 |
isFetching: loading,
|
|
|
|
| 257 |
gcTime: 0,
|
| 258 |
refetchOnWindowFocus: false,
|
| 259 |
queryFn: async () => {
|
| 260 |
+
if (
|
| 261 |
+
isNew !== 'true' &&
|
| 262 |
+
isConversationIdExist(sharedId || conversationId)
|
| 263 |
+
) {
|
| 264 |
+
const { data } = await chatService.getConversation({
|
| 265 |
+
conversationId: conversationId || sharedId,
|
| 266 |
+
});
|
| 267 |
|
| 268 |
const conversation = data?.data ?? {};
|
| 269 |
|
|
|
|
| 278 |
return { data, loading, refetch };
|
| 279 |
};
|
| 280 |
|
| 281 |
+
export const useFetchNextConversationSSE = () => {
|
| 282 |
+
const { isNew } = useGetChatSearchParams();
|
| 283 |
+
const { sharedId } = useGetSharedChatSearchParams();
|
| 284 |
+
const {
|
| 285 |
+
data,
|
| 286 |
+
isFetching: loading,
|
| 287 |
+
refetch,
|
| 288 |
+
} = useQuery<IClientConversation>({
|
| 289 |
+
queryKey: ['fetchConversationSSE', sharedId],
|
| 290 |
+
initialData: {} as IClientConversation,
|
| 291 |
+
gcTime: 0,
|
| 292 |
+
refetchOnWindowFocus: false,
|
| 293 |
+
queryFn: async () => {
|
| 294 |
+
if (isNew !== 'true' && isConversationIdExist(sharedId || '')) {
|
| 295 |
+
if (!sharedId) return {};
|
| 296 |
+
const { data } = await chatService.getConversationSSE({}, sharedId);
|
| 297 |
+
const conversation = data?.data ?? {};
|
| 298 |
+
const messageList = buildMessageListWithUuid(conversation?.message);
|
| 299 |
+
return { ...conversation, message: messageList };
|
| 300 |
+
}
|
| 301 |
+
return { message: [] };
|
| 302 |
+
},
|
| 303 |
+
});
|
| 304 |
+
|
| 305 |
+
return { data, loading, refetch };
|
| 306 |
+
};
|
| 307 |
+
|
| 308 |
export const useFetchManualConversation = () => {
|
| 309 |
const {
|
| 310 |
data,
|
|
|
|
| 582 |
try {
|
| 583 |
const ret = await chatService.getMindMap(params);
|
| 584 |
return ret?.data?.data ?? {};
|
| 585 |
+
} catch (error: any) {
|
| 586 |
if (has(error, 'message')) {
|
| 587 |
message.error(error.message);
|
| 588 |
}
|
web/src/hooks/flow-hooks.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ResponseType } from '@/interfaces/database/base';
|
|
| 2 |
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
|
| 3 |
import { IDebugSingleRequestBody } from '@/interfaces/request/flow';
|
| 4 |
import i18n from '@/locales/config';
|
|
|
|
| 5 |
import flowService from '@/services/flow-service';
|
| 6 |
import { buildMessageListWithUuid } from '@/utils/chat';
|
| 7 |
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
@@ -91,6 +92,8 @@ export const useFetchFlow = (): {
|
|
| 91 |
refetch: () => void;
|
| 92 |
} => {
|
| 93 |
const { id } = useParams();
|
|
|
|
|
|
|
| 94 |
const {
|
| 95 |
data,
|
| 96 |
isFetching: loading,
|
|
@@ -103,7 +106,41 @@ export const useFetchFlow = (): {
|
|
| 103 |
refetchOnWindowFocus: false,
|
| 104 |
gcTime: 0,
|
| 105 |
queryFn: async () => {
|
| 106 |
-
const { data } = await flowService.getCanvas({}, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
const messageList = buildMessageListWithUuid(
|
| 109 |
get(data, 'data.dsl.messages', []),
|
|
|
|
| 2 |
import { DSL, IFlow, IFlowTemplate } from '@/interfaces/database/flow';
|
| 3 |
import { IDebugSingleRequestBody } from '@/interfaces/request/flow';
|
| 4 |
import i18n from '@/locales/config';
|
| 5 |
+
import { useGetSharedChatSearchParams } from '@/pages/chat/shared-hooks';
|
| 6 |
import flowService from '@/services/flow-service';
|
| 7 |
import { buildMessageListWithUuid } from '@/utils/chat';
|
| 8 |
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
|
|
| 92 |
refetch: () => void;
|
| 93 |
} => {
|
| 94 |
const { id } = useParams();
|
| 95 |
+
const { sharedId } = useGetSharedChatSearchParams();
|
| 96 |
+
|
| 97 |
const {
|
| 98 |
data,
|
| 99 |
isFetching: loading,
|
|
|
|
| 106 |
refetchOnWindowFocus: false,
|
| 107 |
gcTime: 0,
|
| 108 |
queryFn: async () => {
|
| 109 |
+
const { data } = await flowService.getCanvas({}, sharedId || id);
|
| 110 |
+
|
| 111 |
+
const messageList = buildMessageListWithUuid(
|
| 112 |
+
get(data, 'data.dsl.messages', []),
|
| 113 |
+
);
|
| 114 |
+
set(data, 'data.dsl.messages', messageList);
|
| 115 |
+
|
| 116 |
+
return data?.data ?? {};
|
| 117 |
+
},
|
| 118 |
+
});
|
| 119 |
+
|
| 120 |
+
return { data, loading, refetch };
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
export const useFetchFlowSSE = (): {
|
| 124 |
+
data: IFlow;
|
| 125 |
+
loading: boolean;
|
| 126 |
+
refetch: () => void;
|
| 127 |
+
} => {
|
| 128 |
+
const { sharedId } = useGetSharedChatSearchParams();
|
| 129 |
+
|
| 130 |
+
const {
|
| 131 |
+
data,
|
| 132 |
+
isFetching: loading,
|
| 133 |
+
refetch,
|
| 134 |
+
} = useQuery({
|
| 135 |
+
queryKey: ['flowDetailSSE'],
|
| 136 |
+
initialData: {} as IFlow,
|
| 137 |
+
refetchOnReconnect: false,
|
| 138 |
+
refetchOnMount: false,
|
| 139 |
+
refetchOnWindowFocus: false,
|
| 140 |
+
gcTime: 0,
|
| 141 |
+
queryFn: async () => {
|
| 142 |
+
if (!sharedId) return {};
|
| 143 |
+
const { data } = await flowService.getCanvasSSE({}, sharedId);
|
| 144 |
|
| 145 |
const messageList = buildMessageListWithUuid(
|
| 146 |
get(data, 'data.dsl.messages', []),
|
web/src/interfaces/database/chat.ts
CHANGED
|
@@ -57,6 +57,7 @@ export interface IConversation {
|
|
| 57 |
create_time: number;
|
| 58 |
dialog_id: string;
|
| 59 |
id: string;
|
|
|
|
| 60 |
message: Message[];
|
| 61 |
reference: IReference[];
|
| 62 |
name: string;
|
|
|
|
| 57 |
create_time: number;
|
| 58 |
dialog_id: string;
|
| 59 |
id: string;
|
| 60 |
+
avatar: string;
|
| 61 |
message: Message[];
|
| 62 |
reference: IReference[];
|
| 63 |
name: string;
|
web/src/interfaces/database/flow.ts
CHANGED
|
@@ -29,8 +29,8 @@ export interface IGraph {
|
|
| 29 |
edges: Edge[];
|
| 30 |
}
|
| 31 |
|
| 32 |
-
export interface IFlow {
|
| 33 |
-
avatar
|
| 34 |
canvas_type: null;
|
| 35 |
create_date: string;
|
| 36 |
create_time: number;
|
|
|
|
| 29 |
edges: Edge[];
|
| 30 |
}
|
| 31 |
|
| 32 |
+
export declare interface IFlow {
|
| 33 |
+
avatar?: null | string;
|
| 34 |
canvas_type: null;
|
| 35 |
create_date: string;
|
| 36 |
create_time: number;
|
web/src/pages/chat/chat-container/index.tsx
CHANGED
|
@@ -68,6 +68,7 @@ const ChatContainer = ({ controller }: IProps) => {
|
|
| 68 |
item={message}
|
| 69 |
nickname={userInfo.nickname}
|
| 70 |
avatar={userInfo.avatar}
|
|
|
|
| 71 |
reference={buildMessageItemReference(
|
| 72 |
{
|
| 73 |
message: derivedMessages,
|
|
|
|
| 68 |
item={message}
|
| 69 |
nickname={userInfo.nickname}
|
| 70 |
avatar={userInfo.avatar}
|
| 71 |
+
avatardialog={conversation.avatar}
|
| 72 |
reference={buildMessageItemReference(
|
| 73 |
{
|
| 74 |
message: derivedMessages,
|
web/src/pages/chat/share/large.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
|
| 4 |
import { MessageType } from '@/constants/chat';
|
| 5 |
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
| 6 |
import { Flex, Spin } from 'antd';
|
| 7 |
-
import { forwardRef } from 'react';
|
| 8 |
import {
|
| 9 |
useGetSharedChatSearchParams,
|
| 10 |
useSendSharedMessage,
|
|
@@ -12,6 +12,8 @@ import {
|
|
| 12 |
import { buildMessageItemReference } from '../utils';
|
| 13 |
|
| 14 |
import PdfDrawer from '@/components/pdf-drawer';
|
|
|
|
|
|
|
| 15 |
import styles from './index.less';
|
| 16 |
|
| 17 |
const ChatContainer = () => {
|
|
@@ -30,6 +32,14 @@ const ChatContainer = () => {
|
|
| 30 |
hasError,
|
| 31 |
} = useSendSharedMessage();
|
| 32 |
const sendDisabled = useSendButtonDisabled(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
if (!conversationId) {
|
| 35 |
return <div>empty</div>;
|
|
@@ -45,6 +55,7 @@ const ChatContainer = () => {
|
|
| 45 |
return (
|
| 46 |
<MessageItem
|
| 47 |
key={message.id}
|
|
|
|
| 48 |
item={message}
|
| 49 |
nickname="You"
|
| 50 |
reference={buildMessageItemReference(
|
|
|
|
| 4 |
import { MessageType } from '@/constants/chat';
|
| 5 |
import { useSendButtonDisabled } from '@/pages/chat/hooks';
|
| 6 |
import { Flex, Spin } from 'antd';
|
| 7 |
+
import { forwardRef, useMemo } from 'react';
|
| 8 |
import {
|
| 9 |
useGetSharedChatSearchParams,
|
| 10 |
useSendSharedMessage,
|
|
|
|
| 12 |
import { buildMessageItemReference } from '../utils';
|
| 13 |
|
| 14 |
import PdfDrawer from '@/components/pdf-drawer';
|
| 15 |
+
import { useFetchNextConversationSSE } from '@/hooks/chat-hooks';
|
| 16 |
+
import { useFetchFlowSSE } from '@/hooks/flow-hooks';
|
| 17 |
import styles from './index.less';
|
| 18 |
|
| 19 |
const ChatContainer = () => {
|
|
|
|
| 32 |
hasError,
|
| 33 |
} = useSendSharedMessage();
|
| 34 |
const sendDisabled = useSendButtonDisabled(value);
|
| 35 |
+
const useData = (from: SharedFrom) =>
|
| 36 |
+
useMemo(() => {
|
| 37 |
+
return from === SharedFrom.Agent
|
| 38 |
+
? useFetchFlowSSE
|
| 39 |
+
: useFetchNextConversationSSE;
|
| 40 |
+
}, [from]);
|
| 41 |
+
|
| 42 |
+
const { data: InforForm } = useData(from)();
|
| 43 |
|
| 44 |
if (!conversationId) {
|
| 45 |
return <div>empty</div>;
|
|
|
|
| 55 |
return (
|
| 56 |
<MessageItem
|
| 57 |
key={message.id}
|
| 58 |
+
avatardialog={InforForm?.avatar}
|
| 59 |
item={message}
|
| 60 |
nickname="You"
|
| 61 |
reference={buildMessageItemReference(
|
web/src/pages/flow/chat/box.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import { useSendNextMessage } from './hooks';
|
|
| 9 |
|
| 10 |
import PdfDrawer from '@/components/pdf-drawer';
|
| 11 |
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
|
|
|
| 12 |
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
|
| 13 |
import styles from './index.less';
|
| 14 |
|
|
@@ -29,6 +30,7 @@ const FlowChatBox = () => {
|
|
| 29 |
useGetFileIcon();
|
| 30 |
const { t } = useTranslate('chat');
|
| 31 |
const { data: userInfo } = useFetchUserInfo();
|
|
|
|
| 32 |
|
| 33 |
return (
|
| 34 |
<>
|
|
@@ -47,6 +49,7 @@ const FlowChatBox = () => {
|
|
| 47 |
key={message.id}
|
| 48 |
nickname={userInfo.nickname}
|
| 49 |
avatar={userInfo.avatar}
|
|
|
|
| 50 |
item={message}
|
| 51 |
reference={buildMessageItemReference(
|
| 52 |
{ message: derivedMessages, reference },
|
|
|
|
| 9 |
|
| 10 |
import PdfDrawer from '@/components/pdf-drawer';
|
| 11 |
import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
| 12 |
+
import { useFetchFlow } from '@/hooks/flow-hooks';
|
| 13 |
import { useFetchUserInfo } from '@/hooks/user-setting-hooks';
|
| 14 |
import styles from './index.less';
|
| 15 |
|
|
|
|
| 30 |
useGetFileIcon();
|
| 31 |
const { t } = useTranslate('chat');
|
| 32 |
const { data: userInfo } = useFetchUserInfo();
|
| 33 |
+
const { data: cavasInfo } = useFetchFlow();
|
| 34 |
|
| 35 |
return (
|
| 36 |
<>
|
|
|
|
| 49 |
key={message.id}
|
| 50 |
nickname={userInfo.nickname}
|
| 51 |
avatar={userInfo.avatar}
|
| 52 |
+
avatardialog={cavasInfo.avatar}
|
| 53 |
item={message}
|
| 54 |
reference={buildMessageItemReference(
|
| 55 |
{ message: derivedMessages, reference },
|
web/src/pages/knowledge/index.tsx
CHANGED
|
@@ -89,9 +89,12 @@ const KnowledgeList = () => {
|
|
| 89 |
className={styles.knowledgeCardContainer}
|
| 90 |
>
|
| 91 |
{nextList?.length > 0 ? (
|
| 92 |
-
nextList.map((item: any) => {
|
| 93 |
return (
|
| 94 |
-
<KnowledgeCard
|
|
|
|
|
|
|
|
|
|
| 95 |
);
|
| 96 |
})
|
| 97 |
) : (
|
|
|
|
| 89 |
className={styles.knowledgeCardContainer}
|
| 90 |
>
|
| 91 |
{nextList?.length > 0 ? (
|
| 92 |
+
nextList.map((item: any, index: number) => {
|
| 93 |
return (
|
| 94 |
+
<KnowledgeCard
|
| 95 |
+
item={item}
|
| 96 |
+
key={`${item?.name}-${index}`}
|
| 97 |
+
></KnowledgeCard>
|
| 98 |
);
|
| 99 |
})
|
| 100 |
) : (
|
web/src/services/chat-service.ts
CHANGED
|
@@ -8,6 +8,7 @@ const {
|
|
| 8 |
listDialog,
|
| 9 |
removeDialog,
|
| 10 |
getConversation,
|
|
|
|
| 11 |
setConversation,
|
| 12 |
completeConversation,
|
| 13 |
listConversation,
|
|
@@ -53,6 +54,10 @@ const methods = {
|
|
| 53 |
url: getConversation,
|
| 54 |
method: 'get',
|
| 55 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
setConversation: {
|
| 57 |
url: setConversation,
|
| 58 |
method: 'post',
|
|
|
|
| 8 |
listDialog,
|
| 9 |
removeDialog,
|
| 10 |
getConversation,
|
| 11 |
+
getConversationSSE,
|
| 12 |
setConversation,
|
| 13 |
completeConversation,
|
| 14 |
listConversation,
|
|
|
|
| 54 |
url: getConversation,
|
| 55 |
method: 'get',
|
| 56 |
},
|
| 57 |
+
getConversationSSE: {
|
| 58 |
+
url: getConversationSSE,
|
| 59 |
+
method: 'get',
|
| 60 |
+
},
|
| 61 |
setConversation: {
|
| 62 |
url: setConversation,
|
| 63 |
method: 'post',
|
web/src/services/flow-service.ts
CHANGED
|
@@ -4,6 +4,7 @@ import request from '@/utils/request';
|
|
| 4 |
|
| 5 |
const {
|
| 6 |
getCanvas,
|
|
|
|
| 7 |
setCanvas,
|
| 8 |
listCanvas,
|
| 9 |
resetCanvas,
|
|
@@ -20,6 +21,10 @@ const methods = {
|
|
| 20 |
url: getCanvas,
|
| 21 |
method: 'get',
|
| 22 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
setCanvas: {
|
| 24 |
url: setCanvas,
|
| 25 |
method: 'post',
|
|
|
|
| 4 |
|
| 5 |
const {
|
| 6 |
getCanvas,
|
| 7 |
+
getCanvasSSE,
|
| 8 |
setCanvas,
|
| 9 |
listCanvas,
|
| 10 |
resetCanvas,
|
|
|
|
| 21 |
url: getCanvas,
|
| 22 |
method: 'get',
|
| 23 |
},
|
| 24 |
+
getCanvasSSE: {
|
| 25 |
+
url: getCanvasSSE,
|
| 26 |
+
method: 'get',
|
| 27 |
+
},
|
| 28 |
setCanvas: {
|
| 29 |
url: setCanvas,
|
| 30 |
method: 'post',
|
web/src/utils/api.ts
CHANGED
|
@@ -71,6 +71,7 @@ export default {
|
|
| 71 |
listDialog: `${api_host}/dialog/list`,
|
| 72 |
setConversation: `${api_host}/conversation/set`,
|
| 73 |
getConversation: `${api_host}/conversation/get`,
|
|
|
|
| 74 |
listConversation: `${api_host}/conversation/list`,
|
| 75 |
removeConversation: `${api_host}/conversation/rm`,
|
| 76 |
completeConversation: `${api_host}/conversation/completion`,
|
|
@@ -113,6 +114,7 @@ export default {
|
|
| 113 |
listTemplates: `${api_host}/canvas/templates`,
|
| 114 |
listCanvas: `${api_host}/canvas/list`,
|
| 115 |
getCanvas: `${api_host}/canvas/get`,
|
|
|
|
| 116 |
removeCanvas: `${api_host}/canvas/rm`,
|
| 117 |
setCanvas: `${api_host}/canvas/set`,
|
| 118 |
resetCanvas: `${api_host}/canvas/reset`,
|
|
|
|
| 71 |
listDialog: `${api_host}/dialog/list`,
|
| 72 |
setConversation: `${api_host}/conversation/set`,
|
| 73 |
getConversation: `${api_host}/conversation/get`,
|
| 74 |
+
getConversationSSE: `${api_host}/conversation/getsse`,
|
| 75 |
listConversation: `${api_host}/conversation/list`,
|
| 76 |
removeConversation: `${api_host}/conversation/rm`,
|
| 77 |
completeConversation: `${api_host}/conversation/completion`,
|
|
|
|
| 114 |
listTemplates: `${api_host}/canvas/templates`,
|
| 115 |
listCanvas: `${api_host}/canvas/list`,
|
| 116 |
getCanvas: `${api_host}/canvas/get`,
|
| 117 |
+
getCanvasSSE: `${api_host}/canvas/getsse`,
|
| 118 |
removeCanvas: `${api_host}/canvas/rm`,
|
| 119 |
setCanvas: `${api_host}/canvas/set`,
|
| 120 |
resetCanvas: `${api_host}/canvas/reset`,
|