mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-20 22:32:56 +00:00
Removed <think>
tags from text processing in reasoning models and updated related components.
This commit is contained in:
parent
cccadcea07
commit
473036c739
@ -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.RemoveThinkTags()" 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;
|
||||
|
@ -4,13 +4,15 @@ public static class StringExtensions
|
||||
{
|
||||
public static string RemoveThinkTags(this string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input) || !input.StartsWith("<think>"))
|
||||
const string OPEN_TAG = "<think>";
|
||||
const string CLOSE_TAG = "</think>";
|
||||
if (string.IsNullOrEmpty(input) || !input.StartsWith(OPEN_TAG))
|
||||
return input;
|
||||
|
||||
int endIndex = input.IndexOf("</think>");
|
||||
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
|
||||
if (endIndex == -1)
|
||||
return input;
|
||||
return string.Empty;
|
||||
|
||||
return input.Substring(endIndex + "</think>".Length);
|
||||
return input[(endIndex + CLOSE_TAG.Length)..];
|
||||
}
|
||||
}
|
@ -1 +1,2 @@
|
||||
# v0.9.48, build 223 (2025-06-xx xx:xx UTC)
|
||||
- Removed `<think>` tags from streaming and final text output because of reasoning models.
|
Loading…
Reference in New Issue
Block a user