Customers who sign-up prior to 30/06/2024 get unlimited access to free features, newer features (with some restrictions), but for free for at least 1 year.Sign up now! https://webveta.alightservices.com/
Categories
.Net A.I Azure C# LLM NLP

Using C# and Azure OpenAI services

If you have access to Azure OpenAI services, the following code snippet shows how to chat with ChatGPT!

Some general tips:

  1. Secure your networks, i.e use private endpoints inside Azure! Stolen keys can be used by other people if the network is not secured.

This code example is C# version of what’s discussed in https://github.com/AzureCosmosDB/Azure-OpenAI-Python-Developer-Guide/blob/main/05_Explore_OpenAI_models/README.md

The above link is for Python developers, this blog post for C# developers.

var chatClient = new OpenAIClient(new Uri(azureEndPoint), 
       new AzureKeyCredential(apiKey));

var chatCompletionOptions = new ChatCompletionsOptions();

chatCompletionOptions.DeploymentName = "gpt35";

chatCompletionOptions.Messages.Add(new
    ChatRequestSystemMessage("You are a helpful, fun and friendly sales assistant for Cosmic Works, a bicycle and bicycle accessories store."));

chatCompletionOptions.Messages.Add(new 
    ChatRequestUserMessage("Do you sell bicycles?"));

chatCompletionOptions.Messages.Add(new
    ChatRequestAssistantMessage("Yes, we do sell bicycles. What kind of bicycle are you looking for?"));

chatCompletionOptions.Messages.Add(new
    ChatRequestUserMessage("I'm not sure what I'm looking for. Could you help me decide?"));

var response = await 
    chatClient.GetChatCompletionsAsync(chatCompletionOptions);

if (response != null && response.Value != null && 
    response.Value.Choices != null && 
    response.Value.Choices.Count > 0)
{

    System.Console.WriteLine(
        response.Value.Choices.ElementAt(0).Message.Content);
}

The above code has 3 configuration variables:

  1. azureEndPoint – This is the endpoint from Azure Portal.
  2. apiKey – One of the API keys from Azure Portal.
  3. The deployment name of the model that has been added through Azure Portal.

If the code was run successful, output looks like this:

If there is network connectivity issues, there might be exceptions, if denied due to network security issues errors might be like the following:

Mr. Kanti Kalyan Arumilli

Arumilli Kanti Kalyan, Founder & CEO
Arumilli Kanti Kalyan, Founder & CEO

B.Tech, M.B.A

Facebook

LinkedIn

Threads

Instagram

Youtube

Founder & CEO, Lead Full-Stack .Net developer

ALight Technology And Services Limited

ALight Technologies USA Inc

Youtube

Facebook

LinkedIn

Phone / SMS / WhatsApp on the following 3 numbers:

+91-789-362-6688, +1-480-347-6849, +44-07718-273-964

+44-33-3303-1284 (Preferred number if calling from U.K, No WhatsApp)

kantikalyan@gmail.com, kantikalyan@outlook.com, admin@alightservices.com, kantikalyan.arumilli@alightservices.com, KArumilli2020@student.hult.edu, KantiKArumilli@outlook.com and 3 more rarely used email addresses – hardly once or twice a year.

Categories
A.I Artificial Intelligence Llama LLM

Have you tried Ollama – ChatGPT on your local machine, great software!

Most of you know, from around 2016, I had interest in DataScience/Machine Learning/Artificial Intelligence and even did some courses as a hobby! I am primarily .Net full-stack web developer, but A.I has been fascinating and I have been hobbyist!

In 2021 I started my own startup, 2023 prototyped a concept for a SaaS product known as WebVeta! 2024 – launched an mvp and now is the time to dive into A.I. Over the past 2 weeks, I was experimenting with several different things in A.I both from a development perspective, features perspective!

Over the past 2 days I am playing around with a nice software that allows working with several LLMs from local machine! I would say at least 16GB of RAM, possibly slightly higher.

https://ollama.com

https://github.com/ollama/ollama

The setup instructions are straightforward!

On the Github page, under “Community Integrations” -> “Web & Desktop” there are several web and desktop clients for UI, choose one of those based on your operating system and you can play around with a large set of A.I models. The list of models can be found at: https://ollama.com/library

Try llama3, phi3 if you have enough CPU and RAM! Or try the smaller models – tinydolphin, tinyllama! There are several coding related LLMs i.e GitHub co-pilot’ish and there are some Visual Studio Code extensions that can communicate with locally version of Ollama and help with code!

Remember the LLMs need to be downloaded, the exact syntax is provided on the LLMs pages, but the general syntax is:

ollama pull <LLM_NAME>

I have used https://github.com/ollama-ui/ollama-ui on Linux, https://github.com/tgraupmann/WinForm_Ollama_Copilot for the client UI!

The client UI’s query and get the available local LLMs and allow specifying / selecting which particular LLM to interact with.

If anyone interested let me know via any of my social media profiles, I might consider doing a small demo for any enthusiasts!

Ollama is a great tool and great effort by the team of developers who developed Ollama! Thank you!

WebVeta – Advanced, unified, consistent search for your website(s), from content of your website(s), blogs(s). First 50 customers, who sign-up prior to 15/05/2024 get unlimited access to existing features, newer features for at least 1 year. Sign up now! https://webveta.alightservices.com/

Mr. Kanti Kalyan Arumilli

Arumilli Kanti Kalyan, Founder & CEO
Arumilli Kanti Kalyan, Founder & CEO

B.Tech, M.B.A

Facebook

LinkedIn

Threads

Instagram

Youtube

Founder & CEO, Lead Full-Stack .Net developer

ALight Technology And Services Limited

ALight Technologies USA Inc

Youtube

Facebook

LinkedIn

Phone / SMS / WhatsApp on the following 3 numbers:

+91-789-362-6688, +1-480-347-6849, +44-07718-273-964

+44-33-3303-1284 (Preferred number if calling from U.K, No WhatsApp)

kantikalyan@gmail.com, kantikalyan@outlook.com, admin@alightservices.com, kantikalyan.arumilli@alightservices.com, KArumilli2020@student.hult.edu, KantiKArumilli@outlook.com and 3 more rarely used email addresses – hardly once or twice a year.