فهرست منبع

提示词工程demo

devin.zhu@doverfs.com 3 ماه پیش
کامیت
d8e7ab6924
28فایلهای تغییر یافته به همراه1283 افزوده شده و 0 حذف شده
  1. 6 0
      .gitignore
  2. 5 0
      DFS.AI.API/DFS.AI.API.AppHost/AppHost.cs
  3. 21 0
      DFS.AI.API/DFS.AI.API.AppHost/DFS.AI.API.AppHost.csproj
  4. 29 0
      DFS.AI.API/DFS.AI.API.AppHost/Properties/launchSettings.json
  5. 8 0
      DFS.AI.API/DFS.AI.API.AppHost/appsettings.Development.json
  6. 9 0
      DFS.AI.API/DFS.AI.API.AppHost/appsettings.json
  7. 22 0
      DFS.AI.API/DFS.AI.API.ServiceDefaults/DFS.AI.API.ServiceDefaults.csproj
  8. 127 0
      DFS.AI.API/DFS.AI.API.ServiceDefaults/Extensions.cs
  9. 5 0
      DFS.AI.API/DFS.AI.API.slnx
  10. 199 0
      DFS.AI.API/DFS.AI.API/Controllers/ModelMessageController.cs
  11. 22 0
      DFS.AI.API/DFS.AI.API/DFS.AI.API.csproj
  12. 6 0
      DFS.AI.API/DFS.AI.API/DFS.AI.API.csproj.user
  13. 6 0
      DFS.AI.API/DFS.AI.API/DFS.AI.API.http
  14. 13 0
      DFS.AI.API/DFS.AI.API/Helper/A2AHelper.cs
  15. 115 0
      DFS.AI.API/DFS.AI.API/Helper/AIClientHelper.cs
  16. 69 0
      DFS.AI.API/DFS.AI.API/Helper/ChatHandle.cs
  17. 42 0
      DFS.AI.API/DFS.AI.API/Helper/ChatModelResponse.cs
  18. 20 0
      DFS.AI.API/DFS.AI.API/Helper/Keys.cs
  19. 100 0
      DFS.AI.API/DFS.AI.API/Helper/MafHelper.cs
  20. 145 0
      DFS.AI.API/DFS.AI.API/Helper/McpHelper.cs
  21. 146 0
      DFS.AI.API/DFS.AI.API/Helper/McpServerTools.cs
  22. 65 0
      DFS.AI.API/DFS.AI.API/Helper/NLogHelper.cs
  23. 24 0
      DFS.AI.API/DFS.AI.API/Helper/PolyglotHelper.cs
  24. 27 0
      DFS.AI.API/DFS.AI.API/Program.cs
  25. 23 0
      DFS.AI.API/DFS.AI.API/Properties/launchSettings.json
  26. 12 0
      DFS.AI.API/DFS.AI.API/WeatherForecast.cs
  27. 8 0
      DFS.AI.API/DFS.AI.API/appsettings.Development.json
  28. 9 0
      DFS.AI.API/DFS.AI.API/appsettings.json

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+bin
+obj
+v17
+.vs
+!*.sh
+*.vsidx

+ 5 - 0
DFS.AI.API/DFS.AI.API.AppHost/AppHost.cs

@@ -0,0 +1,5 @@
+var builder = DistributedApplication.CreateBuilder(args);
+
+builder.AddProject<Projects.DFS_AI_API>("dfs-ai-api");
+
+builder.Build().Run();

+ 21 - 0
DFS.AI.API/DFS.AI.API.AppHost/DFS.AI.API.AppHost.csproj

@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" />
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net10.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+    <UserSecretsId>f6bd846f-6cab-4573-a933-f6cdfa615458</UserSecretsId>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\DFS.AI.API\DFS.AI.API.csproj" />
+  </ItemGroup>
+
+</Project>

+ 29 - 0
DFS.AI.API/DFS.AI.API.AppHost/Properties/launchSettings.json

@@ -0,0 +1,29 @@
+{
+  "$schema": "https://json.schemastore.org/launchsettings.json",
+  "profiles": {
+    "https": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "applicationUrl": "https://localhost:17267;http://localhost:15063",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development",
+        "DOTNET_ENVIRONMENT": "Development",
+        "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21276",
+        "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22117"
+      }
+    },
+    "http": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": true,
+      "applicationUrl": "http://localhost:15063",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development",
+        "DOTNET_ENVIRONMENT": "Development",
+        "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19215",
+        "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20225"
+      }
+    }
+  }
+}

+ 8 - 0
DFS.AI.API/DFS.AI.API.AppHost/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 9 - 0
DFS.AI.API/DFS.AI.API.AppHost/appsettings.json

@@ -0,0 +1,9 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning",
+      "Aspire.Hosting.Dcp": "Warning"
+    }
+  }
+}

+ 22 - 0
DFS.AI.API/DFS.AI.API.ServiceDefaults/DFS.AI.API.ServiceDefaults.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>net10.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+    <IsAspireSharedProject>true</IsAspireSharedProject>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <FrameworkReference Include="Microsoft.AspNetCore.App" />
+
+    <PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="9.9.0" />
+    <PackageReference Include="Microsoft.Extensions.ServiceDiscovery" Version="9.5.0" />
+    <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
+    <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
+    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
+    <PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
+    <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
+  </ItemGroup>
+
+</Project>

+ 127 - 0
DFS.AI.API/DFS.AI.API.ServiceDefaults/Extensions.cs

