Skip to content

Commit d921017

Browse files
committed
fix: 开源业务创建会话和查询会话时增加 user_id
1 parent 2a0267a commit d921017

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

frontend/packages/studio/open-platform/open-chat/src/components/conversation-list-sider/conversation-list/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
type SortedConversationItem,
3535
} from '@/types/conversations';
3636
import { Layout } from '@/types/client';
37+
import { useUserInfo } from '@/components/studio-open-chat/hooks';
3738

3839
import {
3940
PcConversationItem,
@@ -93,6 +94,8 @@ export const ConversationList = forwardRef<
9394
})),
9495
);
9596

97+
const userInfo = useUserInfo();
98+
9699
const conversationRef = useRef<ChatState['currentConversationInfo']>();
97100
const [addLoading, setAddLoading] = useState(false);
98101
const {
@@ -114,6 +117,7 @@ export const ConversationList = forwardRef<
114117
bot_id: botId,
115118
// @ts-expect-error: 有这个属性,但是 openapi 没有暴露
116119
connector_id: connectorId,
120+
user_id: IS_OPEN_SOURCE ? userInfo?.id : undefined,
117121
});
118122
if (res?.id) {
119123
conversationRef.current = {

frontend/packages/studio/open-platform/open-chat/src/components/studio-open-chat/provider/coz-sdk/api-adapter/use-clear-history.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { type SceneConfig } from '@coze-common/chat-core';
2020

2121
import { OpenApiSource } from '@/types/open';
2222
import { useChatAppProps } from '@/components/studio-open-chat/store';
23+
import { useUserInfo } from '@/components/studio-open-chat/hooks';
2324

2425
import { type ChatProviderFunc } from '../type';
2526
export const useClearHistoryAdapter = ({
@@ -29,6 +30,7 @@ export const useClearHistoryAdapter = ({
2930
}): SceneConfig => {
3031
const { chatConfig } = useChatAppProps();
3132
const refConnectorId = useRef('');
33+
const userInfo = useUserInfo();
3234
refConnectorId.current = chatConfig?.auth?.connectorId || '';
3335

3436
return useMemo(() => {
@@ -60,7 +62,11 @@ export const useClearHistoryAdapter = ({
6062
const botId = requestConfig.data.bot_id;
6163
return {
6264
...requestConfig,
63-
data: { bot_id: botId, connector_id: refConnectorId.current },
65+
data: {
66+
bot_id: botId,
67+
connector_id: refConnectorId.current,
68+
user_id: IS_OPEN_SOURCE ? userInfo?.id : undefined,
69+
},
6470
};
6571
},
6672
],

frontend/packages/studio/open-platform/open-chat/src/components/studio-open-chat/provider/coz-sdk/use-request-init.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
import { useCallback } from 'react';
1818

1919
import { type ShortCutCommand } from '@coze-common/chat-area-plugins-chat-shortcuts';
20-
import { type MixInitResponse } from '@coze-common/chat-area';
20+
import {
21+
type UserSenderInfo,
22+
type MixInitResponse,
23+
} from '@coze-common/chat-area';
2124
import i18n from '@coze-arch/i18n/intl';
2225
import { type BotInfo, type CozeAPI } from '@coze/api';
2326

@@ -134,12 +137,14 @@ const getConversationInfo = async ({
134137
connectorId,
135138
defaultHistoryMessage,
136139
onDefaultHistoryClear,
140+
userInfo,
137141
}: GetRequestInfoProps & {
138142
conversationId?: string;
139143
sectionId?: string;
140144
connectorId: string;
141145
defaultHistoryMessage?: MixInitResponse['messageList'];
142146
onDefaultHistoryClear?: () => void;
147+
userInfo: UserSenderInfo | null;
143148
}): Promise<
144149
Pick<
145150
MixInitResponse,
@@ -161,6 +166,7 @@ const getConversationInfo = async ({
161166
connector_id: connectorId,
162167
page_num: 1,
163168
page_size: 1,
169+
user_id: IS_OPEN_SOURCE ? userInfo?.id : undefined,
164170
},
165171
)) as {
166172
data: {
@@ -182,9 +188,10 @@ const getConversationInfo = async ({
182188
await cozeApiSdk.conversations.create(
183189
{
184190
bot_id: botId,
185-
messages: historyMessage,
186191
// @ts-expect-error: connector_id is not in the type
192+
messages: historyMessage,
187193
connector_id: connectorId,
194+
user_id: IS_OPEN_SOURCE ? userInfo?.id : undefined,
188195
},
189196
{
190197
headers: {
@@ -204,6 +211,7 @@ const getConversationInfo = async ({
204211
bot_id: botId,
205212
// @ts-expect-error: connector_id is not in the type
206213
connector_id: connectorId,
214+
user_id: IS_OPEN_SOURCE ? userInfo?.id : undefined,
207215
},
208216
{
209217
headers: {
@@ -329,6 +337,7 @@ export const useRequestInit = () => {
329337
connectorId,
330338
onDefaultHistoryClear,
331339
defaultHistoryMessage,
340+
userInfo,
332341
}),
333342
]);
334343
const prologue = (requestDataBotInfo.prologue || '').replaceAll(

0 commit comments

Comments
 (0)