Skip to content

Instantly share code, notes, and snippets.

View BLamy's full-sized avatar

Brett Lamy BLamy

View GitHub Profile
Title: Electron 22.0.0
URL Source: https://www.electronjs.org/blog/electron-22-0
Published Time: 2022-11-29T00:00:00.000Z
Markdown Content:
Electron 22.0.0 has been released! It includes a new utility process API, updates for Windows 7/8/8.1 support, and upgrades to Chromium `108`, V8 `10.8`, and Node.js `16.17.1`. Read below for more details!
* * *
@BLamy
BLamy / gmail-openapi.json
Created October 6, 2023 21:31
gmail-openapi.json
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "Gmail API"
},
"paths": {
"/gmail/v1/users/{userId}/threads": {
"get": {
"summary": "Lists the threads in the user's mailbox.",
@BLamy
BLamy / Permissions.ts
Last active July 29, 2023 00:35
Typescript Permission System
// https://tsplay.dev/w2kJrN
import { Brand } from 'ts-brand'
import { z } from 'zod'
//------------------------------------------------
// Permission Levels
enum PermissionLevelEnum {
OWNER_ONLY = "OWNER_ONLY",
COMPANY_ONLY = "COMPANY_ONLY",
PUBLIC = "PUBLIC",
@BLamy
BLamy / ChatBuilder.ts
Last active May 16, 2023 21:00
Typesafe Chat Builder
class Prompt<
TPromptTemplate extends string,
TSuppliedInputArgs extends ExtractArgs<TPromptTemplate, {}>
> {
constructor(
public template: TPromptTemplate,
public args: TSuppliedInputArgs
) {}
toString() {
@BLamy
BLamy / PromptBuilder.ts
Last active May 15, 2023 20:41
Typesafe prompt builder no dependencies
class Prompt<
TPromptTemplate extends string,
SuppliedInputArgs extends ExtractArgs<TPromptTemplate, {}>
> {
constructor(
public template: TPromptTemplate,
public args: SuppliedInputArgs
) {}
get text() {
const messages = [
system(`this is a system message
It will end up typed as a literal because It is called as a function
`),
user`typed as
a string This`,
assistant(`
will also
Act as a JSON API, processing valid JSON input and returning valid JSON output. Don't add extra characters. You'll work with a typescript file containing 5 types: Prompt, Input, Output, Errors, and Tools. Handle invalid JSON or type mismatches gracefully, returning error messages in the correct format. Perform actions in the Prompt and return results in the Output format.
@BLamy
BLamy / NFLScoresPrompt.ts
Last active April 12, 2023 08:41
NFLScoresPrompt - no zod
// You will function as a JSON api.
// The user will feed you valid JSON and you will return valid JSON, do not add any extra characters to the output that would make your output invalid JSON.
// The end of this system message will contain a typescript file that exports 5 types:
// Prompt - String literal will use double curly braces to denote a variable.
// Input - The data the user feeds you must strictly match this type.
// Output - The data you return to the user must strictly match this type.
// Errors - A union type that you will classify any errors you encounter into.
// Tools - If you do not know the answer, Do not make anything up, Use a tool. To use a tool pick one from the Tools union and print a valid json object in that format.
@BLamy
BLamy / NFLScoresPrompt.ts
Last active June 15, 2023 23:07
An Example of file that functions as both a typescript module and a GPT4 prompt.
// You will function as a JSON api.
// The user will feed you valid JSON and you will return valid JSON, do not add any extra characters to the output that would make your output invalid JSON.
// The end of this system message will contain a typescript file that exports 5 types:
// Prompt - String literal will use double curly braces to denote a variable.
// Input - The data the user feeds you must strictly match this type.
// Output - The data you return to the user must strictly match this type.
// Errors - A union type that you will classify any errors you encounter into.
// Tools - If you do not know the answer, Do not make anything up, Use a tool. To use a tool pick one from the Tools union and print a valid json object in that format.
@BLamy
BLamy / exportPrompt.js
Created March 12, 2023 02:51
Export prompt from open ai playground
[...document.querySelectorAll(
".text-input[placeholder='You are a helpful assistant.'], .text-input[placeholder='Enter a user message here.'], .text-input[placeholder='Enter an assistant message here.']"
)].map(x => ({
role: x.attributes.header ? x.attributes.header.nodeValue : "system",
content: x.value
}))