@@ -0,0 +1,127 @@
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Diagnostics.HealthChecks;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Diagnostics.HealthChecks;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.ServiceDiscovery;
+using OpenTelemetry;
+using OpenTelemetry.Metrics;
+using OpenTelemetry.Trace;
+
+namespace Microsoft.Extensions.Hosting;
+
+// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
+// This project should be referenced by each service project in your solution.
+// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults
+public static class Extensions
+{
+    private const string HealthEndpointPath = "/health";
+    private const string AlivenessEndpointPath = "/alive";
+
+    public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
+    {
+        builder.ConfigureOpenTelemetry();
+
+        builder.AddDefaultHealthChecks();
+
+        builder.Services.AddServiceDiscovery();
+
+        builder.Services.ConfigureHttpClientDefaults(http =>
+        {
+            // Turn on resilience by default
+            http.AddStandardResilienceHandler();
+
+            // Turn on service discovery by default
+            http.AddServiceDiscovery();
+        });
+
+        // Uncomment the following to restrict the allowed schemes for service discovery.
+        // builder.Services.Configure<ServiceDiscoveryOptions>(options =>
+        // {
+        //     options.AllowedSchemes = ["https"];
+        // });
+
+        return builder;
+    }
+
+    public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
+    {
+        builder.Logging.AddOpenTelemetry(logging =>
+        {
+            logging.IncludeFormattedMessage = true;
+            logging.IncludeScopes = true;
+        });
+
+        builder.Services.AddOpenTelemetry()
+            .WithMetrics(metrics =>
+            {
+                metrics.AddAspNetCoreInstrumentation()
+                    .AddHttpClientInstrumentation()
+                    .AddRuntimeInstrumentation();
+            })
+            .WithTracing(tracing =>
+            {
+                tracing.AddSource(builder.Environment.ApplicationName)
+                    .AddAspNetCoreInstrumentation(tracing =>
+                        // Exclude health check requests from tracing
+                        tracing.Filter = context =>
+                            !context.Request.Path.StartsWithSegments(HealthEndpointPath)
+                            && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath)
+                    )
+                    // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package)
+                    //.AddGrpcClientInstrumentation()
+                    .AddHttpClientInstrumentation();
+            });
+
+        builder.AddOpenTelemetryExporters();
+
+        return builder;
+    }
+
+    private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
+    {
+        var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);
+
+        if (useOtlpExporter)
+        {
+            builder.Services.AddOpenTelemetry().UseOtlpExporter();
+        }
+
+        // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package)
+        //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"]))
+        //{
+        //    builder.Services.AddOpenTelemetry()
+        //       .UseAzureMonitor();
+        //}
+
+        return builder;
+    }
+
+    public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
+    {
+        builder.Services.AddHealthChecks()
+            // Add a default liveness check to ensure app is responsive
+            .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
+
+        return builder;
+    }
+
+    public static WebApplication MapDefaultEndpoints(this WebApplication app)
+    {
+        // Adding health checks endpoints to applications in non-development environments has security implications.
+        // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments.
+        if (app.Environment.IsDevelopment())
+        {
+            // All health checks must pass for app to be considered ready to accept traffic after starting
+            app.MapHealthChecks(HealthEndpointPath);
+
+            // Only health checks tagged with the "live" tag must pass for app to be considered alive
+            app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
+            {
+                Predicate = r => r.Tags.Contains("live")
+            });
+        }
+
+        return app;
+    }
+}

+ 5 - 0
DFS.AI.API/DFS.AI.API.slnx

@@ -0,0 +1,5 @@
+<Solution>
+  <Project Path="DFS.AI.API.AppHost/DFS.AI.API.AppHost.csproj" />
+  <Project Path="DFS.AI.API.ServiceDefaults/DFS.AI.API.ServiceDefaults.csproj" />
+  <Project Path="DFS.AI.API/DFS.AI.API.csproj" />
+</Solution>

+ 199 - 0
DFS.AI.API/DFS.AI.API/Controllers/ModelMessageController.cs

