Use ReadOnlyMemory<byte> for binary data to eliminate UTF-16 transcoding (#1070)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com> Co-authored-by: Eric StJohn <ericstj@microsoft.com>
This commit is contained in:
parent
a3ce9e9606
commit
80b1ad21d7
2 changed files with 400 additions and 103 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using ModelContextProtocol.Protocol;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace EverythingServer.Resources;
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ public class SimpleResourceType
|
|||
} :
|
||||
new BlobResourceContents
|
||||
{
|
||||
Blob = resource.Description!,
|
||||
Blob = Encoding.UTF8.GetBytes(resource.Description!),
|
||||
MimeType = resource.MimeType,
|
||||
Uri = resource.Uri,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using ModelContextProtocol.Protocol;
|
||||
using ModelContextProtocol.Server;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace EverythingServer.Tools;
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ public class AnnotatedMessageTool
|
|||
{
|
||||
contents.Add(new ImageContentBlock
|
||||
{
|
||||
Data = TinyImageTool.MCP_TINY_IMAGE.Split(",").Last(),
|
||||
Data = Encoding.UTF8.GetBytes(TinyImageTool.MCP_TINY_IMAGE.Split(",").Last()),
|
||||
MimeType = "image/png",
|
||||
Annotations = new() { Audience = [Role.User], Priority = 0.5f }
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue