Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@((MarkupString)Markdown.ToHtml(agentChatMessage.Message.Content))
</div>
<div>
使用されたエージェント: @string.Join(", ", agentChatMessage.Message.CalledAgentNames)
使用されたエージェント: @string.Join(", ", agentChatMessage.Message.CalledAgentNames ?? [])
</div>
</FluentGridItem>
</FluentGrid>
Expand Down
9 changes: 7 additions & 2 deletions DurableMultiAgentTemplate.Client/Services/AgentChatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ public async Task<AgentResponseWithAdditionalInfoDto> GetAgentResponseAsync(Agen
IProgress<AgentOrchestratorStatus>? progress = null,
CancellationToken cancellationToken = default)
{
var response = await httpClient.PostAsJsonAsync("api/invoke/async", agentRequestDto, cancellationToken);
var response = await httpClient.PostAsJsonAsync("api/invoke/async",
agentRequestDto,
_jsonSerializerOptions,
cancellationToken);
response.EnsureSuccessStatusCode();

var agentOrchestratorStatus = AgentOrchestratorStatus.NotStarted;
Expand All @@ -35,9 +38,11 @@ public async Task<AgentResponseWithAdditionalInfoDto> GetAgentResponseAsync(Agen
throw new InvalidOperationException("The format of the response from the agent is invalid.");

// The response from the agent is an async response, so we need to poll the status until it's completed.
var statusQueryGetUri = new Uri(invokeAsyncResult.StatusQueryGetUri).PathAndQuery;
statusQueryGetUri = statusQueryGetUri.TrimStart('/');
while (cancellationToken.IsCancellationRequested == false)
{
var statusResponse = await httpClient.GetAsync(invokeAsyncResult.StatusQueryGetUri, cancellationToken);
var statusResponse = await httpClient.GetAsync(statusQueryGetUri, cancellationToken);
statusResponse.EnsureSuccessStatusCode();
var status = await statusResponse.Content.ReadFromJsonAsync<OrchestrationStatus>(_jsonSerializerOptions, cancellationToken)
?? throw new InvalidOperationException("The format of the status response from the agent is invalid.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
},
"Services": {
"backend": {
"httpxxx": [
"http://localhost:7133/"
],
"http": [
"http://localhost:7133"
"https://cautious-carnival-g45p4rwr7fv7pg-7071.app.github.dev/"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public AgentOrchestratorStatus(AgentOrchestratorStep step)
/// <summary>
/// Defines the steps of the agent orchestrator.
/// </summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum AgentOrchestratorStep
{
/// <summary>
Expand Down
1 change: 1 addition & 0 deletions DurableMultiAgentTemplate.Shared/Model/IAdditionalInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace DurableMultiAgentTemplate.Shared.Model;
/// Interface for additional information.
/// Classes implementing this interface are used as supplementary information added to agent responses.
/// </summary>
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
[JsonDerivedType(typeof(AdditionalMarkdownInfo), typeDiscriminator: "markdown")]
[JsonDerivedType(typeof(AdditionalLinkInfo), typeDiscriminator: "link")]
public interface IAdditionalInfo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Text.Json;
using DurableMultiAgentTemplate.Shared.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DurableMultiAgentTemplate.Model; // 追加

namespace DurableMultiAgentTemplate.Test.Model;

[TestClass]
public class AdditionalInfoSerializationTest
{
[TestMethod]
public void AdditionalMarkdownInfo_SerializeDeserialize_WorksCorrectly()
{
var original = new AdditionalMarkdownInfo("**bold text**");
IAdditionalInfo info = original;
var options = new JsonSerializerOptions { TypeInfoResolver = SourceGenerationContext.Default };
string json = JsonSerializer.Serialize(info, typeof(IAdditionalInfo), options);
var deserialized = (IAdditionalInfo)JsonSerializer.Deserialize(json, typeof(IAdditionalInfo), options)!;
Assert.IsInstanceOfType(deserialized, typeof(AdditionalMarkdownInfo));
Assert.AreEqual(original.MarkdownText, ((AdditionalMarkdownInfo)deserialized).MarkdownText);
}

[TestMethod]
public void AdditionalLinkInfo_SerializeDeserialize_WorksCorrectly()
{
var original = new AdditionalLinkInfo("Google", new Uri("https://www.google.com/"));
IAdditionalInfo info = original;
var options = new JsonSerializerOptions { TypeInfoResolver = SourceGenerationContext.Default };
string json = JsonSerializer.Serialize(info, typeof(IAdditionalInfo), options);
var deserialized = (IAdditionalInfo)JsonSerializer.Deserialize(json, typeof(IAdditionalInfo), options)!;
Assert.IsInstanceOfType(deserialized, typeof(AdditionalLinkInfo));
var link = (AdditionalLinkInfo)deserialized;
Assert.AreEqual(original.LinkText, link.LinkText);
Assert.AreEqual(original.Uri, link.Uri);
}
}
4 changes: 2 additions & 2 deletions DurableMultiAgentTemplate/Model/SourceGenerationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace DurableMultiAgentTemplate.Model;
/// Configures the JSON serialization options and declares serializable types
/// for performance optimization through source generation.
/// </summary>
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true)]
[JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, PropertyNameCaseInsensitive = false)]
[JsonSerializable(typeof(GetClimateRequest))]
[JsonSerializable(typeof(GetDestinationSuggestRequest))]
[JsonSerializable(typeof(GetHotelRequest))]
Expand All @@ -24,4 +24,4 @@ namespace DurableMultiAgentTemplate.Model;
[JsonSerializable(typeof(AdditionalMarkdownInfo))]
[JsonSerializable(typeof(AdditionalLinkInfo))]
[JsonSerializable(typeof(AgentResponseWithAdditionalInfoFormat))]
internal partial class SourceGenerationContext : JsonSerializerContext;
public partial class SourceGenerationContext : JsonSerializerContext;
Loading