Skip to content

Instantly share code, notes, and snippets.

@neelabalan
neelabalan / command
Created February 28, 2024 12:33
extract only the dependencies with version
grep -Eo '[a-zA-Z0-9_-]+==[0-9.]+' requirements.txt
@neelabalan
neelabalan / log.py
Created February 27, 2024 01:19
logging with JSON format
import json
import logging
from pydantic import BaseModel
class JsonLogHandler(logging.Handler):
def emit(self, record):
log_record = {
'level': record.levelname,
'message': record.getMessage()
import datetime
from pydantic import BaseModel
import sqlite3
db = sqlite3.connect("mydb")
class Document(BaseModel):
name: str
chunk: str
date: datetime.date
@neelabalan
neelabalan / fast_speech_text_speech.py
Created February 24, 2024 08:00 — forked from thomwolf/fast_speech_text_speech.py
speech to text to speech
""" To use: install LLM studio (or Ollama), clone OpenVoice, run this script in the OpenVoice directory
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
pip install whisper pynput pyaudio
"""
from openai import OpenAI
import time
@neelabalan
neelabalan / stream.py
Created February 24, 2024 05:21
stream tokens
for token in my_agent.stream({"input": query, "chat_history": chat_history}):
print(token, end="", flush=True)
You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture. Knowledge cutoff: 2023-04 Current date: 2024-02-13
Image input capabilities: Enabled Personality: v2
# Tools
## bio
The `bio` tool allows you to persist information across conversations. Address your message `to=bio` and write whatever information you want to remember. The information will appear in the model set context below in future conversations.
@neelabalan
neelabalan / .gitconfig
Created January 15, 2024 07:52 — forked from architgarg/.gitconfig
Awesome git aliases - [For Medium Article]
[alias]
br = branch
st = status -s -b
lg = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative -20
ac = !git add -A && git commit -m
oops = !git add -A && git commit --amend --no-edit
unstash = stash pop
bd = branch -D
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@neelabalan
neelabalan / file.py
Created November 30, 2023 13:25
Post log transformation
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Generating a right-skewed data distribution
data = np.random.exponential(scale=2, size=1000)
# Performing log transformation
log_transformed_data = np.log(data + 1) # Adding 1 to avoid log(0) issue