mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-04 04:02:56 +00:00
Dont display <think> tags (#496)
This commit is contained in:
parent
368fc9ce39
commit
793a9cae0a
@ -67,12 +67,12 @@
|
||||
@if (this.Content.IsStreaming)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Style="white-space: pre-wrap;">
|
||||
@textContent.Text
|
||||
@textContent.Text.RemoveThinkTags()
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudMarkdown Value="@textContent.Text" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo" CodeBlockTheme="@this.CodeColorPalette"/>
|
||||
<MudMarkdown Value="@textContent.Text.RemoveThinkTags().Trim()" OverrideHeaderTypo="@Markdown.OverrideHeaderTypo" CodeBlockTheme="@this.CodeColorPalette"/>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +120,8 @@ public sealed class ContentText : IContent
|
||||
this.IsStreaming = false;
|
||||
}, token);
|
||||
|
||||
this.Text = this.Text.RemoveThinkTags().Trim();
|
||||
|
||||
// Inform the UI that the streaming is done:
|
||||
await this.StreamingDone();
|
||||
return chatThread;
|
||||
|
18
app/MindWork AI Studio/Chat/StringExtension.cs
Normal file
18
app/MindWork AI Studio/Chat/StringExtension.cs
Normal file
@ -0,0 +1,18 @@
|
||||
namespace AIStudio.Chat;
|
||||
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string RemoveThinkTags(this string input)
|
||||
{
|
||||
const string OPEN_TAG = "<think>";
|
||||
const string CLOSE_TAG = "</think>";
|
||||
if (string.IsNullOrEmpty(input) || !input.StartsWith(OPEN_TAG))
|
||||
return input;
|
||||
|
||||
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
|
||||
if (endIndex == -1)
|
||||
return string.Empty;
|
||||
|
||||
return input[(endIndex + CLOSE_TAG.Length)..];
|
||||
}
|
||||
}
|
@ -2,3 +2,4 @@
|
||||
- Improved German translation.
|
||||
- Improved the confirmation dialog for longer texts.
|
||||
- Improved how configurations are applied in organizations and made the process more robust.
|
||||
- Removed `<think>` tags from streaming and final text output because of reasoning models.
|
Loading…
Reference in New Issue
Block a user