mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context In order to keep documentation examples up to date, moving them to a repo where they will actually be built and run. ### Description Move documentation examples from doc repo to this one. ### Contribution Checklist - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
31 lines
1019 B
C#
31 lines
1019 B
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Net;
|
|
using Microsoft.Azure.Functions.Worker;
|
|
using Microsoft.Azure.Functions.Worker.Http;
|
|
using Models;
|
|
|
|
public class AIPluginJson
|
|
{
|
|
[Function("GetAIPluginJson")]
|
|
public HttpResponseData Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = ".well-known/ai-plugin.json")] HttpRequestData req)
|
|
{
|
|
var currentDomain = $"{req.Url.Scheme}://{req.Url.Host}:{req.Url.Port}";
|
|
|
|
HttpResponseData response = req.CreateResponse(HttpStatusCode.OK);
|
|
response.Headers.Add("Content-Type", "application/json");
|
|
|
|
var appSettings = AppSettings.LoadSettings();
|
|
|
|
// serialize app settings to json using System.Text.Json
|
|
var json = System.Text.Json.JsonSerializer.Serialize(appSettings.AIPlugin);
|
|
|
|
// replace {url} with the current domain
|
|
json = json.Replace("{url}", currentDomain, StringComparison.OrdinalIgnoreCase);
|
|
|
|
response.WriteString(json);
|
|
|
|
return response;
|
|
}
|
|
}
|