mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
WAF into memory (#4)
* waf-import WIP * waf import to qdrant * waf WIP * add qdrant-init container * call the seed project in the postCreateCommand script * add envvars * update startup script
This commit is contained in:
7
cli/util/Initial Repo Prompt.txt
Normal file
7
cli/util/Initial Repo Prompt.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Please write a bash script with the commands that would be required to generate two new .NET applications as follows:
|
||||
The first application will be a web service called "skdtwebapi" with a two methods: /prompt, which accepts a PUT request with a text body of no more than 2048k, and /skills which accepts a GET request and lists the semantic skills it has.
|
||||
The second application will be a command line client of the web service and is called "skdt" and will accept one argument, a file name. The command line application will PUT the contents of the text file to the /prompt method of the first application.
|
||||
You may add comments to the script and the generated output but do not add any other text except the bash script.
|
||||
You may include commands to build the applications but do not run them.
|
||||
Use .NET 7.
|
||||
Configuration parameters required for the webapi applicaton will include AzureOpenAIServiceEndpoint, AIServiceKey, AIModel.
|
||||
128
cli/util/InitialRepoPromptOutput.sh
Normal file
128
cli/util/InitialRepoPromptOutput.sh
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create skdtwebapi web service
|
||||
dotnet new webapi -n skdtwebapi
|
||||
cd skdtwebapi
|
||||
|
||||
# Add required NuGet packages
|
||||
dotnet add package Microsoft.AspNetCore.OData
|
||||
dotnet add package Microsoft.Azure.CognitiveServices.Language
|
||||
|
||||
# Add configuration parameters to appsettings.json
|
||||
echo '{
|
||||
"AzureOpenAIServiceEndpoint": "",
|
||||
"AIServiceKey": "",
|
||||
"AIModel": ""
|
||||
}' > appsettings.json
|
||||
|
||||
# Add /prompt and /skills methods to ValuesController.cs
|
||||
echo 'using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Azure.CognitiveServices.Language.TextAnalytics;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace skdtwebapi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ValuesController : ControllerBase
|
||||
{
|
||||
private readonly IConfiguration _config;
|
||||
|
||||
public ValuesController(IConfiguration config)
|
||||
{
|
||||
_config = config;
|
||||
}
|
||||
|
||||
[HttpGet("skills")]
|
||||
public async Task<ActionResult<IEnumerable<string>>> GetSkills()
|
||||
{
|
||||
var credentials = new ApiKeyServiceClientCredentials(_config["AIServiceKey"]);
|
||||
var client = new TextAnalyticsClient(credentials)
|
||||
{
|
||||
Endpoint = _config["AzureOpenAIServiceEndpoint"]
|
||||
};
|
||||
|
||||
var result = await client.EntitiesRecognitionGeneralAsync("en", "I am a software developer");
|
||||
|
||||
return result.Entities.Select(e => e.Name).ToList();
|
||||
}
|
||||
|
||||
[HttpPut("prompt")]
|
||||
public async Task<ActionResult> Prompt([FromBody] string prompt)
|
||||
{
|
||||
var credentials = new ApiKeyServiceClientCredentials(_config["AIServiceKey"]);
|
||||
var client = new TextAnalyticsClient(credentials)
|
||||
{
|
||||
Endpoint = _config["AzureOpenAIServiceEndpoint"]
|
||||
};
|
||||
|
||||
var result = await client.EntitiesRecognitionGeneralAsync("en", prompt);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}' > Controllers/ValuesController.cs
|
||||
|
||||
# Create skdt command line client
|
||||
cd ..
|
||||
dotnet new console -n skdt
|
||||
cd skdt
|
||||
|
||||
# Add required NuGet packages
|
||||
dotnet add package Microsoft.Extensions.Configuration
|
||||
dotnet add package Microsoft.Extensions.Configuration.Json
|
||||
dotnet add package Microsoft.Extensions.DependencyInjection
|
||||
dotnet add package Microsoft.Extensions.Http
|
||||
dotnet add package Microsoft.Net.Http.Headers
|
||||
|
||||
# Add configuration parameters to appsettings.json
|
||||
echo '{
|
||||
"WebApiUrl": "https://localhost:5001",
|
||||
"AIServiceKey": "",
|
||||
"AIModel": ""
|
||||
}' > appsettings.json
|
||||
|
||||
# Add code to Program.cs to PUT contents of text file to /prompt method
|
||||
echo 'using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Http;
|
||||
|
||||
namespace skdt
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var serviceProvider = new ServiceCollection()
|
||||
.AddHttpClient()
|
||||
.BuildServiceProvider();
|
||||
|
||||
var clientFactory = serviceProvider.GetService<IHttpClientFactory>();
|
||||
var client = clientFactory.CreateClient();
|
||||
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
|
||||
var fileContents = await File.ReadAllTextAsync(args[0]);
|
||||
|
||||
var response = await client.PutAsync($"{configuration["WebApiUrl"]}/prompt", new StringContent(fileContents));
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
Console.WriteLine("Prompt sent successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Error sending prompt: {response.StatusCode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}' > Program.cs
|
||||
@@ -2,4 +2,5 @@ I'd like to build a typical Todo List Application: a simple productivity tool th
|
||||
Key features of the Todo List application include the ability to add, edit, and delete tasks, set due dates and reminders, categorize tasks by project or priority, and mark tasks as complete.
|
||||
The Todo List applications also offer collaboration features, such as sharing tasks with others or assigning tasks to team members.
|
||||
Additionally, the Todo List application will offer offer mobile and web-based interfaces, allowing users to access their tasks from anywhere.
|
||||
Use C# as the language.
|
||||
Use C# as the language.
|
||||
The app needs to be deployed to Azure, be highly performant, cost effective and secure, following the rules of Well Architected Framework.
|
||||
Reference in New Issue
Block a user