Gradio

Gradio is all about user interface, it is a startup that got acquired by Hugging Face !

In your python code, you execute the following line

import gradio as gr # The way people usually call it

now, here is an example that turns your text to uppercase

def to_uppercase(text):
return text.upper()

Now, to get a user interface, run the following code

gr.Interface(fn=to_uppercase, inputs="textbox", outputs="textbox").launch()

Now, you should be getting 2 boxes, one for your input, and the other to display your text in uppercase

Now, imagine the to_uppercase function being a call to an AI, so there you have it

Here is a variant with big boxes

# Inputs and Outputs

view = gr.Interface(
fn=to_uppercase,
inputs=[gr.Textbox(label="Your message:", lines=6)],
# outputs=[gr.Textbox(label="Response:", lines=8)],
outputs=[gr.Markdown(label="Response:")],
flagging_mode="never"
)
view.launch()

At this point, when you run this, you should get the link to the URL with that user interface !

LM Studio

LM studio is a great tool to run models locally on your machine, but it is somewhat more than that

According to their intro, it is…

  • A desktop application for running local LLMs
  • A familiar chat interface
  • Search & download functionality (via Hugging Face 🤗)
  • A local server that can listen on OpenAI-like endpoints
  • Systems for managing local models and configurations

stable-diffusion-webui from Automatic1111

This is a great front end for Stable Diffusion

the official GIT repo for this is here, to install it alongside stable diffusion and everything else you need, make sure you are running in your local environment with conda or pip, and run the following command

wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh

then make it executable and run it with the following command

./webui.sh --listen --api

You can add Automatic1111 to your openwebUI (Go to settings/images)

OpenWebUI

1- Installing as docker container

  • Install docker like you would, by adding its repositories or however you are used to installing it
  • sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  • docker run -d --network=host -v open-webui:/app/backend/data -e OLLAMA_BASE_URL=http://127.0.0.1:11434 --name open-webui --restart always ghcr.io/open-webui/open-webui:main
  • to check if it is running, run sudo docker ps
  • Now, localhost:8080 should have your OpenWebUI running
  • Do a signup or create account (Local instance bound), the first account you create will automatically become an admin account !

At this stage, you should be good to go,

If you don’t want to use docker ! you can simply install it with the following pip command

pip install open-webui

Once done, you can simply run it with

open-webui serve

In some cases, if Ollama was previously setup and not running, you might want to run Open WebUI with the command

ENABLE_OLLAMA_API=false open-webui serve

Otherwise, you might have it hang with the message





Now that it is running, go to http://localhost:8080 and create an account, the first account you create will automatically become the admin account

Adding OpenAI API key

The most common use for open-webui is with Ollama, but let us assume you want to install your openAI account into it !

1- Go to admin panel (Bottom left)
2- Go to settings in admin panel (center top)
3- go to connections
4-

Hardware requirements for AI

Every model is a different story, but before you start looking into models, there are a few useful things to know, and a few useful tools that you can use.

NVIDIA

Nvidia is a very popular AI hardware provider, the cool things about modern AI models is that they can be split into layers, hence, you can have more than one card doing the work ! So, I have 2 x 4090 cards doing the work, you can combine the ram to see if your model fits on both when split in half, some models even provide an option to offload some of the model’s data onto the system ram, other have the option to load part of the data into VRAM as needed ! but that is a story for another day (Another post)…

To inspect the GPU and RAM usage of your GPUs, you can use the following command

watch -n 0.5 nvidia-smi

The command should show you what processes live in your VRAM (VRAM is your cards ram)

Getting my 1994 W124 E200 to run again

From other posts like this one, I seem to always be complaining about the 209 E200 W211, The thing i never mentioned is that I have an even older Mercedes E200, A W124 that has been parked for 8 years and decided just now to revive it.

for one, there is a water leak in the cooling system, for another, it has no gas in it, and the fuel pump is not working !

I recall from 8 years ago someone telling me “I can smell gas” While the car was parked near us ! So i am guessing, there is a small leak that is leaking out the gas

Not long before it got parked (8 years ago), the car had a serious leak (Leaked a full tank in a day) and I had to change the hose that connected the fuel tank to the fuel pump that is under the car !

Here are the specs, and this is post is all about how I plan to bring this car to life in a few days !

My Mercedes 200 E (W124 – E200)

  • Transmission: 5 Speed manual transmission
  • Engine: M111.940 (Wikipedia) (Check if part is 111 010 8700 on xentry/das)
  • It has that different looking steering wheel and shifter, If i recall right, this variant’s name has the word sport in it (probably sports line), but I am not sure what it was called exactly, I recall this info because I had to get the steering wheel shipped from Poland as no used or new parts dealer has ever seen it before

Diagnostics/OBD2

Well, this 1994 E does have a diagnostics port, but it is nothing like OBD2 (It is OBD1 not 2), it is very easy to read, just connect any LED (use a 12V LED, or adapt an LED for 12V with resistors obviously).

