mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 09:18:00 +00:00
Added tool calling support (#731)
Co-authored-by: krut_ni <nils.kruthoff@dlr.de> Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
266 files changed
+11186
-740
No files matched your search
@@ -0,0 +1,20 @@
|
||||
namespace AIStudio.Tools.ToolCallingSystem;
|
||||
|
||||
internal static class MarkdownTruncator
|
||||
{
|
||||
public static string Truncate(string markdown, int maxCharacters)
|
||||
{
|
||||
const string TRUNCATION_MARKER = "[Page content truncated]";
|
||||
if (maxCharacters <= TRUNCATION_MARKER.Length)
|
||||
return markdown[..maxCharacters];
|
||||
|
||||
var contentLimit = maxCharacters - TRUNCATION_MARKER.Length - 2;
|
||||
var breakPosition = markdown.LastIndexOf("\n\n", contentLimit, StringComparison.Ordinal);
|
||||
if (breakPosition < contentLimit / 2)
|
||||
breakPosition = markdown.LastIndexOf('\n', contentLimit);
|
||||
if (breakPosition < contentLimit / 2)
|
||||
breakPosition = contentLimit;
|
||||
|
||||
return $"{markdown[..breakPosition].TrimEnd()}\n\n{TRUNCATION_MARKER}";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user