mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* S1006 * S2219 * S3236 * S3260 * S1125 * IDE0063 * IDE0062 * IDE0028
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System;
|
|
using System.Text.Json;
|
|
using Microsoft.Extensions.AI;
|
|
using Microsoft.Shared.Diagnostics;
|
|
|
|
namespace Microsoft.Agents.AI.Workflows;
|
|
|
|
internal sealed class WorkflowThread : AgentThread
|
|
{
|
|
public WorkflowThread(string workflowId, string? workflowName, string runId)
|
|
{
|
|
this.MessageStore = new();
|
|
this.RunId = Throw.IfNullOrEmpty(runId);
|
|
}
|
|
|
|
public WorkflowThread(JsonElement serializedThread, JsonSerializerOptions? jsonSerializerOptions = null)
|
|
{
|
|
throw new NotImplementedException("Pending Checkpointing work.");
|
|
}
|
|
|
|
public string RunId { get; }
|
|
public int Halts { get; }
|
|
|
|
public string ResponseId => $"{this.RunId}@{this.Halts}";
|
|
|
|
public override JsonElement Serialize(JsonSerializerOptions? jsonSerializerOptions = null)
|
|
=> throw new NotImplementedException("Pending Checkpointing work.");
|
|
|
|
public AgentRunResponseUpdate CreateUpdate(params AIContent[] parts)
|
|
{
|
|
Throw.IfNullOrEmpty(parts);
|
|
|
|
AgentRunResponseUpdate update = new(ChatRole.Assistant, parts)
|
|
{
|
|
CreatedAt = DateTimeOffset.UtcNow,
|
|
MessageId = Guid.NewGuid().ToString("N"),
|
|
};
|
|
|
|
this.MessageStore.AddMessages(update.ToChatMessage());
|
|
|
|
return update;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public WorkflowMessageStore MessageStore { get; }
|
|
}
|