mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
wip
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
|
||||
using Microsoft.Azure.Functions.Worker;
|
||||
using Microsoft.Azure.Functions.Worker.Http;
|
||||
using Microsoft.DurableTask;
|
||||
using Microsoft.DurableTask.Client;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace SingleAgent;
|
||||
|
||||
public static class OrchFunction
|
||||
{
|
||||
[Function(nameof(OrchFunction))]
|
||||
public static async Task<List<string>> RunOrchestratorAsync(
|
||||
[OrchestrationTrigger] TaskOrchestrationContext context)
|
||||
{
|
||||
ILogger logger = context.CreateReplaySafeLogger(nameof(OrchFunction));
|
||||
logger.LogInformation("Saying hello.");
|
||||
var outputs = new List<string>();
|
||||
|
||||
outputs.Add("Tokyo");
|
||||
|
||||
return outputs;
|
||||
}
|
||||
|
||||
[Function("OrchFunction_HttpStart")]
|
||||
public static async Task<HttpResponseData> HttpStartAsync(
|
||||
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
|
||||
[DurableClient] DurableTaskClient client,
|
||||
FunctionContext executionContext)
|
||||
{
|
||||
// Function input comes from the request content.
|
||||
string instanceId = await client.ScheduleNewOrchestrationInstanceAsync(
|
||||
nameof(OrchFunction));
|
||||
|
||||
// Returns an HTTP 202 response with an instance management payload.
|
||||
// See https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-http-api#start-orchestration
|
||||
return await client.CreateCheckStatusResponseAsync(req, instanceId);
|
||||
}
|
||||
}
|
||||
@@ -41,16 +41,16 @@ builder.AddEdge(agent2, reverse).WithOutputFrom(agent2);
|
||||
|
||||
var workflow = builder.WithName("MyTestWorkflow").Build();
|
||||
|
||||
// Configure the function app to host the AI agent.
|
||||
// This will automatically generate HTTP API endpoints for the agent.
|
||||
// Configure the function app to host AI agents and workflows in a unified way.
|
||||
// This will automatically generate HTTP API endpoints for agents and workflows.
|
||||
using IHost app = FunctionsApplication
|
||||
.CreateBuilder(args)
|
||||
.ConfigureFunctionsWebApplication()
|
||||
.ConfigureDurableAgents(options => options.AddAIAgent(agent, timeToLive: TimeSpan.FromHours(1)))
|
||||
.AddDurableWorkflows(options =>
|
||||
//.ConfigureDurableAgents(op => op.AddAIAgent(agent, timeToLive: TimeSpan.FromHours(1)))
|
||||
.ConfigureDurableOptions(options =>
|
||||
{
|
||||
// Configure durable workflow options here if needed.
|
||||
options.AddWorkflow(workflow);
|
||||
// Configure workflows - agents referenced in workflows are automatically registered!
|
||||
options.Workflows.AddWorkflow(workflow);
|
||||
})
|
||||
.Build();
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user