Skip to content

Instantly share code, notes, and snippets.

View DeoLeung's full-sized avatar

Zhanzhao (Deo) Liang DeoLeung

View GitHub Profile
@DeoLeung
DeoLeung / hangxiaoyi.md
Last active September 19, 2025 03:19
杭小忆系列大模型接口

chat请求

curl --location 'https://api.aiyou178.com/dispatcher/hangxiaoyi/hangxiaoyi/chat/completions' \
--header 'Authorization: YOUR_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
    "messages": [
        {
            "role": "user",
            "content": "ahahaha"
@DeoLeung
DeoLeung / stt.py
Created August 13, 2025 02:10
livekit stt supports switch between push-to-talk and turn detection
"""
this is the basic stucture supports switching betwween ptt and td in livekit agent
I may later summit a full example and/or opensource my stt/tts implementation using volcengine, if...if i have time :)
"""
# overwrite agent's stt_node
async def stt_node(self, audio, model_settings):
activity = self._get_activity_or_raise()
assert activity.stt is not None, (
'stt_node called but no STT node is available'
)
@DeoLeung
DeoLeung / sample_openapi_spec.py
Created March 12, 2024 03:14
generate openapi.json with fastapi
"""python scripts/sample_openapi_spec.py openapi.json title version"""
import json
import sys
import fastapi
from fastapi import Body
from fastapi import Depends
from fastapi import Query
from fastapi.openapi.utils import get_openapi
from fastapi.security import APIKeyHeader
@DeoLeung
DeoLeung / paradedb.py
Created January 22, 2024 10:01
sqlalchemy recipe for paradedb
"""
sqlalchemy discussion: https://github.com/sqlalchemy/sqlalchemy/discussions/10841
"""
def dump_dict(v):
"""recursively dump dict into rust style, which no quotes for key"""
match v:
case str():
return f'"{v}"'
case int():
return f'{v}'
@DeoLeung
DeoLeung / list_to_bitmaps.py
Created December 26, 2017 06:21
transform list of integers into bitmaps bytes and back
import numpy as np
ids = [1, 5, 7, 12]
bitmaps = np.zeros(max(ids) + 1, dtype=np.bool)
bitmaps[ids] = True
bitmaps = np.packbits(bitmaps).tostring()
print(bitmaps)
# b'E\x08'
# could be use as a binary field to be stored in database
@DeoLeung
DeoLeung / devpi.sh
Created May 19, 2017 04:57
搭建内部python registry, 使用douban镜像
# devpi server
# install package
pip install --trusted-host pypi.douban.com -i http://pypi.douban.com/simple devpi
# initialize the server directory
devpi-server --init
# create the supervisord devpi.ini or start the server directly, if not root user, provide the --serverdir
devpi-server --host 0.0.0.0 --port 3141 --serverdir ~/.devpi/server
# after the server is running
# point to registry