@@ -0,0 +1,199 @@
+using DFS.AI.API.Helper;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.AI;
+
+namespace DFS.AI.API.Controllers;
+
+[ApiController]
+[Route("[controller]")]
+public class ModelMessageController : ControllerBase
+{
+    private static readonly string[] Summaries =
+    [
+        "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
+    ];
+
+    //[HttpGet(Name = "GetWeatherForecast")]
+    //public IEnumerable<WeatherForecast> Get()
+    //{
+    //    return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+    //    {
+    //        Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
+    //        TemperatureC = Random.Shared.Next(-20, 55),
+    //        Summary = Summaries[Random.Shared.Next(Summaries.Length)]
+    //    })
+    //    .ToArray();
+    //}
+
+    [HttpGet(Name = "GetModel")]
+    public Task<ChatModelResponse> GetModel(string promt)
+    {
+        var promtStr = $$"""
+        你是一名铁路票务意图识别专家,负责在前端界面与后端服务之间准确判断用户意图。
+        仅从以下选项中选择:订票意图、退票意图、咨询意图。
+
+        <context>
+        系统当前时间:2025年12月29日 18:00
+        用户Id:Devin
+        用户等级:VIP会员
+        </context>
+
+
+        请严格以如下 JSON 格式返回结果:
+        {
+            "intention": "<订票意图/退票意图/咨询意图>",
+            "reason": "<简要说明识别理由>"
+        }
+        <example>
+        用户请求:我的票能退吗?
+        意图:
+        {
+            "intention": "退票意图",
+            "reason": "用户询问是否可以退票"
+        }
+        </example>
+
+        <example>
+        用户请求:请问高铁可以带宠物吗?
+        意图:
+        {
+            "intention": "咨询意图",
+            "reason": "用户咨询乘车规则,非订退票"
+        }
+        </example>
+        用户请求:{{promt}}
+        若无法明确判断,则选择 "咨询意图",理由写 "输入不够明确,默认为咨询"
+        """;
+        return new ChatHandle().ChatOllamaModel(promtStr, new ChatOptions()
+        {
+            Temperature = 0.1f,      // 低随机性,保证稳定输出
+            TopP = 0.9f,             // 核采样
+            MaxOutputTokens = 120    // 限制输出长度
+        });
+    }
+
+
+    [HttpGet("{fuel}")]
+    public Task<ChatModelResponse> Fuel(string promt)
+    {
+        var promtStr = $$"""
+        你需要识别用户的加油意图,并根据用户请求分类为以下选项之一:
+        * 加油意图
+        * 发票意图
+        * 咨询意图
+        * 售后意图
+
+        当遇到92,95,98,0号,柴油需识别对应的油品,
+
+        请严格以如下 JSON 格式返回分析结果:
+        {
+            "intention": "<加油意图/发票意图/咨询意图/售后意图>",
+            "reason": "<简要说明识别理由>",
+            "Remark":"<油品/金额>"
+        }
+
+        注意事项:  
+        1. 仅从用户请求中提取明确的意图,不提供额外信息或推测。  
+        2. 识别理由需简洁明了,直接引用或总结用户请求的关键词和语义。  
+
+        以下为示例:  
+
+        <example>  
+        用户请求:帮我加92,200元?  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问定量加油",
+            "Remark":"92/200"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:帮我加200  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问加200元",
+            "Remark":"0/200"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:帮我加1百92  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问加100元",
+            "Remark":"92/100"  
+        }  
+        </example>  
+
+
+        <example>  
+        用户请求:帮我加20092?  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问加200元的92号汽油",
+            "Remark":"92/200"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:帮我加10095?  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问加100元的95号汽油",
+            "Remark":"95/100"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:帮我加92汽油  
+        意图:  
+        {  
+            "intention": "加油意图",  
+            "reason": "用户询问加92汽油",
+            "Remark":"92/0"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:帮我开发票  
+        意图:  
+        {  
+            "intention": "开票意图",  
+            "reason": "用户询问是否可以开票",
+            "Remark":"0/0"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:最近油站有什么优惠活动  
+        意图:  
+        {  
+            "intention": "咨询意图",  
+            "reason": "用户询问油站友好活动",
+            "Remark":"0/0"  
+        }  
+        </example>  
+
+        <example>  
+        用户请求:加油报错误编码 51 532   
+        意图:  
+        {  
+            "intention": "售后意图",  
+            "reason": "用户询问加油机错误代码的含义与维修方案",
+            "Remark":"0/0"  
+        }  
+        </example> 
+        """;
+        return new ChatHandle().ChatOllamaModel(promtStr, new ChatOptions()
+        {
+            Temperature = 0.1f,      // 低随机性,保证稳定输出
+            TopP = 0.9f,             // 核采样
+            MaxOutputTokens = 120    // 限制输出长度
+        });
+    }
+}

+ 22 - 0
DFS.AI.API/DFS.AI.API/DFS.AI.API.csproj

@@ -0,0 +1,22 @@
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>net10.0</TargetFramework>
+    <Nullable>enable</Nullable>
+    <ImplicitUsings>enable</ImplicitUsings>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Azure.AI.OpenAI" Version="2.8.0-beta.1" />
+    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.1" />
+    <PackageReference Include="Microsoft.Extensions.AI" Version="10.1.1" />
+    <PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.1.1-preview.1.25612.2" />
+    <PackageReference Include="NLog.Extensions.Logging" Version="6.1.0" />
+    <PackageReference Include="OllamaSharp" Version="5.4.12" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\DFS.AI.API.ServiceDefaults\DFS.AI.API.ServiceDefaults.csproj" />
+  </ItemGroup>
+
+</Project>

+ 6 - 0
DFS.AI.API/DFS.AI.API/DFS.AI.API.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ActiveDebugProfile>https</ActiveDebugProfile>
+  </PropertyGroup>
+</Project>

+ 6 - 0
DFS.AI.API/DFS.AI.API/DFS.AI.API.http

@@ -0,0 +1,6 @@
+@DFS.AI.API_HostAddress = http://localhost:5198
+
+GET {{DFS.AI.API_HostAddress}}/ModelMessage/GetModel
+Accept: application/json
+
+###

+ 13 - 0
DFS.AI.API/DFS.AI.API/Helper/A2AHelper.cs

@@ -0,0 +1,13 @@
+//#r "nuget: A2A, *-*"
+//#r "nuget:A2A.AspNetCore, *-*"
+
+
+
+//using A2A.AspNetCore;
+//using A2A;
+
+
+
+public static class A2AHelper
+{
+}

+ 115 - 0
DFS.AI.API/DFS.AI.API/Helper/AIClientHelper.cs

