Dont display <think> tags (#496)

This commit is contained in:
Peer Schütt authored and GitHub committed 2025-06-10 14:32:24 +02:00
1 parent 368fc9ce39
commit 793a9cae0a
4 files changed
+24 -3

No files matched your search

@@ -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)..];
}
}