Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lmmx's full-sized avatar
🍜
focusing on pho

Louis Maddox lmmx

🍜
focusing on pho
View GitHub Profile
@lmmx
lmmx / prompt.md
Created February 19, 2024 14:47
Mind Ferry (custom GPT) prompt

I, the user, want to be "ferried" by an external computer agent: a custom GPT called "Mind Ferry". As you are a language model, you are able to ferry me through my day by instructing me to do certain things at certain times, by estimating a proper arrangement of tasks given the premise, which is either stated directly or implicit in input provided by the user.

I do not want this in the form of a calendar or any technical format. I want it in a very concise, actionable format with clear separation through headers and very little text that is not absolutely necessary. Although being concise, you need to give the specific sub-tasks, not just the overall tasks.

For example, I may say that I need to eat lunch and I have soup in my fridge, but that is not enough on its own. So I want to have something else, like toast, but I do not have bread (but I do have some frozen bread). And I want to go shopping to get something from the shopping centre ten minutes bus journey away. You would assemble all of those requirem

conda create -n aqlm python=3.11 -y
conda activate aqlm
conda install pytorch pytorch-cuda=11.8 -c pytorch -c nvidia -y
pip install aqlm[gpu]==1.0.1
pip install "git+https://github.com/huggingface/accelerate.git@main"
pip install "git+https://github.com/huggingface/transformers.git@main"
@lmmx
lmmx / Template.md
Created February 12, 2024 15:46
Template for task specification

Thank you for clarifying your requirements for the new templating system to record new items of work in your company's GitHub repository. Based on your detailed explanation, it's clear that the focus should be on components, routines, and original contributions without explicitly prioritizing or determining dependencies in the manner I previously suggested. Let's adjust the template to align with your vision:


New Work Item Template


Title:

[Feature/Issue Name]: [Brief Description]

@lmmx
lmmx / reason_based_exits_with_handlers.py
Last active February 10, 2024 18:00
The Body Guard pattern: a context manager that prevents errors from bubbling up, but does ensure they halt (unless designated as recoverable)
from __future__ import annotations
from pydantic import ValidationError
__all__ = ["BodyGuard", "FailureCause", "main"]
class BodyGuard:
"""Exceptions raised in this ContextManager become stored as `errors`."""
@lmmx
lmmx / fail_trace.py
Last active January 29, 2024 21:16
Traceback from unsuccesfully patching Fal `test_apps_simple.py` on the `pydantic-2-bump` feature branch, and another from a trivial `assert False` to compare to the success case (test must fail to see the logs)
============================= test session starts ==============================
platform linux -- Python 3.11.7, pytest-7.4.4, pluggy-1.3.0 -- /home/louis/miniconda3/envs/fal/bin/python3
cachedir: .pytest_cache
rootdir: /home/louis/dev/fal/pydantic-2-bump/projects/fal/tests
plugins: anyio-4.2.0
collecting ... collected 1 item
test_apps_simple.py::test_app_client FAILED
=================================== FAILURES ===================================
@lmmx
lmmx / newwip.sh
Last active February 2, 2024 16:11
Git repo handling bashrc functions
alias gcb='git checkout -b'
alias gcwd='gcb $(basename $PWD)'
function gcns { gcb "lmmx/${1-$(basename $PWD)}"; }
function newwip () {
local NEW_WIP=$1;
local CLEAN=${2:-"clean/develop/"};
if [ -z "$NEW_WIP" ]; then
echo "Error: NEW_WIP arg must be passed." >&2
return 1
elif [ ! -d "$CLEAN" ]; then
@lmmx
lmmx / comparison.md
Last active January 26, 2024 00:17
Dynamic model creation checklist

Different in key: __pydantic_parent_namespace__ (can just set on the recreated model)

  • __pydantic_complete__
  • __pydantic_decorators__
    • different:
====__pydantic_decorators__===
DecoratorInfos(validators={},
               field_validators={'x_plus_10': Decorator(cls_ref='__main__.A:31201184',
@lmmx
lmmx / dynamic_pydantic_model_creation.md
Last active January 25, 2024 23:36
Dynamic Pydantic model creation examples

geekan/MetaGPT: action_node.py

Verdict: only one validator, a model validator

Sets a single model validator (L150), passes its function from the local namespace after creating it as an higher order function [in a method].

Tautulli/Tautulli: dataclasses.py

@lmmx
lmmx / checkly_badges.py
Last active January 25, 2024 14:08
Added to the docs with a `hooks` top-level entry in the `mkdocs.yml` file as `- docs/hooks/checkly_badges.py`
import re
def on_page_markdown(markdown, page, config, **kwargs):
check_ids = page.meta.get("checkly")
if check_ids:
# Access the nested configuration for Checkly badges
checkly_config = config["extra"].get("checkly_badges", {})
badge_style = checkly_config.get("style", "flat")
theme = checkly_config.get("theme", "light")
@lmmx
lmmx / response_error_handler_concise.py
Created January 24, 2024 18:43
Tidy away structured exception handling into a context manager
from contextlib import contextmanager
@contextmanager
def exception_handler(response_dict, source=""):
try:
# Before yield is equivalent to the code in __enter__ method
yield
except Exception as exc:
# After yield is equivalent to the code in __exit__ method