Showing posts with label Visual Studio Code. Show all posts
Showing posts with label Visual Studio Code. Show all posts

Tuesday, October 24, 2023

Enable Python preview in Polyglot notebook

It is a big difference if anyone ever tried the Jupyter Notebook. Once we experience, we need that experience everywhere including .Net. That experience was there in terms of a Jupyter kernel for .Net¹. That requires Jupyter installed in the machine already. Finally, more native experience came for .Net in the form of a VS Code extension. That was called .Net Interactive Notebooks² which uses .Net Interactive (formerly Try.Net) behind the scene. That started supporting many languages such as PowerShell, JavaScript, SQL etc... which is kinda out of the .Net world. Finally, in Nov 2022, .Net Interactive was renamed to Polyglot notebooks³ to reflect its purpose.

Is Python supported by Polyglot Notebooks?

The Polyglot notebooks didn't have the support for Python. We had to switch to Jypyter to work with Python and come back. Now Polyglot Notebooks has Python support as a preview.

How to enable Python in Polyglot Notebook?

Obviously, we should have Polyglot notebooks up and running. The first step to enable Python preview is that we need to install Jupyter on the machine and make sure the Python kernel spec is available. Run the below command to make sure it is there.
Once this is done, we can see 2 Kernel options at the Notebook level in Visual Studio Code.

The enabling preview feature requires the below command to be run on the notebook cell.

#!connect jupyter --kernel-name pythonkernel --kernel-spec python3

The command output shows it is in preview mode.
Command is - #!connect jupyter --kernel-name pythonkernel --kernel-spec python3

Once we add support, we can start having Python cells alongside C#. The cell kernel type needs to be the name we have given in the connect command. Below is the final state. Here we can learn C#⁴ and Python side by side.

We can even set up R language in Polyglot Notebooks⁵. Hereafter don't waste time creating an entire project to confirm small language or platform features.

References

¹ - https://devblogs.microsoft.com/dotnet/net-core-with-juypter-notebooks-is-here-preview-1/

² - https://hanselman.com/blog/announcing-net-interactive-try-net-includes-net-notebooks-and-more

³ - https://devblogs.microsoft.com/dotnet/dotnet-interactive-notebooks-is-now-polyglot-notebooks/

⁴ - https://techcommunity.microsoft.com/t5/educator-developer-blog/using-visual-studio-notebooks-for-learning-c/ba-p/3580015

⁵ - https://github.com/dotnet/interactive/blob/main/docs/jupyter-in-polyglot-notebooks.md

Tuesday, October 3, 2023

[Video] Configuring CodeGPT to use Azure OpenAI key

If there is a way to get GitHub Copilot, use it and don't look back. But if we don't have the luxury to afford the license or there are other reasons but still want to leverage AI continue reading this post.

CodeGPT VS Code extension

This is not a complete replacement for Copilot but it can give some level of intelligence and speed up development. Checking code quality, and explaining the code are some to use.

They have their own licensing model where the AI comes from them or we can use their extension to use our preferred AI providers. If we don't have GitHub Copilot but have an Azure subscription with Azure Open AI service we can configure the CodeGPT extension using the key from Azure Open AI.

Why this post and a video just to configure?

It may sound easy. Why a post to do the configuration? The reason is that the provided documentation¹ is not clear and the extension configuration screen leads us to the wrong URL to configure.
eg: the extension configuration screen is not showing the /openai/ in the URL also the fragment is to be added after the model name. But in order to configure we need all.

The endpoint of the Azure OpenAI service will look like below.

https://<your name>.openai.azure.com

But this is not the URL to be used to configure. The URL to configure is as follows

https://<your name>.openai.azure.com/openai/deployments/<model name>/chat/completions?api-version=2023-07-01-preview

Yeah, there is a video also made to make it simple.


References

Tuesday, July 23, 2019

Setting up PlantUML for coding C4 architecture diagrams - Video Tutorial

At last I published a video tutorial. As always its very difficult to get the first job done, if its a different type of job.

The tutorial is about setting Visual Studio Code with PlantUML to code C4 architecture diagrams  as explained in one of my previous post.

Since I don't have the right recording equipment and not a native English speaker, I used a text to speech service. It is AWS->Polly service. I didn't feel somehow the voices in Azure are good. The voice is US English Male voice named Matthew.

You tube link is given below and also embedded.
https://www.youtube.com/watch?v=Zt3Bj1HMJ8g