Skip to content

Instantly share code, notes, and snippets.

@jawond
jawond / DragDrop.js
Created November 12, 2020 07:39 — forked from mikkokaar/DragDrop.js
react-beautiful-dnd wrapper to add payloads and callback support on droppables
import React from "react"
import { DragDropContext as DragDropContext_, Droppable as Droppable_, Draggable as Draggable_ } from "react-beautiful-dnd"
// Maps
const draggableMap = {}
const droppableMap = {}
@jawond
jawond / bash-gpt.bash
Created April 9, 2023 02:21 — forked from shikaan/bash-gpt.bash
bash GPT
#!/bin/bash
OPENAI_API_KEY="YOUR_API_KEY"
CONVERSATION="/tmp/$(cat /proc/sys/kernel/random/uuid)"
query_open_ai() {
curl -s https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d "{
@jawond
jawond / claude_3.5_sonnet_artifacts.xml
Created June 25, 2024 21:54 — forked from dedlim/claude_3.5_sonnet_artifacts.xml
Claude 3.5 Sonnet, Full Artifacts System Prompt
<artifacts_info>
The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity.
# Good artifacts are...
- Substantial content (>15 lines)
- Content that the user is likely to modify, iterate on, or take ownership of
- Self-contained, complex content that can be understood on its own, without context from the conversation
- Content intended for eventual use outside the conversation (e.g., reports, emails, presentations)
- Content likely to be referenced or reused multiple times
@jawond
jawond / README_MINIMAL_PROMPT_CHAINABLE.md
Created July 1, 2024 21:06 — forked from disler/README_MINIMAL_PROMPT_CHAINABLE.md
Minimal Prompt Chainable for zero library sequential prompt chaining

Minimal Prompt Chainable

Sequential prompt chaining in one method with context and output back-referencing.

Files

  • main.py - start here - full example using MinimalChainable from chain.py to build a sequential prompt chian
  • chain.py - contains zero library minimal prompt chain class
  • chain_test.py - tests for chain.py, you can ignore this
  • requirements.py - python requirements

Setup

@jawond
jawond / dom3d.js
Created July 2, 2024 23:21 — forked from OrionReed/dom3d.js
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯

MLX LM with the OpenAI Python Package

1. Install

Install MLX LM and openai:

pip install mlx-lm openai
# --------------------------------------------------------------
# Customer Support Ticket Classification System
# --------------------------------------------------------------
import instructor
from pydantic import BaseModel, Field
from openai import OpenAI
from enum import Enum
from typing import List
@jawond
jawond / l3min.py
Created August 9, 2024 22:52 — forked from awni/l3min.py
"""
A minimal, fast example generating text with Llama 3.1 in MLX.
To run, install the requirements:
pip install -U mlx transformers fire
Then generate text with:
python l3min.py "How tall is K2?"

Clone the model

This can take a little while:

# Make sure you have git-lfs installed (https://git-lfs.com)
git lfs install

git clone https://huggingface.co/black-forest-labs/FLUX.1-schnell
@jawond
jawond / llm_factory.py
Created August 18, 2024 23:09 — forked from daveebbelaar/llm_factory.py
LLM Factory with Instructor
from typing import Any, Dict, List, Type
import instructor
from anthropic import Anthropic
from config.settings import get_settings
from openai import OpenAI
from pydantic import BaseModel, Field
class LLMFactory: