Llamafile: the easiest way to try LLMs locally

Posted on Mon 01 January 2024 in AI, LLM • Tagged with AI, LLM

From my previous post about projects to test AI chat bots locally, the field has not been standing still.

I've found that the easiest way to try LLMs locally is to use llamafile: download a file, run it and that's it.

I've also tried LM studio, which is more powerful, but it's also more complicated to use.


Uninstalling Windows Apps that seem not to be installed

Posted on Mon 01 January 2024 in Windows • Tagged with Windows

I found with WizTree that there are some apps in C:\Program Files\WindowsApps that seem not to be installed for my user, and I'm the only user on my computer. Examples are games like Candy Crush and Disney Magic Kingdoms. I found a solution to uninstall them in the following thread.

Basically, you have to start PowerShell as administrator and run the following command:

Get-AppxPackage -allusers  *disney* | Select Name, PackageFullName
Get-AppxPackage -allusers  *disney* | Remove-AppxPackage -allusers

The first command lists all apps that contain the string disney in their name. The second command removes all apps that contain the string disney in their name. You can also use *candy* to remove Candy Crush and so on.


Serving JavaScript with Python's http.server

Posted on Wed 19 July 2023 in Python, JavaScript, Web • Tagged with Python, JavaScript, Web

I was trying to serve a JavaScript file with Python's http.server module, but I was getting this error:

Loading module from http://localhost:9876/main.js” was blocked because of a disallowed MIME type (“text/plain”).

I saw in this StackOverflow answer that I needed to change the MIME type for JavaScript files. I'm using Windows, so I checked the key HKEY_CLASSES_ROOT\.js in RegEdit, and I found that it had this value:

(Default)     JSFile
ContentType   text/plain
PerceivedType text

I changed the ContentType to application/javascript, and now my JavaScript files are served with the correct MIME type.

I'm not sure why the MIME type was set to text/plain in the first place. I'm guessing that it was set by a program that I installed, but I don't know which one. I'm also not sure if changing the MIME type will cause any problems with other programs.


Pylance and mypy cannot find editable local imports

Posted on Thu 01 June 2023 in Pylance, Mypy, Python • Tagged with Pylance, Mypy, Python

The other day, I wrote a post about how I fixed a problem with Pylance not finding a local import. It worked, but now mypy was complaining about the same import.

The solution was installing the package in compat mode with:

pip install -e . --config-settings editable_mode=compat

Reading units from a pickle file with Pint

Posted on Tue 30 May 2023 in Pylance, Python, Pint • Tagged with Pylance, Python, Pint

I have a Python package called cloudmodel that uses Pint to define units and adds some to the default registry. When I read a pickle file that use these units, I get an error:

int.errors.UndefinedUnitError: 'usd' is not defined in the unit registry

The way to fix it is to set the application registry to the one used by cloudmodel:

from cloudmodel.unified.units import ureg
from pint import set_application_registry

set_application_registry(ureg)