@@ -0,0 +1,115 @@
+using Azure.AI.OpenAI;
+using Microsoft.Extensions.AI;
+using OllamaSharp;
+using OpenAI;
+using System.ClientModel;
+
+public static class AIClientHelper
+{
+    /// <summary>
+    /// 获取默认的聊天客户端,默认使用 AzureOpenAI 和 gpt-4o 模型
+    /// AzureOpenAI: gpt-4o
+    /// DeepSeek: deepseek-chat, deepseek-reasoner
+    /// Qwen: qwen-max, qwen-plus, qwen-flash
+    /// TokenAI: gpt-5-pro, claude-sonnet-4-5-20250929
+    /// ollama
+    /// </summary>
+    public static IChatClient GetDefaultChatClient(string provider = "AzureOpenAI", string model = "gpt-4o", bool enableLogging = false)
+    {
+        IChatClient chatClient;
+        switch (provider) {
+            case "AzureOpenAI":
+                chatClient= GetAzureOpenAIClient(enableLogging).GetChatClient(model).AsIChatClient();
+                break;
+            case "DeepSeek":
+                chatClient = GetDeepSeekClient(enableLogging).GetChatClient(model).AsIChatClient();
+                break;
+            case "Qwen":
+                chatClient = GetQwenClient(enableLogging).GetChatClient(model).AsIChatClient();
+                break;
+            case "TokenAI":
+                chatClient = GetTokenAIClient(enableLogging).GetChatClient(model).AsIChatClient();
+                break;
+            case "Ollama":
+                chatClient = GetOllamaApiClient(model);
+                break;
+           default:
+                chatClient = GetTokenAIClient(enableLogging).GetChatClient(model).AsIChatClient();
+                break;
+
+        };
+        //var chatClient = provider switch
+        //{
+        //    "AzureOpenAI" => GetAzureOpenAIClient(enableLogging).GetChatClient(model),
+        //    "DeepSeek" => GetDeepSeekClient(enableLogging).GetChatClient(model),
+        //    "Qwen" => GetQwenClient(enableLogging).GetChatClient(model),
+        //    "TokenAI" => GetTokenAIClient(enableLogging).GetChatClient(model),
+        //    "Ollama" => GetOllamaApiClient(model),
+        //    _ => GetAzureOpenAIClient(enableLogging).GetChatClient(model),
+        //};
+
+        return chatClient;
+    }
+
+    public static AzureOpenAIClient GetAzureOpenAIClient(bool enableLogging = false)
+    {
+        var endpoint = Keys.AzureOpenAIEndpoint;
+        var apiKey = Keys.AzureOpenAIApiKey;
+
+        var clientOptions = new AzureOpenAIClientOptions();
+
+        if (enableLogging)
+        {
+            var clientLoggingOptions = NLogHelper.CreateClientLoggingOptions();
+
+            clientOptions.ClientLoggingOptions = clientLoggingOptions;
+        }
+
+        var client = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(apiKey), clientOptions);
+
+        return client;
+    }
+
+    public static IEmbeddingGenerator<string, Embedding<float>> GetAzureOpenAIEmbeddingGenerator()
+    {
+        var client = GetAzureOpenAIClient();
+        return client.GetEmbeddingClient("text-embedding-3-small").AsIEmbeddingGenerator();
+    }
+
+
+    public static OpenAIClient GetDeepSeekClient(bool enableLogging = false)
+        => GetAIClient(Keys.DeepSeekEndpoint, Keys.DeepSeekApiKey, enableLogging);
+
+
+    //public static OpenAIClient GetOllamaClient(bool enableLogging = false)
+    //    => GetAIClient(Keys.DeepSeekEndpoint, Keys.DeepSeekApiKey, enableLogging);
+
+
+    public static OpenAIClient GetQwenClient(bool enableLogging = false) =>
+        GetAIClient(Keys.QwenEndpoint, Keys.QwenApiKey, enableLogging);
+
+    public static OpenAIClient GetTokenAIClient(bool enableLogging = false) =>
+        GetAIClient(Keys.TokenAIEndpoint, Keys.TokenAIApiKey, enableLogging);
+
+    private static OpenAIClient GetAIClient(string endpoint, string apiKey, bool enableLogging = false)
+    {
+        OpenAIClientOptions clientOptions = new OpenAIClientOptions();
+        clientOptions.Endpoint = new Uri(endpoint);
+
+        if (enableLogging)
+        {
+            var clientLoggingOptions = NLogHelper.CreateClientLoggingOptions();
+
+            clientOptions.ClientLoggingOptions = clientLoggingOptions;
+        }
+
+        // 创建自定义的OpenAI客户端
+        OpenAIClient aiClient = new(new ApiKeyCredential(apiKey), clientOptions);
+        return aiClient;
+    }
+
+    public static IChatClient GetOllamaApiClient( string model) {
+        return new OllamaApiClient(Keys.OllamaUri, model);
+    }
+    
+}

+ 69 - 0
DFS.AI.API/DFS.AI.API/Helper/ChatHandle.cs

@@ -0,0 +1,69 @@
+using Microsoft.Extensions.AI;
+using OpenAI.Chat;
+
+namespace DFS.AI.API.Helper
+{
+    public class ChatHandle
+    {
+        public ChatHandle()
+        {
+            
+        }
+        // 创建快捷调用方法
+        public async Task<ChatModelResponse> Chat(string userPrompt,ChatOptions chatOptions,string provider,string model)
+        {
+            // 配置生成参数
+            //var chatOptions = new ChatOptions
+            //{
+            //    Temperature = 0.1f,      // 低随机性,保证稳定输出
+            //    TopP = 0.9f,             // 核采样
+            //    MaxOutputTokens = 120    // 限制输出长度
+            //};
+            var chatClient = AIClientHelper.GetDefaultChatClient(provider,model);
+            try
+            {
+                Console.WriteLine("⏱️ 开始请求...\n");
+
+                var response = await chatClient.GetResponseAsync(userPrompt, chatOptions);
+
+                Console.WriteLine("✅ 请求成功");
+               return response.ToModel();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("❌ 请求失败:");
+               
+            }
+            return null;
+        }
+
+
+        // 创建快捷调用方法
+        public async Task<ChatModelResponse> ChatOllamaModel(string userPrompt, ChatOptions chatOptions, string provider= "Ollama", string model="qwen2.5")
+        {
+            // 配置生成参数
+            //var chatOptions = new ChatOptions
+            //{
+            //    Temperature = 0.1f,      // 低随机性,保证稳定输出
+            //    TopP = 0.9f,             // 核采样
+            //    MaxOutputTokens = 120    // 限制输出长度
+            //};
+            var chatClient = AIClientHelper.GetDefaultChatClient(provider, model);
+            try
+            {
+                Console.WriteLine("⏱️ 开始请求...\n");
+
+                var response = await chatClient.GetResponseAsync(userPrompt, chatOptions);
+
+                Console.WriteLine("✅ 请求成功");
+                return response.ToModel();
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine("❌ 请求失败:");
+
+            }
+            return null;
+        }
+    }
+}

