mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
8e1998ddcb
* Adds Valkey to chat message history * Address review: switch to Valkey.Glide, add options class, remove context provider - Switch from StackExchange.Redis to Valkey.Glide 1.1.0 (official Valkey .NET client) - Extract optional params into ValkeyChatHistoryProviderOptions - Add JsonSerializerOptions support, remove [RequiresUnreferencedCode] - Make MaxMessages/MaxMessagesToRetrieve readonly via options - Remove ValkeyContextProvider (overlaps with ChatHistoryMemoryProvider + MEVD) - Remove ValkeyProviderScope (only used by context provider) - Remove connection string constructors (caller manages IConnectionMultiplexer) - Update samples to use new API and gpt-5.4-mini * Use type-safe JsonSerializer overloads, remove suppress attributes Use JsonSerializerOptions.GetTypeInfo() for Serialize/Deserialize calls to enable NativeAOT/trimming compatibility without suppress attributes. Default to AgentAbstractionsJsonUtilities.DefaultOptions when no options provided. Signed-off-by: Matthias Howell <matthias.howell@improving.com> * Update READMEs: remove context provider references Remove ValkeyContextProvider and long-term memory references from sample READMEs since the context provider was removed from this PR. Simplify Valkey server requirements (no search module needed for chat history). Signed-off-by: Matthias Howell <matthias.howell@improving.com> * Apply suggestion from @westey-m * Fix formatting (dotnet format) Signed-off-by: Matthias Howell <matthias.howell@improving.com> * Update dotnet/src/Microsoft.Agents.AI.Valkey/Microsoft.Agents.AI.Valkey.csproj Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> --------- Signed-off-by: Matthias Howell <matthias.howell@improving.com> Co-authored-by: Matthias Howell <matthias.howell@yoppworks.com> Co-authored-by: westey <164392973+westey-m@users.noreply.github.com> Co-authored-by: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com>
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.AI;
|
|
using Moq;
|
|
|
|
namespace Microsoft.Agents.AI.Valkey.UnitTests;
|
|
|
|
internal sealed class TestAgentSession : AgentSession
|
|
{
|
|
public TestAgentSession()
|
|
{
|
|
this.StateBag = new AgentSessionStateBag();
|
|
}
|
|
}
|
|
|
|
internal static class TestHelpers
|
|
{
|
|
internal static readonly AIAgent MockAgent = new Mock<AIAgent>().Object;
|
|
|
|
internal static ChatHistoryProvider.InvokingContext CreateChatHistoryInvokingContext(
|
|
IEnumerable<ChatMessage>? requestMessages = null)
|
|
{
|
|
#pragma warning disable MAAI001
|
|
return new ChatHistoryProvider.InvokingContext(
|
|
MockAgent,
|
|
new TestAgentSession(),
|
|
requestMessages ?? [new ChatMessage(ChatRole.User, "test")]);
|
|
#pragma warning restore MAAI001
|
|
}
|
|
|
|
internal static ChatHistoryProvider.InvokedContext CreateChatHistoryInvokedContext(
|
|
IEnumerable<ChatMessage> requestMessages,
|
|
IEnumerable<ChatMessage> responseMessages)
|
|
{
|
|
#pragma warning disable MAAI001
|
|
return new ChatHistoryProvider.InvokedContext(
|
|
MockAgent,
|
|
new TestAgentSession(),
|
|
requestMessages,
|
|
responseMessages);
|
|
#pragma warning restore MAAI001
|
|
}
|
|
}
|