mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
79 lines
2.9 KiB
C#
79 lines
2.9 KiB
C#
// ------------------------------------------------------------------------------
|
|
// <auto-generated>
|
|
// This code was generated by a tool.
|
|
// Runtime Version: 18.0.0.0
|
|
//
|
|
// Changes to this file may cause incorrect behavior and will be lost if
|
|
// the code is regenerated.
|
|
// </auto-generated>
|
|
// ------------------------------------------------------------------------------
|
|
namespace Microsoft.Agents.AI.Workflows.Declarative.CodeGen
|
|
{
|
|
using Microsoft.Agents.ObjectModel;
|
|
using System;
|
|
|
|
/// <summary>
|
|
/// Class to produce the template output
|
|
/// </summary>
|
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "18.0.0.0")]
|
|
internal partial class CreateConversationTemplate : ActionTemplate
|
|
{
|
|
/// <summary>
|
|
/// Create the template output
|
|
/// </summary>
|
|
public override string TransformText()
|
|
{
|
|
this.Write("\n");
|
|
this.Write("\n");
|
|
this.Write("\n");
|
|
this.Write("\n");
|
|
this.Write("\n/// <summary>\n/// Creates a new conversation and stores the identifier value to " +
|
|
"the \"");
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(this.Model.ConversationId));
|
|
this.Write("\" variable.\n/// </summary>\ninternal sealed class ");
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(this.Name));
|
|
this.Write("Executor(FormulaSession session, ResponseAgentProvider agentProvider) : ActionExe" +
|
|
"cutor(id: \"");
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(this.Id));
|
|
this.Write(@""", session)
|
|
{
|
|
protected override async ValueTask<object?> ExecuteAsync(IWorkflowContext context, CancellationToken cancellationToken)
|
|
{
|
|
string conversationId = await agentProvider.CreateConversationAsync(cancellationToken).ConfigureAwait(false);");
|
|
|
|
AssignVariable(this.ConversationId, "conversationId");
|
|
this.Write("\n await context.AddEventAsync(new ConversationUpdateEvent(conversationId))" +
|
|
".ConfigureAwait(false);\n\n return default;\n }\n}\n");
|
|
return this.GenerationEnvironment.ToString();
|
|
}
|
|
|
|
void AssignVariable(PropertyPath targetVariable, string valueVariable, bool tightFormat = false)
|
|
{
|
|
if (targetVariable is not null)
|
|
{
|
|
this.Write("\n await context.QueueStateUpdateAsync(key: \"");
|
|
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(VariableName(targetVariable)));
|
|
|
|
this.Write("\", value: ");
|
|
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(valueVariable));
|
|
|
|
this.Write(", scopeName: \"");
|
|
|
|
this.Write(this.ToStringHelper.ToStringWithCulture(VariableScope(targetVariable)));
|
|
|
|
this.Write("\").ConfigureAwait(false);");
|
|
|
|
|
|
if (!tightFormat)
|
|
{
|
|
this.Write("\n ");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|