The 16 pin connector can be accessed with banana plugs connecting the LED to the flowing

Pin-3 = ECU (BLINK… LED+Button)
Pin-6 = K-line (BLINK… LED+Button) (Ex: VAG-COM USB reader)
Pin-1 = GND
pin-16 = 12V

The users manual does not go into sufficient detail concerning the (HFM Sequential Multiport Fuel Injection/Ignition System (HFM-SFI))

The OBD plug can be accessed with a scan tool (Ex: HfmScan) using the diagram below, if you insist on going into that rabbit hole, there are adapters (OBD2 to banana) like the one you see here, which connects the OBD connector to the following pins (OBD breakout cable 4 colours)

Now, I prefer using the LED method

Degrading wires (Mercedes and Porsche !)

Why I think claiming that the degrading wires were “intentionally installed for easier recycling” is a bullshit attempt to cover Mercedes benz’s unforgivable failure on those models

  • Having an arcing wire right next to the fuel pump is an even worse failure than the failing to predict that the wires will bio degrade
  • Giving a rust insurance of 30 years, and having the wires degrade after 10 ? doesn’t make any sense, You are implicitly telling the consumer you are expecting the car to live for 30 years, having its cables degrade starting after 10 years with the most dangerous ones, and eventually degrading to the extent that fixing it is not feasible contradicts the assumption of expected longevity !
  • Assuming the above is not correct in the sense that not all wires degrade, only those exposed to heat etc… defeats the purpose they claim the wires were scheduled to degrade for

To revisit

When your primary concern is getting it to run, you will come across stuff that needs attention after, here is a small list

  • The wires to the fuel pump need shrink wraps
  • Distilled water to be swapped with antifreeze

Shopping list

I don’t think this will be a long list, but I am mentioning what I needed here so that if you are in a similar situation, this might remind you of what you might need

  • Both kinds of polish compounds
  • Retouch paint, and application thingie
  • Thinner (To clean spray gun after)
  • Clear coat
  • Clean, lint free cotton
  • Masking paper
  • Electrician’s tape
  • Gasoline ! since it probably evaporated
  • A 12V tester (Usually in the form of a screw driver with a wire hanging out from the back to go to ground/Negative)
  • A 12V car battery (The one in the car is 100% toast)
  • Distilled water for the radiator (Add antifreeze later)

Head gasket and valve stem seals !

Surprise ! the head gasket is toast (happened while it was sitting) ! So I will probably need to start with this one

The head gasket i found on the market are Reinz (Victor Reinz now owned by DANA)… Part number 61-29105-10 – I am told that for that model year, the gasket was either Reinz, or Elring, Mercedes used both as OEM so I am hoping i should be good… the head gaskets for the M111 was a multi-layer steel (MLS), and is 91 mm diameter, 1.75 mm thickness, which is what the gasket i have is !

On ebay, it says this gasket fits the OEM numbers (111 016 05 20, 111 016 06 20, 111 016 11 20, 111 016 26 20, and 111 016 27 20)

For the Exhaust Manifold Gasket, I found the Victor Reinz Exhaust Manifold Gasket 71-29349-00, which seems to fit the bill (matches Mercedes-Benz OEM numbers 111 142 05 80 and 111 142 08 80)
Torque spec for the M111 exhaust manifold nuts is 25 Nm (Double check)

TTY head bolts: So, what is left is finding new TTY head bolts (torque-to-yield), this is usually where my problems begin, I am always forced to use the old bolts (Like everyone else) because finding those bolts is next to impossible in Jordan ! they tell me (We don’t cary them because no one orders them), this happened to me lately with my Toyota and almarkazeyah exclusive Toyota dealer !

Valve stem seals: Found the Corteco brand (PN: 19034069) ! this is not ideal as I prefer having OEM like Reinz or Elring, But I am being told Cortico is a brand of Freudenberg, the inventors of the seals you see on the crank of your car for example (Their brand of it was called Simmerring), So, with this old engine, I guess i will give them a go ! the box I have reads (made in Italy), Italy is the place where Chinese products go to get a European seal of origin (A loophole in the system, probably intentional) states that if anything is added to the product in italy, it can be branded as made in Italy !

Keyboard and mouse Bluetooth wireless adapter

I found this adapter on Ali Express, the KUWEE Bluetooth 5 wired keyboard and mouse adapter, it should connect my beloved wired keyboard and mouse to my PC through Bluetooth 5, to any of 8 Bluetooth enabled devices

I got a few of them for a very nice project of mine, but more on that in another post !

According to the seller, here are the features of the device

  • Brand: BRDRC
  • Product size: 67x40x14MM
  • Interface type: USB
  • Effective distance:30M
  • Supported system: Windows, ios. Android, OS.linux. TVOS, etc color:Black
  • Material: plastic
  • Package Contents: 1 x Gaming Keyboard Mouse Converter.

