Skip to content

Commit 793a9ca

Browse files
authored
Dont display <think> tags (#496)
1 parent 368fc9c commit 793a9ca

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

app/MindWork AI Studio/Chat/ContentBlockComponent.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@
6767
@if (this.Content.IsStreaming)
6868
{
6969
<MudText Typo="Typo.body1" Style="white-space: pre-wrap;">
70-
@textContent.Text
70+
@textContent.Text.RemoveThinkTags()
7171
</MudText>
7272
}
7373
else
7474
{
75-
<MudMarkdown Value="@textContent.Text" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo" CodeBlockTheme="@this.CodeColorPalette"/>
75+
<MudMarkdown Value="@textContent.Text.RemoveThinkTags().Trim()" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo" CodeBlockTheme="@this.CodeColorPalette"/>
7676
}
7777
}
7878
}

app/MindWork AI Studio/Chat/ContentText.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ await Task.Run(async () =>
119119
this.InitialRemoteWait = false;
120120
this.IsStreaming = false;
121121
}, token);
122+
123+
this.Text = this.Text.RemoveThinkTags().Trim();
122124

123125
// Inform the UI that the streaming is done:
124126
await this.StreamingDone();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace AIStudio.Chat;
2+
3+
public static class StringExtensions
4+
{
5+
public static string RemoveThinkTags(this string input)
6+
{
7+
const string OPEN_TAG = "<think>";
8+
const string CLOSE_TAG = "</think>";
9+
if (string.IsNullOrEmpty(input) || !input.StartsWith(OPEN_TAG))
10+
return input;
11+
12+
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
13+
if (endIndex == -1)
14+
return string.Empty;
15+
16+
return input[(endIndex + CLOSE_TAG.Length)..];
17+
}
18+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# v0.9.48, build 223 (2025-06-xx xx:xx UTC)
22
- Improved German translation.
33
- Improved the confirmation dialog for longer texts.
4-
- Improved how configurations are applied in organizations and made the process more robust.
4+
- Improved how configurations are applied in organizations and made the process more robust.
5+
- Removed `<think>` tags from streaming and final text output because of reasoning models.

0 commit comments

Comments
 (0)