Skip to content

Instantly share code, notes, and snippets.

View wullemsb's full-sized avatar

Wullems Bart wullemsb

View GitHub Profile
{
"autoentities": {
"public-api": {
"patterns": {
"include": [ "dbo.%" ],
"exclude": [ "dbo.internal%", "dbo.__migration%" ],
"name": "{schema}_{object}"
},
"template": {
"rest": { "enabled": true },
<!--Update the SDK version below 👇-->
<Project Sdk="Aspire.AppHost.Sdk/13.2.2">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
app.MapPost("/api/workflow/run", async (WorkflowRequest request, [FromKeyedServices("ContentReviewWorkflow")] Workflow workflow) =>
{
Run run = await InProcessExecution.RunAsync(workflow, request.Input);
WorkflowEvent result = null;
foreach (WorkflowEvent evt in run.OutgoingEvents)
{
if (evt is WorkflowOutputEvent response)
{
result = evt;
}
var reviewerAgentName = "Reviewer";
var reviewerInstructions = "You are a content editor. Give 2-3 bullet points of actionable feedback on the draft you receive. Be specific and concise.";
var writerAgentName = "Writer";
var writerInstructions = "You are a content writer. Write a clear, engaging paragraph on the topic provided. Be concise — 3-5 sentences.";
var reviewerAgentBuilder = builder.AddAIAgent(reviewerAgentName, reviewerInstructions);
var writerAgentBuilder = builder.AddAIAgent(writerAgentName, writerInstructions);
// The workflow name shows up in the DevUI sidebar
// ── 1. Configure the chat client (Ollama endpoint) ──────────
// Configuration - Ollama endpoint and model selection
var endpoint = "http://localhost:11434"; // Default Ollama endpoint
var modelName = "llama3.2"; // Model to use for AI responses
using OllamaApiClient chatClient = new(new Uri(endpoint), modelName);
builder.Services.AddChatClient(chatClient);
// ── 2. Create agents for the workflow ───────────────────────────
var reviewerAgentName = "Reviewer";
var reviewerInstructions = "You are a content editor. Give 2-3 bullet points of actionable feedback on the draft you receive. Be specific and concise.";
using Microsoft.Agents.AI.Workflows;
namespace AgentFramework.DevUI.Example
{
internal sealed partial class FormatterExecutor(): Executor("FormatterExecutor")
{
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
{
return protocolBuilder;
}
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
namespace AgentFramework.DevUI.Example
{
internal sealed partial class ReviewerExecutor(AIAgent agent): Executor("ReviewerExecutor")
{
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
{
return protocolBuilder;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
namespace AgentFramework.DevUI.Example
{
internal sealed partial class WriterExecutor(AIAgent agent) : Executor("WriterExecutor")
{
protected override ProtocolBuilder ConfigureProtocol(ProtocolBuilder protocolBuilder)
{
return protocolBuilder;
// Define tool functions
static string GetWeather(string city) => $"Weather in {city}: 18°C, partly cloudy."; // Replace with real API call
static string GetForecast(string city, int days) => $"{days}-day forecast for {city}: mostly sunny with occasional showers.";
// Create tool descriptors
var weatherTools = new[]
{
AIFunctionFactory.Create(GetWeather, "get_weather", "Get the current weather for a city"),
AIFunctionFactory.Create(GetForecast, "get_forecast", "Get a multi-day weather forecast"),
};
using Microsoft.Agents.AI.DevUI;
using Microsoft.Agents.AI.Hosting;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.AI;
using OllamaSharp;
using OpenTelemetry.Resources;
using System.Net;
var builder = WebApplication.CreateBuilder(args);