+ 42 - 0
DFS.AI.API/DFS.AI.API/Helper/ChatModelResponse.cs

@@ -0,0 +1,42 @@
+using Microsoft.Extensions.AI;
+
+namespace DFS.AI.API.Helper
+{
+    /// <summary>
+    /// 模型返回
+    /// </summary>
+    public class ChatModelResponse
+    {
+        /// <summary>
+        /// 模型名称
+        /// </summary>
+        public string Model { get; set; }
+
+        /// <summary>
+        /// 模型的token 
+        /// </summary>
+        public long Token { get; set; }
+
+        /// <summary>
+        /// 模型返回
+        /// </summary>
+        public string Text { get; set; }
+
+        
+    }
+
+
+    /// <summary>
+    /// 转化模型的结果集
+    /// </summary>
+    public static class ChartReponseExtension {
+        public static ChatModelResponse ToModel(this ChatResponse response)
+        {
+            return new ChatModelResponse() { 
+                Text = response.Text,
+                Model= response.ModelId,
+                Token= response.Usage?.TotalTokenCount ?? 0,
+            };
+        }
+    }
+}

+ 20 - 0
DFS.AI.API/DFS.AI.API/Helper/Keys.cs

@@ -0,0 +1,20 @@
+public static class Keys
+{
+    public const string AzureOpenAIEndpoint = "https://my-openapi.openai.azure.com/"; // 请自行替换为你的Endpoint
+    public const string AzureOpenAIApiKey = "D6uw9hVI6vXTjGo35RTlEpTWbhfXd8xRs38tG2gIgWtvhNpxjJt4JQQJ99BDACYeBjFXJ3w3AAABACOGvPWE"; // 请自行替换为你的API Key
+
+    public const string DeepSeekEndpoint = "https://api.deepseek.com/v1"; // 请自行替换为你的Endpoint
+    public const string DeepSeekApiKey = "sk-xx"; // 请自行替换为你的API Key
+
+    // 阿里百炼平台
+    public const string QwenEndpoint = "https://dashscope.aliyuncs.com/compatible-mode/v1"; // 请自行替换为你的Endpoint
+    public const string QwenApiKey = "sk-xxx"; // 请自行替换为你的API Key
+
+    // 通过该链接:https://api.token-ai.cn/register/fatiaobot 注册TokenAI账号,获取5美元免费额度
+    // public const string TokenAIEndpoint = "https://api.token-ai.com/v1"; 
+    public const string TokenAIEndpoint = "http://175.178.155.193/v1";
+    public const string TokenAIApiKey = "sk-xxx";
+
+    public const string OllamaUri = "http://127.0.0.1:11434";
+
+}

+ 100 - 0
DFS.AI.API/DFS.AI.API/Helper/MafHelper.cs

@@ -0,0 +1,100 @@
+////#r "nuget: Azure.AI.OpenAI"
+////#r "nuget:  Microsoft.Agents.AI.OpenAI, *-*"
+////#r "nuget: Microsoft.Agents.AI.Workflows, *-*"
+
+//using Microsoft.Agents.AI;
+//using Azure.AI.OpenAI;
+//using System.ClientModel;
+//using OpenAI;
+//using System.ComponentModel;
+//using Microsoft.Extensions.AI;
+//using System.Text.Json;
+
+//public static class MafHelper
+//{
+//    public static AzureOpenAIClient GetAzureOpenAIClient()
+//    {
+//        var endpoint = new Uri("https://my-openapi.openai.azure.com");
+//        var apiKey = "D6uw9hVI6vXTjGo35RTlEpTWbhfXd8xRs38tG2gIgWtvhNpxjJt4JQQJ99BDACYeBjFXJ3w3AAABACOGvPWE";
+
+//        var clientOptions = new AzureOpenAIClientOptions()
+//        {
+//            // Version = AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_preview
+//        };
+//        var azureClient = new AzureOpenAIClient(
+//            endpoint: endpoint,
+//            credential: new ApiKeyCredential(apiKey),
+//            options: clientOptions
+//        );
+
+//        return azureClient;
+//    }
+
+//    [Description("The current datetime offset.")]
+//    public static string GetDateTime() => DateTimeOffset.Now.ToString();
+
+//    /// <summary>
+//    /// 创建一个默认的 Agent,包含当前时间工具
+//    /// </summary>
+//    /// <param name="modelName"></param>
+//    /// <returns></returns>
+//    public static AIAgent GetDefaultAgent(string modelName = "gpt-4o")
+//    {
+//        var azureClient = GetAzureOpenAIClient();
+//        var chatClient = azureClient.GetChatClient(modelName);
+
+//        var agent = chatClient.CreateAIAgent(
+//            name: "DefaultAgent",
+//            instructions: "你是一名得力的助手。",
+//            tools: [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))]
+//        );
+
+//        return agent;
+//    }
+
+
+
+//    public static AIAgent GetAgentInJsonSchemaResponse(JsonElement jsonSchema, string modelName = "gpt-4o")
+//    {
+//        var azureClient = GetAzureOpenAIClient();
+//        var chatClient = azureClient.GetChatClient(modelName);
+
+//        ChatOptions chatOptions = new()
+//        {
+//            // Tools = [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))],
+//            ResponseFormat = ChatResponseFormatJson.ForJsonSchema(schema: jsonSchema)                        
+//        };
+
+//        var agent = chatClient.CreateAIAgent(
+//            options: new ChatClientAgentOptions()
+//            {
+//                Name = "HelperAgent",
+//                Instructions = "你是一个乐于助人的助手。",
+//                ChatOptions = chatOptions
+//            });
+
+//        return agent;
+//    }
+
+
+//    public static AIAgent GetAgentInJsonResponse(string modelName = "gpt-4o")
+//    {
+//        var azureClient = GetAzureOpenAIClient();
+//        var chatClient = azureClient.GetChatClient(modelName);
+//        ChatOptions chatOptions = new()
+//        {
+//            ResponseFormat = ChatResponseFormat.Json,
+//            Tools = [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))]
+//        };
+
+//        var agent = chatClient.CreateAIAgent(
+//            options: new ChatClientAgentOptions()
+//            {
+//                Name = "HelperAgent",
+//                Instructions = "你是一个乐于助人的助手,所有的回答都必须是JSON格式。",
+//                ChatOptions = chatOptions
+//            });
+
+//        return agent;
+//    }
+//}

