dotnet-ai
0.0.1
See the version list below for details.
dotnet tool install --global dotnet-ai --version 0.0.1
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local dotnet-ai --version 0.0.1
#tool dotnet:?package=dotnet-ai&version=0.0.1
nuke :add-package dotnet-ai --version 0.0.1
dotnet-ai
This repo is responsible for listing steps to achieve the query requested by the user.
Prerequisites
- Ensure you add the OpenAI API KEY to your environment such as the following if you are running in powershell:
$env:OPENAI_API_KEY = ''
or the following if you are running in cmd:
set OPENAI_API_KEY = ''
Usage
After building the project, you can invoke it by passing in the desired query with the --query argument:
.\dotnet-ai.exe --query "Create an application that prints the planets of the solar system"
You can execute the query, as well by passing in the --execute flag:
.\dotnet-ai.exe --query "Create an application that prints the planets of the solar system" --execute
Example Response
.\dotnet-ai.exe --query "create a program that'll generate the first 30 prime numbers and also add the newtonsoft json nuget package"
Response:
To create a program that generates the first 30 prime numbers and add the Newtonsoft.Json NuGet package, you can follow these steps:
Create a new .NET project:
dotnet new console -n PrimeNumberGenerator
Change to the project directory:
cd PrimeNumberGenerator
Add the Newtonsoft.Json NuGet package:
dotnet add package Newtonsoft.Json
Open the Program.cs file in a text editor and replace the existing code with the following code:
using System; using Newtonsoft.Json; namespace PrimeNumberGenerator { class Program { static void Main(string[] args) { int count = 0; int number = 2; while (count < 30) { if (IsPrime(number)) { Console.WriteLine(number); count++; } number++; } } static bool IsPrime(int number) { if (number < 2) return false; for (int i = 2; i <= Math.Sqrt(number); i++) { if (number % i == 0) return false; } return true; } } }
Save the changes to the Program.cs file.
Build the project:
dotnet build
Run the program:
dotnet run
This will generate and display the first 30 prime numbers. The Newtonsoft.Json NuGet package has been added to the project to enable JSON serialization and deserialization capabilities.
Next Steps
- Create a dotnet tool with this project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
This package has no dependencies.