Skip to content

Instantly share code, notes, and snippets.

@lamoboos223
lamoboos223 / CentOS 7 Repository Fix Script.sh
Created January 20, 2025 23:07
This is for centos7 old mirror repository
#!/bin/bash
# Backup existing repo files
echo "Creating backup of existing repo files..."
cd /etc/yum.repos.d/
mkdir -p backup
mv CentOS-* backup/
# Create new CentOS-Base.repo file
echo "Creating new CentOS-Base.repo file..."
@lamoboos223
lamoboos223 / sphinx_example.md
Last active January 19, 2025 10:00
sphinx a gui documentation

Create docs/ directory

mkdir docs/
cd docs/
pip install sphinx sphinx-rtd-theme myst-parser recommonmark
@lamoboos223
lamoboos223 / function-calling.md
Last active December 16, 2024 22:11
This is a demo on how to make a function calling app via LangChain framework to utilize models running on Ollama platform
import warnings
from fastapi import FastAPI
from langchain_experimental.llms.ollama_functions import OllamaFunctions
from pydantic import BaseModel
from typing import List

warnings.filterwarnings('ignore')

app = FastAPI()

Build Project From Source

poetry install --extras all

Activate Virtual Environment (MacOS)

source /Users//Library/Caches/pypoetry/virtualenvs//bin/activate

enable notification for a room

note that %21RotqTsIrBvXaPAbhiC%3Atwkl.chat is the room_id after url encoding it using this tool

curl --location --request PUT 'http://localhost:8008/_matrix/client/r0/pushrules/global/room/%21RotqTsIrBvXaPAbhiC%3Atwkl.chat' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <user_token>' \
--data '{
'''
Steps for making a RAG system in Langchain framework
1. Prepare the data (knowledge base)
2. Use the Loader object to load the data in the proper format
3. Chunk the data into appropriate size
4. Create Embedding and Retriever
4.1. Use Embedding model like BAAI/bge-base-en-v1.5 from HuggingFace
4.2. Create a Vector database like FAISS (Facebook AI Similarity Search). And the Retriever is a an object from the DB class. E.g. `retriever = db.as_retriever(search_type="similarity", search_kwargs={"k": 4})`
apt install python3 python3-pip wget curl unzip portaudio19-dev virtualenv libespeak1 libespeak-dev -y
cd /opt
wget https://github.com/lamoboos223/demo-faster-whisper/archive/refs/heads/master.zip
unzip master.zip
rm master.zip
cd demo-faster-whisper-master
virtualenv myenv
source myenv/bin/activate
python3 -m pip install -r requirements.txt
python3 __init__.py

install on unix like systems

sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
# restart terminal session
nix --version

create nix shell

@lamoboos223
lamoboos223 / esp8266_output_to_arduino_uno.md
Last active April 1, 2024 03:17
connect esp8266 to output a value to arduino uno where arduino reads this value and do some action

Arduino code

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);   // Initialize the serial communication

  pinMode(7, INPUT);

}