AI-Studio/app/MindWork AI Studio/Chat/StringExtension.cs
2025-06-10 14:32:24 +02:00

18 lines
536 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.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)..];
}
}