+ 145 - 0
DFS.AI.API/DFS.AI.API/Helper/McpHelper.cs

@@ -0,0 +1,145 @@
+////#r "nuget: ModelContextProtocol, *-*"
+////#r "nuget: Microsoft.Extensions.DependencyInjection"
+////#r "nuget: Microsoft.Extensions.Hosting"
+
+//using Microsoft.Extensions.DependencyInjection;
+//using Microsoft.Extensions.Hosting;
+//using Microsoft.Extensions.Logging;
+//using ModelContextProtocol;
+//using ModelContextProtocol.Client;
+//using ModelContextProtocol.Server;
+//using ModelContextProtocol.Protocol;
+//using System;
+//using System.Collections.Generic;
+//using System.Threading.Tasks;
+
+//using System.IO.Pipelines;
+//using System.Reflection;
+//using System.Threading.Channels;
+
+///// <summary>
+///// Model Context Protocol (MCP) 相关的帮助方法
+///// 统一管理 MCP 相关的 NuGet 包版本和常用功能
+///// </summary>
+//public static class McpHelper
+//{
+//    /// <summary>
+//    /// 使用反射从指定类型中提取所有 MCP 工具
+//    /// </summary>
+//    public static List<McpServerTool> GetToolsForType<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembers(
+//        System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.PublicMethods)] T>()
+//    {
+//        var tools = new List<McpServerTool>();
+//        var toolType = typeof(T);
+
+//        // 获取所有标记了 McpServerToolAttribute 的公共静态方法
+//        var methods = toolType.GetMethods(BindingFlags.Public | BindingFlags.Static)
+//            .Where(m => m.GetCustomAttributes(typeof(McpServerToolAttribute), false).Any());
+
+//        foreach (var method in methods)
+//        {
+//            try
+//            {
+//                var tool = McpServerTool.Create(method, target: null, new McpServerToolCreateOptions());
+//                tools.Add(tool);
+//            }
+//            catch (Exception ex)
+//            {
+//                throw new InvalidOperationException($"添加工具失败 {toolType.Name}.{method.Name}: {ex.Message}", ex);
+//            }
+//        }
+
+//        return tools;
+//    }
+
+//    /// <summary>
+//    /// 创建并初始化 InMemory Transport 的 Server 和 Client
+//    /// </summary>
+//    /// <param name="tools">要注册的工具集合</param>
+//    /// <param name="serverOptions">Server 配置选项(可选)</param>
+//    /// <param name="loggerFactory">日志工厂(可选)</param>
+//    /// <returns>返回已连接的 Client 和运行中的 Server</returns>
+//    public static async Task<(McpClient Client, McpServer Server)> CreateInMemoryClientAndServerAsync(
+//        List<McpServerTool> tools,
+//        McpServerOptions? serverOptions = null,
+//        McpClientOptions? clientOptions = null,
+//        ILoggerFactory? loggerFactory = null)
+//    {
+//        // 步骤 1:创建两个 Pipe(双向管道)
+//        Pipe clientToServerPipe = new();
+//        Pipe serverToClientPipe = new();
+
+//        // 步骤 2:创建 Server,使用 StreamServerTransport
+//        var serverTransport = new StreamServerTransport(
+//            clientToServerPipe.Reader.AsStream(),
+//            serverToClientPipe.Writer.AsStream());
+
+//        var toolCollection = new McpServerPrimitiveCollection<McpServerTool>();
+        
+//        tools.ForEach(toolCollection.Add);
+
+//        var options = serverOptions ?? new McpServerOptions();
+//        options.ToolCollection = toolCollection;
+
+//        var server = McpServer.Create(serverTransport, options);
+
+//        // 步骤 3:启动 Server(后台运行)
+//        _ = server.RunAsync();
+
+//        // 步骤 4:创建 Client,使用 StreamClientTransport
+//        var client = await McpClient.CreateAsync(
+//            new StreamClientTransport(
+//                clientToServerPipe.Writer.AsStream(),
+//                serverToClientPipe.Reader.AsStream()),
+//            clientOptions: clientOptions,
+//            loggerFactory: loggerFactory);
+
+//        return (client, server);
+//    }
+
+//}
+
+
+//public static class InMemoryMcpClientServerBuilder
+//{
+//    private static readonly Pipe ClientToServerPipe = new();
+//    private static readonly Pipe ServerToClientPipe = new();
+
+//    public static IMcpServerBuilder CreateMcpServerBuilder(Action<McpServerOptions>? options = null)
+//    {
+//        ServiceCollection sc = new();
+//        sc.AddLogging();
+//        var builder = sc.AddMcpServer(options)
+//            .WithStreamServerTransport(ClientToServerPipe.Reader.AsStream(), ServerToClientPipe.Writer.AsStream());
+
+//        return builder;
+//    }
+
+//    public static Task StartMcpServer(IMcpServerBuilder mcpServerBuilder)
+//    {
+//        var serviceProvider = mcpServerBuilder.Services.BuildServiceProvider();
+        
+//        var server = serviceProvider.GetRequiredService<McpServer>();
+
+//        return server.RunAsync();
+//    }
+    
+    
+//    public static async Task<McpClient> CreateMcpClientForServer(McpClientOptions? clientOptions = null)
+//    {
+//        var loggerFactory = LoggerFactory.Create(loggingBuilder =>
+//        {
+//            loggingBuilder.AddConsole();
+//        });
+        
+//        return await McpClient.CreateAsync(
+//            new StreamClientTransport(
+//                serverInput: ClientToServerPipe.Writer.AsStream(),
+//                ServerToClientPipe.Reader.AsStream(),
+//                loggerFactory),
+//            clientOptions: clientOptions,
+//            loggerFactory: loggerFactory);
+//    }
+//}
+
+

