Skip to content

Instantly share code, notes, and snippets.

View aleksandr-smechov's full-sized avatar
🌙

Aleksandr Smechov aleksandr-smechov

🌙
  • New York City
View GitHub Profile
@aleksandr-smechov
aleksandr-smechov / files.js
Last active June 20, 2024 15:14
Django Direct-to-S3 Uploads Vanilla JS
const BASE_BACKEND_URL = window.location.protocol + '//' + window.location.host;
const fileInput = document.getElementById('fileInput');
const uploadButton = document.getElementById('uploadButton')
const closeUploadModalButton = document.getElementById('closeUploadModalButton'); // the upload box is in a modal
const progressBar = document.getElementById('uploadProgressBar');
uploadButton.disabled = false;
let xhr;
const getBaseConfig = (method) => ({
@aleksandr-smechov
aleksandr-smechov / api_server_with_auth.py
Last active March 27, 2024 18:20
vLLM FastAPI server with very basic auth
# Adapted from
# https://github.com/lm-sys/FastChat/blob/168ccc29d3f7edc50823016105c024fe2282732a/fastchat/serve/openai_api_server.py
import argparse
import asyncio
import json
import os
import time
from http import HTTPStatus
from typing import AsyncGenerator, Dict, List, Optional, Tuple, Union
@aleksandr-smechov
aleksandr-smechov / distil_whisper_streaming_client.py
Last active November 17, 2023 05:09
Client-side distil-whisper streaming script
import datetime
import platform
import subprocess
import sys
import asyncio
import websockets
import numpy as np
from typing import Tuple, Optional, Union
@aleksandr-smechov
aleksandr-smechov / distil_whisper_streaming_server.py
Created November 17, 2023 05:01
Server-side distil-whisper streaming code
import asyncio
from typing import List
import numpy as np
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
@aleksandr-smechov
aleksandr-smechov / gradio_server_openai.py
Last active January 3, 2024 06:40
vLLM gradio server for skypilot
import argparse
import requests
import gradio as gr
def http_bot(prompt, model_input, api_key, temperature, max_tokens, top_p):
headers = {"User-Agent": "vLLM Client"}
payload = dict(
model=model_input,
api_key=api_key,
@aleksandr-smechov
aleksandr-smechov / estimate_none.py
Created November 8, 2023 17:44
Estimate None timestamp for Whisper output
def estimate_none_timestamps(timestamp_list):
"""
Estimates missing timestamps in a list of timestamp segments based on the character length of segment times.
Parameters:
timestamp_list (list): A list of timestamp segments with text.
Returns:
list: The list with estimated missing timestamps.
"""