Skip to content

Simple .NET console application demonstrating OpenAI NuGet package with OpenAI and local LLMs using Ollama.

License

Notifications You must be signed in to change notification settings

tsjdev-apps/openai-localllm-chat-copilot

Repository files navigation

Using the official OpenAI library for .NET to access local running LLMs ans SLMs using Ollama or llamafiles

Header

In this repository, we will use the official OpenAI library for .NET to create a simple console application. This application will implement a Shakespearean chat using either OpenAI’s models, locally running LLMs or SLMs with Ollama or locally running LLMs or SLMs as llamafile.

Usage

You need to create an OpenAI account on this website. You have to pay to use the API so make sure that you add your payment information. After that, you can create an API Key here for further use.

If you want to run local LLMs or SLMs simply install Ollama and download a desired model.

If you want to run local LLMs or SLM get a llamafile from the official GitHub Repository. On Windows you need to replace the file extension .llamafile with .exe to be able to execute the file.

Just run the app and follow the steps displayed on the screen.

Screenshots

Here you can see the console application in action:

The first screenshot shows the host selection.

Console

Depending on your selection, you will be asked for the required parameters. In this case we need to enter the OpenAI key.

Console

Next we need to select the OpenAI model.

Console

Finally you can start chatting with William Shakespeare.

Console

If you select Ollama (Local LLM) as host, you need to specify the downloaded Ollama model.

Console

In my case I’ve downloaded the famous Phi-3 model provided by Microsoft.

Console

Finally you can start chatting with William Shakespeare.

Console

If you select Llamafile (Local LLM) as host, you can start directly chatting with Shakespeare.

Console

Blog Post / YouTube Video

If you are more interested into details, please see the following posts on medium.com or in my personal blog:

About

Simple .NET console application demonstrating OpenAI NuGet package with OpenAI and local LLMs using Ollama.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages