✨ Shield now has support for Avalonia UI

Create an Application That Creates Other Applications with ChatGPT

Mar 19, 2023 | .NET, C#, ChatGPT

Are you tired of spending many hours coding new applications from scratch? What if I told you that you can create new apps on your own?

It may sound too good to be true, but with the power of ChatGPT, you can do exactly that.

In this article, we’ll delve into the world of AI-based app development and show you how to create an app that creates other apps with ChatGPT.

Ready? Let’s go!

The App that creates other Apps

At the end I will leave the link to the GitHub repository so you can also use this application.

We have created an application that creates applications based on what we want using the ChatGPT API.

using OpenAI_API;
using Test;

OpenAIAPI api = new OpenAIAPI("YOUR_API_KEY"); // shorthand

var source = "";

await api.Completions.StreamCompletionAsync(
    new CompletionRequest("REQUEST_APPLICATION", Model.DavinciText, 200, 0.5, presencePenalty: 0.1, frequencyPenalty: 0.1),
    res => source += res.ToString());

//Console.WriteLine(source);

var compiler = new Compiler();
var runner = new Runner();

byte[] compiled = compiler.Compile(source);
string[] none = Array.Empty<string>();
runner.Execute(compiled, none);


Console.ReadLine();

And for example we can try:

Create a C# code that asks me for a number and check if it is even or odd. If it is even, it will have to return “it is even”. If it is odd, it will have to return by console “it is odd”.

using OpenAI_API;
using Test;

OpenAIAPI api = new OpenAIAPI("YOUR_API_KEY"); // shorthand

var source = "";

await api.Completions.StreamCompletionAsync(
    new CompletionRequest("Create a C# code that asks me for a number with red text and check if it is odd or even. If it is even, it will have to return \"it is even\" in yellow. If it is odd, it will have to return by console \"is odd\" in blue. After answering me, you must ask me for another number in red and tell me if it is even or odd. Infinitely.", Model.DavinciText, 200, 0.5, presencePenalty: 0.1, frequencyPenalty: 0.1),
    res => source += res.ToString());

//Console.WriteLine(source);

var compiler = new Compiler();
var runner = new Runner();

byte[] compiled = compiler.Compile(source);
string[] none = Array.Empty<string>();
runner.Execute(compiled, none);


Console.ReadLine();

If we run and try it:

85caa62e041819cb8af60d97b8802e29

It works well! Let’s try something different:

Create a C# application that asks me for 3 numbers one by one. Then return the average of those three numbers.

using OpenAI_API;
using Test;

OpenAIAPI api = new OpenAIAPI("YOUR_API_KEY"); // shorthand

var source = "";

await api.Completions.StreamCompletionAsync(
    new CompletionRequest("Create a C# application that asks me for 3 numbers one by one. Then return the average of those three numbers.", Model.DavinciText, 2000, 0.5, presencePenalty: 0.1, frequencyPenalty: 0.1),
    res => source += res.ToString());

//Console.WriteLine(source);

var compiler = new Compiler();
var runner = new Runner();

byte[] compiled = compiler.Compile(source);
string[] none = Array.Empty<string>();
runner.Execute(compiled, none);


Console.ReadLine();

Let’s see the result:

a2a0032cf1773e82fc5a9bd7b86bc568

Let’s try something more difficult.

Create a C# application that asks me for a path to indicate a csv file. The csv has 2 columns, the first one: “username” and the second one “logins”. In the first column are the names of the users. In the second column is the number of logins they have done. After inputting the path to the csv file, the application should output a table with the name and the number of logins of the 5 users who have made the most logins.

For this example we have prepared a simple example table with 100 names and random numbers which we have then exported in csv:

image 37

And done!

image 36

These are just a few simple ideas, but they can be as complicated as you want them to be. As I said at the beginning, here you have access to the repository on GitHub. If you manage to create something interesting, leave it in the comments section!

You May Also Like