Langchain is an abstraction layer so that you don’t have to call the APIs of every AI provider separately
Originally in Python, langchain ports such as Dart and Rust exist
QWORQS – A blog by Yazeed Almadaeen
Langchain is an abstraction layer so that you don’t have to call the APIs of every AI provider separately
Originally in Python, langchain ports such as Dart and Rust exist
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 is a great tool to run models locally on your machine, but it is somewhat more than that
According to their intro, it is…
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)
1- Installing as docker container
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
At this stage, you should be good to go,
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 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)
This page is a list of AI solutions that you can use via API for a fee
Vellum Leadboard: This website maintains a lead-board that compares prices !
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/
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
I am not sure this requires any introduction !
While the ChatGPT app can be accessed through, the API portal is at platform.openai.com, and even though the website provides a free tier, the API does not, you must have prepaid credits in order to use it, the minimum is $5, those $5 are pay as you go, you use them up by sending more API calls.
GPT 4o is rumored to be 10 Trillion parameters !! for comparison, deepseek, which is an amazing LLM that came out lately is 671 Billion parameters, meaning it is 7% of the size of ChatGPT !
Models and API pricing