+ 146 - 0
DFS.AI.API/DFS.AI.API/Helper/McpServerTools.cs

@@ -0,0 +1,146 @@
+//using ModelContextProtocol;
+//using ModelContextProtocol.Protocol;
+//using System.ComponentModel;
+
+///// <summary>
+///// 用户信息工具 - 提供会话用户信息
+///// </summary>
+//[McpServerToolType]
+//public sealed class UserInfoTool
+//{
+//    [McpServerTool, Description("获取当前 MCP 会话的用户信息")]
+//    public static string GetUserInfo()
+//    {
+//        return $"用户信息:\n" +
+//               $"- 用户 ID: {Guid.NewGuid().ToString("N")[..8]} (模拟)\n" +
+//               $"- 用户名: User{new Random().Next(1, 1000)}\n" +
+//               $"- 角色: User, Guest\n" +
+//               $"- 最后登录: {DateTime.Now.AddMinutes(-new Random().Next(1, 60)):HH:mm:ss}\n" +
+//               $"- 账户状态: 激活";
+//    }
+//}
+
+///// <summary>
+///// 时钟相关工具 - 提供时间和日期操作
+///// </summary>
+//[McpServerToolType]
+//public sealed class ClockTool
+//{
+//    [McpServerTool, Description("获取当前服务器时间")]
+//    public static string GetTime()
+//    {
+//        return $"当前服务器时间: {DateTime.Now:yyyy-MM-dd HH:mm:ss}";
+//    }
+
+//    [McpServerTool, Description("获取指定格式的当前日期")]
+//    public static string GetDate(
+//        [Description("日期格式 (如 'yyyy-MM-dd', 'MM/dd/yyyy')")] 
+//        string format = "yyyy-MM-dd")
+//    {
+//        try
+//        {
+//            return $"当前日期: {DateTime.Now.ToString(format)}";
+//        }
+//        catch (FormatException)
+//        {
+//            return $"无效的格式 '{format}',使用默认格式: {DateTime.Now:yyyy-MM-dd}";
+//        }
+//    }
+
+//    [McpServerTool, Description("转换时区")]
+//    public static string ConvertTimeZone(
+//        [Description("源时区 (如 'UTC', 'EST')")] string fromTimeZone = "UTC",
+//        [Description("目标时区 (如 'PST', 'GMT')")] string toTimeZone = "PST")
+//    {
+//        var now = DateTime.Now;
+//        return $"时区转换 {fromTimeZone} → {toTimeZone}: {now:HH:mm:ss} (演示)";
+//    }
+//}
+
+
+///// <summary>
+///// 计算器工具 - 提供数学计算功能
+///// </summary>
+//[McpServerToolType]
+//public sealed class CalculatorTool
+//{
+//    [McpServerTool, Description("执行基本算术运算(加、减、乘、除)")]
+//    public static string Calculate(
+//        [Description("数学表达式 (如 '5 + 3', '10 - 2', '4 * 6', '15 / 3')")] 
+//        string expression)
+//    {
+//        try
+//        {
+//            expression = expression.Trim();
+            
+//            if (expression.Contains("+"))
+//            {
+//                var parts = expression.Split('+');
+//                if (parts.Length == 2 && 
+//                    double.TryParse(parts[0].Trim(), out var a) && 
+//                    double.TryParse(parts[1].Trim(), out var b))
+//                {
+//                    return $"{expression} = {a + b}";
+//                }
+//            }
+//            else if (expression.Contains("-"))
+//            {
+//                var parts = expression.Split('-');
+//                if (parts.Length == 2 && 
+//                    double.TryParse(parts[0].Trim(), out var a) && 
+//                    double.TryParse(parts[1].Trim(), out var b))
+//                {
+//                    return $"{expression} = {a - b}";
+//                }
+//            }
+//            else if (expression.Contains("*"))
+//            {
+//                var parts = expression.Split('*');
+//                if (parts.Length == 2 && 
+//                    double.TryParse(parts[0].Trim(), out var a) && 
+//                    double.TryParse(parts[1].Trim(), out var b))
+//                {
+//                    return $"{expression} = {a * b}";
+//                }
+//            }
+//            else if (expression.Contains("/"))
+//            {
+//                var parts = expression.Split('/');
+//                if (parts.Length == 2 && 
+//                    double.TryParse(parts[0].Trim(), out var a) && 
+//                    double.TryParse(parts[1].Trim(), out var b))
+//                {
+//                    if (b == 0)
+//                        return "错误: 除数不能为零";
+//                    return $"{expression} = {a / b}";
+//                }
+//            }
+            
+//            return $"无法计算表达式: {expression}。支持的运算: +, -, *, /";
+//        }
+//        catch (Exception ex)
+//        {
+//            return $"计算 '{expression}' 时出错: {ex.Message}";
+//        }
+//    }
+
+//    [McpServerTool, Description("计算百分比")]
+//    public static string CalculatePercentage(
+//        [Description("基数")] double number,
+//        [Description("百分比值")] double percentage)
+//    {
+//        var result = (number * percentage) / 100;
+//        return $"{number} 的 {percentage}% = {result}";
+//    }
+
+//    [McpServerTool, Description("计算平方根")]
+//    public static string SquareRoot(
+//        [Description("要计算平方根的数字")] double number)
+//    {
+//        if (number < 0)
+//            return "错误: 无法计算负数的平方根";
+        
+//        var result = Math.Sqrt(number);
+//        return $"√{number} = {result}";
+//    }
+//}

