Skip to content

Instantly share code, notes, and snippets.

View flipbit03's full-sized avatar
🛠️
Never delegate understanding

Cadu flipbit03

🛠️
Never delegate understanding
View GitHub Profile
@flipbit03
flipbit03 / ollama_no_think_with_pydantic_ai.py
Last active March 13, 2026 01:24
PydanticAI + Ollama: How to control thinking (reasoning) on/off via OpenAI-compat API
"""
PydanticAI + Ollama: Controlling Thinking (Reasoning) on/off
=============================================================
Problem:
Ollama's OpenAI-compatible API (/v1/chat/completions) auto-enables thinking
for thinking-capable models (like qwen3.5). There is NO `think: true/false`
parameter on the OpenAI-compat API — that only works on Ollama's native
API (/api/chat).
@flipbit03
flipbit03 / restore.sh
Created March 23, 2024 22:52
Restore a dump to a PG database, using Docker to use the exact version
#!/bin/bash
# Function to check if an environment variable is set
check_env_variable() {
local var_name="$1"
local var_desc="$2"
if [ -z "${!var_name}" ]; then
echo "Error: '${var_name}' environment variable is not set. Please set it to ${var_desc}."
exit 1
@flipbit03
flipbit03 / dump.sh
Last active March 24, 2024 19:53
Dump from a PG database, using Docker to use the exact version
#!/bin/bash
# Function to check if an environment variable is set
check_env_variable() {
local var_name="$1"
local var_desc="$2"
if [ -z "${!var_name}" ]; then
echo "Error: '${var_name}' environment variable is not set. Please set it to ${var_desc}."
exit 1
@flipbit03
flipbit03 / type_aware_python_decorator.py
Last active November 17, 2023 00:14
Type-aware Python Decorator
P = ParamSpec("P")
RT = TypeVar("RT")
# By using ParamSpec, you are able to capture the original function's args and kwargs and forward
# them through the decorator in a way that static analyzes like MyPy, and also ide's like PyCharm
# will be happy ;-)
def your_decorator(f: Callable[P, RT]) -> Callable[P, RT]:
@wraps(f)
def decorated_function(*args: P.args, **kwargs: P.kwargs) -> RT: