Skip to content

Instantly share code, notes, and snippets.

View boxabirds's full-sized avatar

Julian Harris boxabirds

View GitHub Profile
@boxabirds
boxabirds / estimator.js
Created October 22, 2024 20:50
Google Gemini cost estimator (node)
const {GoogleGenerativeAI} = require('@google/generative-ai');
/**
* Estimates the cost of a Gemini API invocation based on token usage.
*
* @param {Object} usageMetadata - The usage metadata from the API response.
* @param {number} usageMetadata.promptTokenCount - The number of tokens in the input prompt.
* @param {number} usageMetadata.candidatesTokenCount - The number of tokens in the output.
* @returns {number} The estimated cost of the invocation in USD.
*
* Pricing information:
@boxabirds
boxabirds / img2alt.py
Created August 6, 2024 12:15
Generate alt tags for images (using llava)
import os
import requests
from bs4 import BeautifulSoup
import argparse
import base64
import json
def download_image(url, save_path):
response = requests.get(url)
if response.status_code == 200:
@boxabirds
boxabirds / main.go
Created June 22, 2024 19:52
Whisper.cpp go demo
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
whisper "github.com/ggerganov/whisper.cpp/bindings/go"
)
@boxabirds
boxabirds / openai-fixed-seed-demo.go
Created May 28, 2024 11:15
Demo of how fixing the seed with OpenAI's API gives deterministic results.
// Demo of how you can fix the seed with OpenAI and you'll get deterministic output.
// this is only for a given system fingerprint
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
@boxabirds
boxabirds / image-captioning-ollama-llava.go
Created May 26, 2024 22:08
Demo of using ollama + llava to create extremely detailed image captions from an image
// this is a demo that connects to ollama and
// Prerequisites:
// - ollama
// - open weights model "llava" 1.6 or greater
package main
import (
"bytes"
"encoding/base64"
"encoding/json"
@boxabirds
boxabirds / summarise-text-gemini.go
Created May 24, 2024 11:42
Summarise large documents in go using Google Gemini Flash
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
"time"
@boxabirds
boxabirds / upscale-imgurl-claude.go
Created May 23, 2024 09:14
Sample of how you can use an LLM instead of a bunch of regexes.
package main
import (
"bufio"
"context"
"flag"
"fmt"
"log"
"os"
@boxabirds
boxabirds / summariser-ollama-openai.go
Last active May 22, 2024 11:36
Use Ollama to run an AI summariser on your machine for free
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"os"
"time"
@boxabirds
boxabirds / main.go
Created May 21, 2024 12:00
Demo of how to create a summariser using golang and Anthropic Claude.
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"os"
"time"

Objective: Create an interactive, two player, web-based game that is a hybrid of poker and chess rules. Use SVG graphics for any pieces or cards used and use popular animation and interaction libraries for visual appeal.

======================================== Task Breakdown ========================================

Task 1: Prompt: The objective has not been fully achieved yet. To break it down into the next sub-task:

Sub-task: Outline the core gameplay mechanics and rules for a two-player game that combines elements of poker and chess. Specify how turns progress, what actions players can take, the win conditions, and any unique twists that blend the two games together in an engaging way.

Prompt for subagent: Please create a detailed outline of the gameplay mechanics and rules for an original two-player game that merges elements from both poker and chess. Explain how the game is set up, what actions players can take on their turns, and how a player wins the game. Describe any unique features or twists t