Revert "Integrate RecalcEngine to compute Env variables"

This reverts commit caf61440f6.
This commit is contained in:
markwallace-microsoft
2025-11-11 15:55:44 +00:00
Unverified
parent caf61440f6
commit 947e811d7f
25 changed files with 54 additions and 212 deletions
@@ -6,8 +6,6 @@ using System.Text.Json.Serialization;
using Microsoft.Bot.ObjectModel;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
using Microsoft.PowerFx;
using Microsoft.PowerFx.Types;
namespace Microsoft.Agents.AI.Declarative.UnitTests;
@@ -220,6 +218,7 @@ public sealed class AgentBotElementYamlTests
.AddInMemoryCollection(new Dictionary<string, string?>
{
["OpenAIEndpoint"] = "endpoint",
["OpenAIModelId"] = "modelId",
["OpenAIApiKey"] = "apiKey"
})
.Build();
@@ -234,10 +233,9 @@ public sealed class AgentBotElementYamlTests
Assert.NotNull(model);
Assert.NotNull(model.Connection);
Assert.IsType<ApiKeyConnection>(model.Connection);
ApiKeyConnection connection = (model.Connection as ApiKeyConnection)!;
Assert.NotNull(connection);
Assert.Equal("endpoint", this.Eval(connection.Endpoint!, configuration));
Assert.Equal("apiKey", this.Eval(connection.Key!, configuration));
//Assert.Equal("https://my-azure-openai-endpoint.openai.azure.com/", agent.Model.Connection.Endpoint?.LiteralValue);
//Assert.Equal("apiKey", connection.Key?.LiteralValue);
//Assert.Equal("modelId", model.Id);
}
/// <summary>
@@ -255,28 +253,4 @@ public sealed class AgentBotElementYamlTests
[JsonPropertyName("occupation")]
public string? Occupation { get; set; }
}
private string? Eval(StringExpression expression, IConfiguration configuration)
{
RecalcEngine engine = new();
foreach (var kvp in configuration.AsEnumerable())
{
engine.UpdateVariable(kvp.Key, kvp.Value ?? string.Empty);
}
if (expression.IsLiteral)
{
return expression.LiteralValue?.ToString();
}
else if (expression.IsExpression)
{
return engine.Eval(expression.ExpressionText!).ToString();
}
else if (expression.IsVariableReference)
{
var stringValue = engine.Eval(expression.VariableReference!.VariableName) as StringValue;
return stringValue?.Value;
}
return null;
}
}
@@ -146,7 +146,7 @@ internal static class PromptAgents
description: Agent description
instructions: You are a helpful assistant.
model:
id: gpt-4o
id: =Env.OpenAIModelId
connection:
kind: apiKey
endpoint: =Env.OpenAIEndpoint