mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-07-04 16:02:56 +00:00
18 lines
567 B
C#
18 lines
567 B
C#
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.IsNullOrWhiteSpace(input) || !input.StartsWith(OPEN_TAG, StringComparison.Ordinal))
|
|
return input;
|
|
|
|
var endIndex = input.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
|
|
if (endIndex == -1)
|
|
return string.Empty;
|
|
|
|
return input[(endIndex + CLOSE_TAG.Length)..];
|
|
}
|
|
} |