+ 65 - 0
DFS.AI.API/DFS.AI.API/Helper/NLogHelper.cs

@@ -0,0 +1,65 @@
+//#r "nuget:NLog.Extensions.Logging"
+
+using NLog.Extensions.Logging;
+using NLog.Targets;
+using System.ClientModel;
+using System.ClientModel.Primitives;
+using Microsoft.Extensions.Logging;
+
+public static class NLogHelper
+{
+    public static ILoggerFactory CreateNLogLoggerFactory()
+    {
+        // 定义文件日志输出目标
+        var fileTarget = new FileTarget()
+        {
+            FileName = "maf.log",
+            AutoFlush = true,
+            DeleteOldFileOnStartup = true
+        };
+        // 定义控制台日志输出目标
+        var consoleTarget = new ConsoleTarget();
+
+        var config = new NLog.Config.LoggingConfiguration();
+        // 定义日志输出规则(输出所有Trace级别及以上的日志到控制台)
+        config.AddRule(
+            NLog.LogLevel.Trace,
+            NLog.LogLevel.Fatal,
+            target: fileTarget,  // 这里采用文件输出
+            "*");// * 表示所有Logger
+
+        var loggerFactory = LoggerFactory.Create(builder =>
+        {
+            builder.ClearProviders();
+            builder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
+            builder.AddNLog(config);
+        });
+
+        return loggerFactory;
+    }
+
+    /// <summary>
+    /// 初始化 ClientLoggingOptions,以打印ChatClient请求日志到控制台
+    /// </summary>
+    /// <returns></returns>
+    public static ClientLoggingOptions CreateClientLoggingOptions()
+    {
+        var loggingOptions = new ClientLoggingOptions();
+
+        loggingOptions.LoggerFactory = CreateNLogLoggerFactory();
+
+        loggingOptions.EnableLogging = true;                    // 总开关:启用日志
+        loggingOptions.EnableMessageLogging = true;             // 记录请求/响应的行与头
+        loggingOptions.EnableMessageContentLogging = true;      // 记录请求/响应的完整内容
+        loggingOptions.MessageContentSizeLimit = 64 * 1024;     // 增大到 64KB
+
+        // 可选:白名单(避免默认打码影响诊断)
+        loggingOptions.AllowedHeaderNames.Add("Content-Type");
+        loggingOptions.AllowedHeaderNames.Add("Accept");
+        loggingOptions.AllowedHeaderNames.Add("Content-Length");
+        loggingOptions.AllowedQueryParameters.Add("api-version");
+
+
+        return loggingOptions;
+    }
+}

+ 24 - 0
DFS.AI.API/DFS.AI.API/Helper/PolyglotHelper.cs

@@ -0,0 +1,24 @@
+//using PolyglotKernel = Microsoft.DotNet.Interactive.Kernel;
+//using Microsoft.DotNet.Interactive.Commands;
+
+//public static class PolyglotHelper
+//{
+
+//    public static Task AddMarkdownCellAsync(string markdown)
+//        => AddCodeCellAsync("markdown", markdown);
+
+//    public static Task AddMermaidCellAsync(string mermaidCode)
+//        => AddCodeCellAsync("mermaid", mermaidCode);
+//    public static async Task AddCodeCellAsync(string codeLanguage, string code)
+//    {
+//        var command = new SendEditableCode(codeLanguage, code);
+//        await PolyglotKernel.Root.SendAsync(command);
+//    }
+
+//    public static async Task<T> ReadConsoleInputAsync<T>(string prompt)
+//    {
+//        var input = await PolyglotKernel.GetInputAsync(prompt);
+//        return (T)Convert.ChangeType(input, typeof(T));
+//    }
+
+//}

+ 27 - 0
DFS.AI.API/DFS.AI.API/Program.cs

@@ -0,0 +1,27 @@
+var builder = WebApplication.CreateBuilder(args);
+
+builder.AddServiceDefaults();
+
+// Add services to the container.
+
+builder.Services.AddControllers();
+// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
+builder.Services.AddOpenApi();
+
+var app = builder.Build();
+
+app.MapDefaultEndpoints();
+
+// Configure the HTTP request pipeline.
+if (app.Environment.IsDevelopment())
+{
+    app.MapOpenApi();
+}
+
+app.UseHttpsRedirection();
+
+app.UseAuthorization();
+
+app.MapControllers();
+
+app.Run();

+ 23 - 0
DFS.AI.API/DFS.AI.API/Properties/launchSettings.json

@@ -0,0 +1,23 @@
+{
+  "$schema": "https://json.schemastore.org/launchsettings.json",
+  "profiles": {
+    "http": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": false,
+      "applicationUrl": "http://localhost:5198",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "https": {
+      "commandName": "Project",
+      "dotnetRunMessages": true,
+      "launchBrowser": false,
+      "applicationUrl": "https://localhost:7041;http://localhost:5198",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 12 - 0
DFS.AI.API/DFS.AI.API/WeatherForecast.cs

@@ -0,0 +1,12 @@
+namespace DFS.AI.API;
+
+public class WeatherForecast
+{
+    public DateOnly Date { get; set; }
+
+    public int TemperatureC { get; set; }
+
+    public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
+
+    public string? Summary { get; set; }
+}

+ 8 - 0
DFS.AI.API/DFS.AI.API/appsettings.Development.json

@@ -0,0 +1,8 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  }
+}

+ 9 - 0
DFS.AI.API/DFS.AI.API/appsettings.json

@@ -0,0 +1,9 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft.AspNetCore": "Warning"
+    }
+  },
+  "AllowedHosts": "*"
+}