diff --git a/DurableMultiAgentTemplate.Client/Components/Pages/Home.razor.cs b/DurableMultiAgentTemplate.Client/Components/Pages/Home.razor.cs index 2ee9528..16bdc1b 100644 --- a/DurableMultiAgentTemplate.Client/Components/Pages/Home.razor.cs +++ b/DurableMultiAgentTemplate.Client/Components/Pages/Home.razor.cs @@ -7,6 +7,10 @@ namespace DurableMultiAgentTemplate.Client.Components.Pages; +/// +/// Main home page component for the chat interface. +/// Handles user interactions and communication with agent services. +/// public partial class Home(AgentChatService agentChatService, ILogger logger) { private const int _chatTimeoutMs = 60000; @@ -17,6 +21,10 @@ public partial class Home(AgentChatService agentChatService, ILogger logge private readonly List _messages = []; private readonly List _additionalInfo = []; + /// + /// Sends a message to the agent and processes the response. + /// Manages the UI state during the request/response cycle. + /// private async Task SendMessageAsync() { void handleError(string originalInputMessage, string errorMessage) @@ -105,6 +113,9 @@ static string createStatusMessage(AgentOrchestratorStatus status) } } + /// + /// Resets the chat interface by clearing all messages and additional information. + /// private void Reset() { _messages.Clear(); diff --git a/DurableMultiAgentTemplate.Client/Components/Utilities/ScrollToBottomContext.cs b/DurableMultiAgentTemplate.Client/Components/Utilities/ScrollToBottomContext.cs index b20cdde..51c8161 100644 --- a/DurableMultiAgentTemplate.Client/Components/Utilities/ScrollToBottomContext.cs +++ b/DurableMultiAgentTemplate.Client/Components/Utilities/ScrollToBottomContext.cs @@ -1,14 +1,29 @@ namespace DurableMultiAgentTemplate.Client.Components.Utilities; +/// +/// Context class for managing scroll-to-bottom operations in the UI. +/// Used to communicate scroll requests between components. +/// public class ScrollToBottomContext { + /// + /// Gets a value indicating whether a scroll to bottom operation has been requested. + /// public bool IsRequestScrollToBottom { get; private set; } + /// + /// Requests a scroll to bottom operation. + /// Sets the IsRequestScrollToBottom flag to true. + /// public void RequestScrollToBottom() { IsRequestScrollToBottom = true; } + /// + /// Resets the scroll request. + /// Sets the IsRequestScrollToBottom flag to false. + /// public void Reset() { IsRequestScrollToBottom = false; diff --git a/DurableMultiAgentTemplate.Client/Http/AzureFunctionsApiKeyAuthenticationHttpMessageHandler.cs b/DurableMultiAgentTemplate.Client/Http/AzureFunctionsApiKeyAuthenticationHttpMessageHandler.cs index 416a39d..aa6757a 100644 --- a/DurableMultiAgentTemplate.Client/Http/AzureFunctionsApiKeyAuthenticationHttpMessageHandler.cs +++ b/DurableMultiAgentTemplate.Client/Http/AzureFunctionsApiKeyAuthenticationHttpMessageHandler.cs @@ -2,8 +2,18 @@ namespace DurableMultiAgentTemplate.Client.Http; +/// +/// HTTP message handler that adds Azure Functions API key authentication to requests. +/// Implements the delegating handler pattern to inject authentication headers. +/// public class AzureFunctionsApiKeyAuthenticationHttpMessageHandler(IOptions backendOptions) : DelegatingHandler { + /// + /// Sends an HTTP request to the inner handler after adding the API key header if configured. + /// + /// The HTTP request message to send. + /// A cancellation token to cancel the operation. + /// The HTTP response message. protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { if (!string.IsNullOrEmpty(backendOptions.Value.ApiKey)) diff --git a/DurableMultiAgentTemplate.Client/Model/ChatInput.cs b/DurableMultiAgentTemplate.Client/Model/ChatInput.cs index 499c551..383c908 100644 --- a/DurableMultiAgentTemplate.Client/Model/ChatInput.cs +++ b/DurableMultiAgentTemplate.Client/Model/ChatInput.cs @@ -1,7 +1,18 @@ namespace DurableMultiAgentTemplate.Client.Model; +/// +/// Represents user chat input in the client application. +/// Contains the message text and a flag indicating whether additional information is required. +/// public class ChatInput { + /// + /// Gets or sets a value indicating whether the response should include additional information. + /// public bool RequireAdditionalInfo { get; set; } + + /// + /// Gets or sets the message content entered by the user. + /// public string Message { get; set; } = ""; } diff --git a/DurableMultiAgentTemplate.Client/Model/ChatMessage.cs b/DurableMultiAgentTemplate.Client/Model/ChatMessage.cs index a6961af..985cf3c 100644 --- a/DurableMultiAgentTemplate.Client/Model/ChatMessage.cs +++ b/DurableMultiAgentTemplate.Client/Model/ChatMessage.cs @@ -2,20 +2,67 @@ namespace DurableMultiAgentTemplate.Client.Model; +/// +/// Abstract record representing a chat message in the conversation. +/// Base class for different types of messages in the chat interface. +/// +/// The role of the message sender. +/// Indicates whether the message is a target for a request. public abstract record ChatMessage(Role Role, bool IsRequestTarget); + +/// +/// Record representing a message from the user. +/// +/// The content of the user's message. public record UserChatMessage(string Message) : ChatMessage(Role.User, true); + +/// +/// Record representing a message from the agent. +/// Contains the response data including any additional information. +/// +/// The agent's response data. public record AgentChatMessage(AgentResponseWithAdditionalInfoDto Message) : ChatMessage(Role.Assistant, true); + +/// +/// Record representing an informational message in the chat. +/// Used for system messages and status updates. +/// +/// The informational text. +/// Indicates whether to display progress information. public record InfoChatMessage(string Info, bool IsShowProgress) : ChatMessage(Role.Info, false); +/// +/// Enum defining the possible roles in a conversation. +/// public enum Role { + /// + /// Represents a human user. + /// User, + + /// + /// Represents an AI assistant. + /// Assistant, + + /// + /// Represents an informational system message. + /// Info } +/// +/// Extension methods for the Role enum. +/// public static class RoleExtensions { + /// + /// Converts a Role enum value to its string representation. + /// + /// The role to convert. + /// String representation of the role. + /// Thrown when an unsupported role is provided. public static string ToRoleName(this Role role) => role switch { Role.User => "user", diff --git a/DurableMultiAgentTemplate.Client/Utilities/ExecutionTracker.cs b/DurableMultiAgentTemplate.Client/Utilities/ExecutionTracker.cs index eac7477..b4bfe86 100644 --- a/DurableMultiAgentTemplate.Client/Utilities/ExecutionTracker.cs +++ b/DurableMultiAgentTemplate.Client/Utilities/ExecutionTracker.cs @@ -1,9 +1,22 @@ namespace DurableMultiAgentTemplate.Client.Utilities; +/// +/// Tracks the execution state of operations. +/// Helps prevent concurrent operations by maintaining a flag for operations in progress. +/// public class ExecutionTracker { + /// + /// Gets a value indicating whether an operation is currently in progress. + /// public bool IsInProgress { get; private set; } + /// + /// Starts tracking an execution and returns a disposable scope. + /// When the scope is disposed, the execution is marked as completed. + /// + /// A disposable scope that, when disposed, marks the execution as completed. + /// Thrown if an execution is already in progress. public Scope Start() { if (IsInProgress) @@ -15,8 +28,15 @@ public Scope Start() return new Scope(this); } + /// + /// Represents a scope of execution. + /// When disposed, marks the associated execution tracker's operation as completed. + /// public struct Scope(ExecutionTracker executionTracker) : IDisposable { + /// + /// Marks the execution as completed. + /// public void Dispose() => executionTracker.IsInProgress = false; } } diff --git a/DurableMultiAgentTemplate.Shared/Model/AgentResponseDto.cs b/DurableMultiAgentTemplate.Shared/Model/AgentResponseDto.cs index 8b7fbb2..785db57 100644 --- a/DurableMultiAgentTemplate.Shared/Model/AgentResponseDto.cs +++ b/DurableMultiAgentTemplate.Shared/Model/AgentResponseDto.cs @@ -12,6 +12,10 @@ public record AgentResponseDto( string Content, List CalledAgentNames) { + /// + /// Initializes a new instance of the AgentResponseDto class with empty called agent names. + /// + /// The content of the response. public AgentResponseDto(string content) : this(content, []) { } diff --git a/DurableMultiAgentTemplate.Shared/Model/AgentResponseWithAdditionalInfoDto.cs b/DurableMultiAgentTemplate.Shared/Model/AgentResponseWithAdditionalInfoDto.cs index 895c580..4046a16 100644 --- a/DurableMultiAgentTemplate.Shared/Model/AgentResponseWithAdditionalInfoDto.cs +++ b/DurableMultiAgentTemplate.Shared/Model/AgentResponseWithAdditionalInfoDto.cs @@ -14,6 +14,10 @@ public record AgentResponseWithAdditionalInfoDto(string Content, List CalledAgentNames, List AdditionalInfo) : AgentResponseDto(Content, CalledAgentNames) { + /// + /// Initializes a new instance of the AgentResponseWithAdditionalInfoDto class with empty called agent names and additional info. + /// + /// The content of the response. public AgentResponseWithAdditionalInfoDto(string content) : this(content, [], []) { } diff --git a/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderActivity.cs b/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderActivity.cs index 7409c2d..9b19add 100644 --- a/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderActivity.cs +++ b/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderActivity.cs @@ -8,8 +8,18 @@ namespace DurableMultiAgentTemplate.Agent.AgentDecider; +/// +/// Activity class responsible for determining which agent(s) should be called based on user request. +/// Analyzes user input and decides appropriate agent routing for the multi-agent system. +/// public class AgentDeciderActivity(ChatClient chatClient, ILogger logger) { + /// + /// Executes the agent decision logic to determine which agents should be called. + /// Analyzes user messages and uses OpenAI function calling to route to appropriate agents. + /// + /// Request data containing user messages and configuration + /// Agent decision result indicating whether agent calls are needed and which agents to call [Function(AgentActivityName.AgentDeciderActivity)] public async Task Run([ActivityTrigger] AgentRequestDto reqData) { diff --git a/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderPrompt.cs b/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderPrompt.cs index 89d32d5..78aa3c3 100644 --- a/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderPrompt.cs +++ b/DurableMultiAgentTemplate/Agent/AgentDecider/AgentDeciderPrompt.cs @@ -1,5 +1,9 @@ namespace DurableMultiAgentTemplate.Agent.AgentDecider; +/// +/// Static class containing prompt templates for the AgentDecider. +/// Provides the system prompt used to guide the agent's decision-making process. +/// internal static class AgentDeciderPrompt { // Orchestrator Agent functions diff --git a/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateActivity.cs b/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateActivity.cs index cb0f101..46ec0b5 100644 --- a/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateActivity.cs +++ b/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateActivity.cs @@ -4,9 +4,19 @@ namespace DurableMultiAgentTemplate.Agent.GetClimateAgent; +/// +/// Activity class responsible for retrieving climate information for a specified location. +/// Part of the multi-agent travel concierge system. +/// public class GetClimateActivity(ChatClient chatClient, ILogger logger) { + /// + /// Retrieves climate information for the specified location. + /// Simulates a network call with potential failures and returns detailed climate data. + /// + /// Request containing the location for which to retrieve climate information + /// Detailed climate information for the specified location in Japanese [Function(AgentActivityName.GetClimateAgent)] public async Task RunAsync([ActivityTrigger] GetClimateRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateRequest.cs b/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateRequest.cs index 255b8b2..5de8b80 100644 --- a/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateRequest.cs +++ b/DurableMultiAgentTemplate/Agent/GetClimateAgent/GetClimateRequest.cs @@ -2,6 +2,10 @@ namespace DurableMultiAgentTemplate.Agent.GetClimateAgent; +/// +/// Record representing a request to retrieve climate information. +/// Used as input for the GetClimateActivity. +/// public record GetClimateRequest( [property: Description("場所の名前。例: ボストン, 東京、フランス")] string Location); diff --git a/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestActivity.cs b/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestActivity.cs index c8aa221..037172d 100644 --- a/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestActivity.cs +++ b/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestActivity.cs @@ -4,9 +4,19 @@ namespace DurableMultiAgentTemplate.Agent.GetDestinationSuggestAgent; +/// +/// Activity class responsible for suggesting travel destinations based on user preferences. +/// Provides recommendations for both domestic and international locations. +/// public class GetDestinationSuggestActivity(ChatClient chatClient, ILogger logger) { + /// + /// Generates travel destination suggestions based on the provided search criteria. + /// Simulates a network call with potential failures and returns categorized destination recommendations. + /// + /// Request containing search terms and criteria for destination suggestions + /// Categorized destination suggestions (domestic and international) in Japanese [Function(AgentActivityName.GetDestinationSuggestAgent)] public async Task RunAsync([ActivityTrigger] GetDestinationSuggestRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestRequest.cs b/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestRequest.cs index 75efc12..efdd4dd 100644 --- a/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestRequest.cs +++ b/DurableMultiAgentTemplate/Agent/GetDestinationSuggestAgent/GetDestinationSuggestRequest.cs @@ -2,6 +2,10 @@ namespace DurableMultiAgentTemplate.Agent.GetDestinationSuggestAgent; +/// +/// Record representing a request to suggest travel destinations. +/// Used as input for the GetDestinationSuggestActivity. +/// public record GetDestinationSuggestRequest( [property: Description("行き先に求める希望の条件")] string SearchTerm); diff --git a/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelActivity.cs b/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelActivity.cs index dd04435..1e8b652 100644 --- a/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelActivity.cs +++ b/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelActivity.cs @@ -4,9 +4,19 @@ namespace DurableMultiAgentTemplate.Agent.GetHotelAgent; +/// +/// Activity class responsible for retrieving hotel information for a specified location. +/// Part of the multi-agent travel concierge system. +/// public class GetHotelActivity(ChatClient chatClient, ILogger logger) { + /// + /// Retrieves hotel information for the specified location. + /// Simulates a network call with potential failures and returns hotel recommendations. + /// + /// Request containing the location for which to retrieve hotel information + /// Detailed hotel recommendations for the specified location in Japanese [Function(AgentActivityName.GetHotelAgent)] public async Task Run([ActivityTrigger] GetHotelRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelRequest.cs b/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelRequest.cs index 4cb77ff..ccde1a7 100644 --- a/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelRequest.cs +++ b/DurableMultiAgentTemplate/Agent/GetHotelAgent/GetHotelRequest.cs @@ -2,6 +2,10 @@ namespace DurableMultiAgentTemplate.Agent.GetHotelAgent; +/// +/// Record representing a request to retrieve hotel information. +/// Used as input for the GetHotelActivity. +/// public record GetHotelRequest( [property: Description("場所の名前。例: ボストン, 東京、フランス")] string Location); diff --git a/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotActivity.cs b/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotActivity.cs index 377ab37..5cccef3 100644 --- a/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotActivity.cs +++ b/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotActivity.cs @@ -4,9 +4,19 @@ namespace DurableMultiAgentTemplate.Agent.GetSightseeingSpotAgent; +/// +/// Activity class responsible for providing information about sightseeing spots at a specified location. +/// Delivers details about temples, natural attractions, beaches, cultural experiences, and activities. +/// public class GetSightseeingSpotActivity(ChatClient chatClient, ILogger logger) { + /// + /// Retrieves detailed information about sightseeing spots at the specified location. + /// Simulates a network call with potential failures and returns comprehensive attraction recommendations. + /// + /// Request containing the location for which to retrieve sightseeing information + /// Detailed information about temples, nature spots, beaches, cultural experiences, and activities in Japanese [Function(AgentActivityName.GetSightseeingSpotAgent)] public async Task RunAsync([ActivityTrigger] GetSightseeingSpotRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotRequest.cs b/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotRequest.cs index 84a1640..d1b85a7 100644 --- a/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotRequest.cs +++ b/DurableMultiAgentTemplate/Agent/GetSightseeingSpotAgent/GetSightseeingSpotRequest.cs @@ -2,6 +2,10 @@ namespace DurableMultiAgentTemplate.Agent.GetSightseeingSpotAgent; +/// +/// Record representing a request to retrieve sightseeing spot information. +/// Used as input for the GetSightseeingSpotActivity. +/// public record GetSightseeingSpotRequest( [property: Description("場所の名前。例: ボストン, 東京、フランス")] string Location); diff --git a/DurableMultiAgentTemplate/Agent/Orchestrator/AgentOrchestrator.cs b/DurableMultiAgentTemplate/Agent/Orchestrator/AgentOrchestrator.cs index 1c0ea9f..b976218 100644 --- a/DurableMultiAgentTemplate/Agent/Orchestrator/AgentOrchestrator.cs +++ b/DurableMultiAgentTemplate/Agent/Orchestrator/AgentOrchestrator.cs @@ -8,6 +8,11 @@ namespace DurableMultiAgentTemplate.Agent.Orchestrator; +/// +/// Orchestrator class that coordinates the entire multi-agent workflow. +/// Manages the flow of requests through agent decision, worker agent activities, and result synthesis. +/// Implements retry policies and handles parallel agent execution. +/// public class AgentOrchestrator() { private static TaskOptions DefaultTaskOptions { get; } = new( @@ -17,6 +22,12 @@ public class AgentOrchestrator() 1, TimeSpan.FromSeconds(10)))); + /// + /// Orchestrates the complete multi-agent workflow execution. + /// Coordinates agent decision, parallel agent execution, and result synthesis with retry policies. + /// + /// Orchestration context for managing workflow state and activities + /// Aggregated response from all executed agents, with or without additional information [Function(nameof(AgentOrchestrator))] public async Task RunOrchestrator( [OrchestrationTrigger] TaskOrchestrationContext context) diff --git a/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationActivity.cs b/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationActivity.cs index d456769..bde0117 100644 --- a/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationActivity.cs +++ b/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationActivity.cs @@ -3,8 +3,18 @@ namespace DurableMultiAgentTemplate.Agent.SubmitReservationAgent; +/// +/// Activity class responsible for handling hotel reservation submissions. +/// Creates a reservation record and returns confirmation details. +/// public class SubmitReservationActivity(ChatClient chatClient)//, CosmosClient cosmosClient) { + /// + /// Processes a hotel reservation request and generates a confirmation. + /// Simulates reservation processing and returns booking details with a unique reservation number. + /// + /// Request containing reservation details including destination, dates, and guest count + /// Reservation confirmation with booking details and reservation number in Japanese [Function(AgentActivityName.SubmitReservationAgent)] public async Task RunAsync([ActivityTrigger] SubmitReservationRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationRequest.cs b/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationRequest.cs index fdca8be..99554e7 100644 --- a/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationRequest.cs +++ b/DurableMultiAgentTemplate/Agent/SubmitReservationAgent/SubmitReservationRequest.cs @@ -2,6 +2,10 @@ namespace DurableMultiAgentTemplate.Agent.SubmitReservationAgent; +/// +/// Record representing a request to submit a hotel reservation. +/// Used as input for the SubmitReservationActivity. +/// public record SubmitReservationRequest( [property: Description("行き先のホテルの名前。")] string Destination, diff --git a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerActivity.cs b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerActivity.cs index e975e7d..62890be 100644 --- a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerActivity.cs +++ b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerActivity.cs @@ -7,8 +7,18 @@ namespace DurableMultiAgentTemplate.Agent.Synthesizer; +/// +/// Activity class responsible for synthesizing results from multiple agent calls into a unified response. +/// Processes and formats agent outputs into coherent and user-friendly content. +/// public class SynthesizerActivity(ChatClient chatClient, ILogger logger) { + /// + /// Synthesizes results from multiple agent calls into a coherent response. + /// Uses OpenAI to combine and format agent outputs into user-friendly content. + /// + /// Request containing agent results, original request, and called agent names for synthesis + /// Unified agent response with synthesized content and list of called agents [Function(AgentActivityName.SynthesizerActivity)] public async Task Run([ActivityTrigger] SynthesizerRequest req) { diff --git a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerPrompt.cs b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerPrompt.cs index d2a491a..9bfaf44 100644 --- a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerPrompt.cs +++ b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerPrompt.cs @@ -1,5 +1,9 @@ namespace DurableMultiAgentTemplate.Agent.Synthesizer; +/// +/// Static class containing prompt templates for the Synthesizer. +/// Provides the system prompt used to guide the synthesizer's response generation process. +/// internal static class SynthesizerPrompt { // Orchestrator Agent functions diff --git a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerWithAdditionalInfoActivity.cs b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerWithAdditionalInfoActivity.cs index 4df8df2..2cc7b54 100644 --- a/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerWithAdditionalInfoActivity.cs +++ b/DurableMultiAgentTemplate/Agent/Synthesizer/SynthesizerWithAdditionalInfoActivity.cs @@ -10,8 +10,18 @@ namespace DurableMultiAgentTemplate.Agent.Synthesizer; +/// +/// Activity class responsible for synthesizing results from multiple agent calls into a unified response +/// with additional information. Handles formatting and processing responses with supplementary data. +/// public class SynthesizerWithAdditionalInfoActivity(ChatClient chatClient, ILogger logger) { + /// + /// Synthesizes results from multiple agent calls into a unified response with additional information. + /// Uses OpenAI structured output to combine agent results and generate supplementary data. + /// + /// Request containing agent results, original request, and called agent names for synthesis + /// Enhanced agent response with synthesized content, additional information, and list of called agents [Function(AgentActivityName.SynthesizerWithAdditionalInfoActivity)] public async Task Run([ActivityTrigger] SynthesizerRequest req) { diff --git a/DurableMultiAgentTemplate/Extension/AgentRequestMessageItemExtension.cs b/DurableMultiAgentTemplate/Extension/AgentRequestMessageItemExtension.cs index ac6d636..072b65a 100644 --- a/DurableMultiAgentTemplate/Extension/AgentRequestMessageItemExtension.cs +++ b/DurableMultiAgentTemplate/Extension/AgentRequestMessageItemExtension.cs @@ -3,8 +3,18 @@ namespace DurableMultiAgentTemplate.Extension; +/// +/// Extension methods for AgentRequestMessageItem. +/// Provides conversion functionality between the application's message format and OpenAI's chat message format. +/// public static class AgentRequestMessageItemExtension { + /// + /// Converts a collection of AgentRequestMessageItem objects to ChatMessage objects. + /// + /// The collection of message items to convert. + /// A collection of ChatMessage objects. + /// Thrown when an unsupported role is encountered. public static IEnumerable ConvertToChatMessageArray(this IEnumerable messages) { return messages.Select(m => diff --git a/DurableMultiAgentTemplate/Json/JsonSchemaGenerator.cs b/DurableMultiAgentTemplate/Json/JsonSchemaGenerator.cs index 3b9f8ec..4454a24 100644 --- a/DurableMultiAgentTemplate/Json/JsonSchemaGenerator.cs +++ b/DurableMultiAgentTemplate/Json/JsonSchemaGenerator.cs @@ -10,15 +10,15 @@ namespace DurableMultiAgentTemplate.Json; /// -/// JsonSchema を生成する。 -/// クラス定義に Description 属性を指定することで JsonSchema にも description を追加する。 +/// Generator for JSON schema creation. +/// Supports adding descriptions to JSON schemas by specifying Description attributes on class definitions. /// internal static class JsonSchemaGenerator { private static readonly JsonSchemaExporterOptions _jsonSchemaExporterOptions = new() { TreatNullObliviousAsNonNullable = true, - // Description を追加する + // Add description to schema TransformSchemaNode = (context, schema) => { var attributeProvider = context.PropertyInfo is not null ? @@ -44,8 +44,19 @@ internal static class JsonSchemaGenerator Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), }; + /// + /// Generates a JSON schema as a string from the specified type information. + /// + /// The JSON type information to generate the schema from + /// JSON schema as a string with Unicode encoding support public static string GenerateSchema(JsonTypeInfo type) => JsonSchemaExporter.GetJsonSchemaAsNode(type, _jsonSchemaExporterOptions).ToJsonString(_jsonSerializerOptions); + + /// + /// Generates a JSON schema as binary data from the specified type information. + /// + /// The JSON type information to generate the schema from + /// JSON schema as binary data public static BinaryData GenerateSchemaAsBinaryData(JsonTypeInfo type) => BinaryData.FromString(GenerateSchema(type)); } diff --git a/DurableMultiAgentTemplate/Model/AppConfig.cs b/DurableMultiAgentTemplate/Model/AppConfig.cs index 7b647f9..43689e0 100644 --- a/DurableMultiAgentTemplate/Model/AppConfig.cs +++ b/DurableMultiAgentTemplate/Model/AppConfig.cs @@ -1,21 +1,62 @@ namespace DurableMultiAgentTemplate.Model; +/// +/// Configuration class for the application. +/// Contains settings for OpenAI and Cosmos DB services. +/// public class AppConfig { + /// + /// Gets or initializes the OpenAI configuration. + /// public required OpenAIConfig OpenAI { get; init; } + + /// + /// Gets or initializes the Cosmos DB configuration. + /// public required CosmosDbConfig CosmosDb { get; init; } } +/// +/// Configuration class for OpenAI services. +/// Includes endpoint, API key, and model deployment names. +/// public class OpenAIConfig { + /// + /// Gets or initializes the endpoint URL for the OpenAI API. + /// public required string Endpoint { get; init; } + + /// + /// Gets or initializes the API key for authentication with OpenAI services. + /// public string? ApiKey { get; init; } + + /// + /// Gets or initializes the deployment name for the chat model. + /// public required string ChatModelDeployName { get; init; } + + /// + /// Gets or initializes the deployment name for the embedding model. + /// public required string EmbeddingModelDeployName { get; init; } } +/// +/// Configuration class for Cosmos DB. +/// Includes endpoint and API key settings. +/// public class CosmosDbConfig { + /// + /// Gets or initializes the endpoint URL for Cosmos DB. + /// public required string Endpoint { get; init; } + + /// + /// Gets or initializes the API key for authentication with Cosmos DB. + /// public string? ApiKey { get; init; } } diff --git a/DurableMultiAgentTemplate/Model/SourceGenerationContext.cs b/DurableMultiAgentTemplate/Model/SourceGenerationContext.cs index 7c5a2d0..684cfa2 100644 --- a/DurableMultiAgentTemplate/Model/SourceGenerationContext.cs +++ b/DurableMultiAgentTemplate/Model/SourceGenerationContext.cs @@ -9,6 +9,11 @@ namespace DurableMultiAgentTemplate.Model; +/// +/// Source generation context for JSON serialization. +/// Configures the JSON serialization options and declares serializable types +/// for performance optimization through source generation. +/// [JsonSourceGenerationOptions(PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, PropertyNameCaseInsensitive = true)] [JsonSerializable(typeof(GetClimateRequest))] [JsonSerializable(typeof(GetDestinationSuggestRequest))]