Skip to content

Instantly share code, notes, and snippets.

@aviadr1
aviadr1 / json_schema.py
Last active December 24, 2025 09:49
**OpenAI JSON Schema Sanitizer for Pydantic Models** - A production-ready function that transforms any Pydantic model into an OpenAI Structured Outputs-compatible JSON schema, handling optionals, unions, recursion detection, numeric constraints, and additionalProperties issues that cause API failures. Includes comprehensive test suite covering a…
"""
File: gv/ai/common/llm/json_schema.py
Author: Aviad Rozenhek
OpenAI Structured Outputs (`response_format={"type":"json_schema"}`) supports only a subset of JSON Schema.
Many perfectly valid Pydantic constructs won't fly as-is. Use these patterns:
-------------------------------------------------------------------------
1) Optional / nullable / Default fields
-------------------------------------------------------------------------
@riverscn
riverscn / gen_iptv_m3u8.sh
Last active October 16, 2025 04:52
中国电信IPTV抓包数据转m3u8播放列表
#!/bin/bash
# Usage: bash gen_iptv_m3u8.sh iptv.pcap
udpxy=192.168.5.1:7088
input=$1
workdir=${input%%.*}
tshark -r $1 -Y 'http.response_for.uri contains getchannellist' -T jsonraw -j data-text-lines_raw \
| awk '/"data-text-lines_raw"/{getline; print}' \
| sed -E 's/"|,//g' \
@zozovo
zozovo / Sarasa-Gothic.user.js
Last active November 7, 2024 02:03
Replace the font with Sarasa Gothic (CJK) and the corresponding monospaced one.
// ==UserScript==
// @name Sarasa-Gothic-Font-Substitution-Tool
// @name:en-US Sarasa Gothic Font Substitution Tool
// @name:zh-CN 更纱黑体字体替换工具
// @name:zh-TW 更紗黑體字型替換工具
// @name:zh-HK 更紗黑體字型替換工具
// @name:ja-JP 更紗ゴシックフォント置換ツール
// @name:ko-KR 사라사고딕 폰트 대체 도구
// @namespace https://gist.github.com/zozovo/8a76915acf197a873304dd23f2cfd49c
// @version 8.9