I am still looking for all the specs, but i think I found what I was looking for and am here to share this

Note: The device works fine with my wireless keyboard and mouse in 1 dongle (I used the keyboard port for the dongle), I understand it defeats the purpose (2 wireless hops), but just in case you have a reason to want it to work with 1USB that carrys both keyboard and mouse, there you have it, IT WORKS

Pairing

When you connect the device with a keyboard and mouse and power, you only need to hit the center button long enough for a new slot to start blinking, this means the device is ready to pair, look for the device with the name MEYING X1 3

1- Circulating through output: Switching output devices using the physical button on the device is inconvenient, you have to go through up to 7 clicks to get back to the one right before the one you are on (This is assuming all 8 slots are programmed, if you only programmed two devices, you only have to click twice to come back to the device you are on) !

So the answer is a shortcut, something a la KVM devices that intercept keyboard strokes as shortcuts, so the 8 inputs can be mapped directly to the 8 numbers on the keyboard with the following shortcut

Ctrl+Alt+Shift+1/8

2- Resetting the device: another shortcut that might come in handy is how to reset the device, here is the shortcut

device physical button + F1 on keyboard for 15 seconds

So, There you have it, the most useful two shortcuts that can mean the difference between convenient and inconvenient !

3- Multimedia buttons !

According to a random screenshot on my phone, the device adds multimedia buttons when you don’t have any physical ones !

  • Ctrl + Alt + Shift + Esc = Multimedia Keys on / off
  • Ctrl + Alt + Shift + F1 = iOS soft keyboard on / off
  • Ctrl + Alt + Shift + F2 = Volume Down
  • Ctrl + Alt + Shift + F3 = Volume Up
  • Ctrl + Alt + Shift + F4 = Mute
  • Ctrl + Alt + Shift + F5 = Previous
  • Ctrl + Alt + Shift + F6 = Next
  • Ctrl + Alt + Shift + F7 = Play / Pause

4- The USB output at the top: I don’t think it has any function other than sharing the power source to for example recharge a phone or something, not a very useful feature, but knowing what it is would at least answer your curiosities !

5- Size

For our American friends who would rather use any unit of measurement except for SI, the device itself is two fingers wide and less than one finger thick, and 3/4 index finger long, like in the photo below, as for everyone else, the dimensions of the device are 67x40x14MM

Here are some scans and photos i took for my future reference

So, here are a few photos of the device from the website, here for my reference

There is also another branding of the same external box at a much lower price (Photo below), sometimes less than half the price, but since i will have to wait a couple of weeks for it to arrive, I had to get the above because it has many more reviews, I would bet the other box is exactly like the one I got, but oh well, just a few dollars difference to spare me disappointment isn’t a big deal

And there also seems to be another device that shares the same input and output and description and I would bet it is them same device in a different shell, it looks like the one below, and it is also available in the KUWEE brand…

Cloud AI with API

This page is a list of AI solutions that you can use via API for a fee (Or for free)

Vellum Leadboard: This website maintains a lead-board that compares prices !

  1. OpenAI (ChatGPT)
  2. Anthropic (Claude)
  3. Google / Gemeni
  4. DeepSeek
  5. Cohere / Command R
  6. Perplexity: (A search engine that can either use other models, or its own model)
  7. hunyuan : by tencent.. The T1 Turbo-s hybrid transformer MAMBA architecture (Super fast (2x)), 24K input tokens and 64K output tokens ($0.14, and $0.56 respectively)… HuggingFace demo
  8. Ernie 4.5 : From Baidu, china’s leading search engine (yiyan.baidu.com)
  9. grok.com (By XAI, under the same company that acquired twitter)

Anthropic / Claude

Anthropic’s claude is probably the main competing AI to OpenAI’s ChatGPT

Anthropic has an edge over OpenAI in many areas, I personally think it is better than OpenAI for Code generation

To simply chat with Claude, you can create an account at https://claude.ai/

To obtain API keys from anthropic and access the system programmatically, you will need to get the API keys from https://console.anthropic.com/

Your .env file

In the context of my AI notes, here is what you need to know about the .env file

Any file that starts with a . is a hidden file according to linux, windows is a bot funny about such files, it allows their existance, as long as you don’t try to use windows explorer to name or rename into them.

On linux, if you want the ls command to show such files, you would execute the command “ls -a

Now, with that out of the way, let me start with a few variables for various providers

# Open AI (ChatGPT)
OPENAI_API_KEY=sk-proj-xxxx
# Google AI (Gemeni)
GOOGLE_API_KEY=xxxx
# Anthropic (Claude)
ANTHROPIC_API_KEY=xxxx
# Huging face (HF_TOKEN is short for hugging face token)
HF_TOKEN=xxxx
# DeepSeek API
DEEPSEEK_API_KEY=sk-xxxx