Skip to content

Commit e4c7883

Browse files
committed
feat: 简易的 <think> 标签处理
1 parent af018a5 commit e4c7883

File tree

1 file changed

+15
-5
lines changed
  • spring-ai-alibaba-integration-example/frontend/src

1 file changed

+15
-5
lines changed

spring-ai-alibaba-integration-example/frontend/src/App.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,21 @@ const aiConfig = {
168168
borderRadius: 16
169169
}
170170
},
171-
messageRender: (content) => (
172-
<Typography>
173-
<ReactMarkdown>{content}</ReactMarkdown>
174-
</Typography>
175-
)
171+
messageRender: (content) => {
172+
const regex = /<think>([\s\S]*?)<\/think>/;
173+
const match = content.match(regex);
174+
175+
if (match) {
176+
const extractedContent = match[1].replace("\n", ">");
177+
const newString = content.replace(regex, "");
178+
content = extractedContent + newString;
179+
}
180+
return (
181+
<Typography>
182+
<ReactMarkdown>{content}</ReactMarkdown>
183+
</Typography>
184+
);
185+
}
176186
};
177187
const roles: GetProp<typeof Bubble.List, "roles"> = {
178188
ai: {

0 commit comments

Comments
 (0)