mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
74879489a4
* Checkpoint * Update workflows/DeepResearch.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Comment * Fix comment * Update package version * Fix nuget haxx * Checkpoint * Code complete * Testing * Message content workaround * Add sequential flow * Checkpoint * Integration test project * Checkpoint * Checkpoint cleanup * Complete * Update package --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using Microsoft.Extensions.AI;
|
|
using Microsoft.PowerFx;
|
|
using Microsoft.PowerFx.Types;
|
|
|
|
namespace Microsoft.Agents.Workflows.Declarative.PowerFx.Functions;
|
|
|
|
internal sealed class UserMessage : ReflectionFunction
|
|
{
|
|
public const string FunctionName = nameof(UserMessage);
|
|
|
|
public UserMessage()
|
|
: base(FunctionName, FormulaType.String, FormulaType.String)
|
|
{ }
|
|
|
|
public static FormulaValue Execute(StringValue input) =>
|
|
string.IsNullOrEmpty(input.Value) ?
|
|
FormulaValue.NewBlank(RecordType.Empty()) :
|
|
FormulaValue.NewRecordFromFields(
|
|
new NamedValue(TypeSchema.Message.Fields.Role, FormulaValue.New(ChatRole.User.Value)),
|
|
new NamedValue(
|
|
TypeSchema.Message.Fields.Content,
|
|
FormulaValue.NewTable(
|
|
RecordType.Empty()
|
|
.Add(TypeSchema.Message.Fields.ContentType, FormulaType.String)
|
|
.Add(TypeSchema.Message.Fields.ContentValue, FormulaType.String),
|
|
[
|
|
FormulaValue.NewRecordFromFields(
|
|
new NamedValue(TypeSchema.Message.Fields.ContentType, FormulaValue.New(TypeSchema.Message.ContentTypes.Text)),
|
|
new NamedValue(TypeSchema.Message.Fields.ContentValue, input))
|
|
]
|
|
)
|
|
)
|
|
);
|
|
}
|