Coder Social home page Coder Social logo

mokosan / dotnet-ai Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 1.0 36 KB

Leveraging LLMs to Create and Run dotnet Projects Faster and Easier.

C# 100.00%
dotnet llm openai-api semantic-kernel csharp gpt3-turbo openai-chatgpt semantickernel dotnet-sdk dotnet-sdk-6

dotnet-ai's Introduction

dotnet-ai: Leveraging LLMs to Create and Run dotnet Projects Faster and Easier.

Nuget

This tool leverages Large Language Models (LLMs) to convert a user query into a series of steps for the dotnet SDK that can be optionally executed. To be put simply: The tool takes a user query of an intended action, an optional argument to execute the steps and responds with a series of steps.

The main purpose is to streamline and simplify the process of using the dotnet SDK to create projects by simply specifying instructions and optionally invoking them.

Prerequisites

  1. Acquire an OpenAI API KEY. Here is a tutorial on how to do so.
  2. Install the .NET6 SDK from here.

Getting Started

  1. Install the dotnet-ai tool by invoking the following on your terminal: dotnet tool install dotnet-ai -g.
  2. Set the OpenAI API Key as an environment variable.
    1. If you are using Powershell, use: $env:OPENAI_API_KEY='Add Your OpenAI API Key Here'.
    2. If you are using Command Prompt, use: set OPENAI_API_KEY=Add Your OPEN API KEY Without Quotations.
  3. Invoke the tool:
    1. dotnet-ai --query "Add your query here": This will list the steps required.
    2. dotnet-ai --query "Add your query here" --execute: This will list the steps required and then execute them.
  4. Examples:
    1. Handling some basic SDK operations both in the form of questions and commands:
      1. dotnet-ai --query "Display the sdks installed" --execute.
      2. dotnet-ai --query "How do I add a nuget package?".
      3. dotnet-ai --query "How do I uninstall a dotnet tool".
    2. Generating projects from simple to more complex in C#, F# or Visual Basic:
      1. dotnet-ai --query "Create and run an application that'll print all the planets of the solar system.".
      2. dotnet-ai --query "Create and run an application that'll generate the first 20 Fibonacci numbers in F# in a project called 'Fib'" --execute.
      3. dotnet-ai --query "Create an implementation of Priority Queues in C#" --execute.
      4. dotnet-ai --query "Implement of Bubblesort in VB in a project called Bubblesort" --execute.

NOTE: Some projects are too complex for the current LLM to generate code for.

Getting Started With Development and Running Locally

  1. Clone the repo: git clone https://github.com/MokoSan/dotnet-ai.git.
  2. cd into the folder: cd dotnet-ai.
  3. Build the repo:
    1. cd dotnet-ai.
    2. dotnet build. Use dotnet build -c Release to build in Release mode.
  4. Run the code:
    1. Running using the dotnet SDK:
      1. dotnet run -- --query "Create an application that prints the planets of the solar system.".
    2. Running from the binary:
      1. cd bin.
      2. cd Debug or cd Release.
      3. cd net6.0.
      4. .\dotnet-ai.exe --query "Create an application that prints the planets of the solar system.".

Example Response

dotnet-ai --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:

  1. Create a new .NET project: dotnet new console -n PrimeNumberGenerator

  2. Change to the project directory: cd PrimeNumberGenerator

  3. Add the Newtonsoft.Json NuGet package: dotnet add package Newtonsoft.Json

  4. 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;
            }
        }
    }
  5. Save the changes to the Program.cs file.

  6. Build the project: dotnet build

  7. 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.

License

This project is licensed under the MIT License.

Contributions and Issues

Contributions are most welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

dotnet-ai's People

Contributors

mokosan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

smarteasy

dotnet-ai's Issues

Improving the Exception Handling

Gracefully handling an exception needs to be added. Currently we aren't catching all the different exceptions; for example in case the user doesn't add the OPENAI_API_KEY, we are simply throwing an ArgumentException - this can be handled better.

Use a more pure version of RAG with Chains on the dotnet documentation

Rather than stitching all the documentation in one query, identify the specific data source to be used and grab that data only to augment the original query. This requires:

  1. Figuring out all the commands needed.
  2. Taking those commands and getting the raw markdown to augment the prompt with.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.