Files
agent-framework/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/PowerFx/RecalcEngineFactory.cs
T
Ben Thomas 647db9635a .NET: Rename workflows projects (#975)
* Renaming Microsoft.Agent.Workflows to Microsoft.Agents.AI.Workflows

* Removing local settings.

* Removing remining old files from merge.
2025-09-29 18:30:45 +00:00

47 lines
1.3 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
using Microsoft.Agents.AI.Workflows.Declarative.PowerFx.Functions;
using Microsoft.Bot.ObjectModel;
using Microsoft.PowerFx;
using Microsoft.PowerFx.Types;
namespace Microsoft.Agents.AI.Workflows.Declarative.PowerFx;
internal static class RecalcEngineFactory
{
public static RecalcEngine Create(
int? maximumExpressionLength = null,
int? maximumCallDepth = null)
{
RecalcEngine engine = new(CreateConfig());
foreach (string scopeName in VariableScopeNames.AllScopes)
{
engine.UpdateVariable(WorkflowFormulaState.GetScopeName(scopeName), RecordValue.Empty());
}
engine.UpdateVariable(VariableScopeNames.Topic, RecordValue.Empty());
return engine;
PowerFxConfig CreateConfig()
{
PowerFxConfig config = new(Features.PowerFxV1);
if (maximumExpressionLength is not null)
{
config.MaximumExpressionLength = maximumExpressionLength.Value;
}
if (maximumCallDepth is not null)
{
config.MaxCallDepth = maximumCallDepth.Value;
}
config.EnableSetFunction();
config.AddFunction(new UserMessage());
return config;
}
}
}