Skip to content

Commit fecef4f

Browse files
carolin913LzhengH
andauthored
Fix/chatbot export 0603 (#224)
* feat(chatsender): 补充textarea插槽 * feat(thinking): 修复thinking更新时无法收起展开的问题 breakingChange: 单独使用thinking组件的场景需要补充参数 * feat(filecard): desc style * feat(chatmessage): systemmessage style and remove sendprops onsend --------- Co-authored-by: brightzhli <864345220@qq.com>
1 parent 2612a4b commit fecef4f

3 files changed

Lines changed: 19 additions & 40 deletions

File tree

src/chat-message/style/chat-item.less

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,10 @@
6060
}
6161

6262
&.@{prefix}-chat__item__role-- {
63-
// system渲染固定样式
6463
&system {
6564
.@{prefix}-chat__item__main {
6665
align-items: center;
6766
}
68-
.@{prefix}-chat__item__detail {
69-
margin: var(--td-chat-item-system-margin);
70-
padding: var(--td-chat-item-system-padding);
71-
border-radius: var(--td-chat-item-system-radius);
72-
background-color: var(--td-chat-item-system-bg-color);
73-
font-size: var(--td-chat-item-system-font-size);
74-
}
75-
.@{prefix}-chat__text__markdown {
76-
color: var(--td-chat-item-system-color);
77-
}
7867
}
7968
}
8069

@@ -528,6 +517,14 @@
528517
word-wrap: break-word;
529518
white-space: pre-wrap;
530519
}
520+
&--system {
521+
margin: var(--td-chat-item-system-margin);
522+
padding: var(--td-chat-item-system-padding);
523+
border-radius: var(--td-chat-item-system-radius);
524+
background-color: var(--td-chat-item-system-bg-color);
525+
font-size: var(--td-chat-item-system-font-size);
526+
color: var(--td-chat-item-system-color);
527+
}
531528

532529
}
533530
.@{prefix}-chat-actions {

src/chatbot/_example/basic.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,11 @@ const mockData: ChatMessagesData[] = [
159159
],
160160
},
161161
{
162-
id: '34234',
163-
status: 'error',
162+
id: '8d51e238-wewrwer-35_6',
163+
status: 'complete',
164164
role: 'assistant',
165-
content: [
166-
{
167-
type: 'text',
168-
data: '出错了',
169-
},
170-
],
165+
comment: '',
166+
content: [],
171167
},
172168
{
173169
id: '7389',
@@ -198,16 +194,11 @@ const mockData: ChatMessagesData[] = [
198194
],
199195
},
200196
{
201-
id: '3242',
202-
role: 'assistant',
197+
id: '8d51e238-d1bd-49c8-a31e-b60ac324f235_6',
203198
status: 'complete',
204-
comment: 'good',
205-
content: [
206-
{
207-
type: 'markdown',
208-
data: '**tdesign** 团队的 *核心开发者* `uyarnchen` 是也。',
209-
},
210-
],
199+
role: 'assistant',
200+
comment: '',
201+
content: [],
211202
},
212203
];
213204

@@ -328,8 +319,6 @@ const mockModels = {
328319
},
329320
body: JSON.stringify({
330321
session_id: 'session_123456789',
331-
search: true,
332-
think: true,
333322
question: [
334323
{
335324
id: messageID,

src/chatbot/chat.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -254,17 +254,10 @@ export default class Chatbot extends Component<TdChatProps> implements TdChatbot
254254
*/
255255
private handleSend = async (e: CustomEvent<TdChatSenderParams>) => {
256256
const { value, attachments } = e.detail;
257-
let params = {
257+
const params = {
258258
prompt: value,
259259
attachments,
260260
} as ChatRequestParams;
261-
if (this.props?.senderProps?.onSend) {
262-
const customParams = await this.props.senderProps.onSend(e);
263-
// 这里允许用户修改生成消息的参数
264-
if (customParams) {
265-
params = customParams;
266-
}
267-
}
268261
await this.sendUserMessage(params);
269262
this.scrollToBottom();
270263
};
@@ -313,7 +306,7 @@ export default class Chatbot extends Component<TdChatProps> implements TdChatbot
313306
private renderItems = () => {
314307
const items = this.props.reverse ? [...this.chatMessageValue].reverse() : this.chatMessageValue;
315308
return items.map((item) => {
316-
const { role, id } = item;
309+
const { role, id, content } = item;
317310
const itemSlotNames = this.slotNames.filter((key) => key.includes(id));
318311
let itemProps = {
319312
...this.messageRoleProps?.[role],
@@ -330,7 +323,7 @@ export default class Chatbot extends Component<TdChatProps> implements TdChatbot
330323
return <slot name={slotName} slot={str}></slot>;
331324
})}
332325
{/* 渲染actionBar */}
333-
{item.status !== 'complete' && item.status !== 'stop' ? null : (
326+
{content.length === 0 || (item.status !== 'complete' && item.status !== 'stop') ? null : (
334327
<t-chat-action
335328
slot="actionbar"
336329
actionBar={this.getChatActionBar(itemProps) as TdChatActionsName[]}

0 commit comments

Comments
 (0)