Skip to content

Instantly share code, notes, and snippets.

View BLamy's full-sized avatar

Brett Lamy BLamy

View GitHub Profile
@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
}))
[
{
"role": "system",
"content": "Your goal is to extract structured information from the user's input that matches the form described below. When extracting information please make sure it matches the type information exactly. Do not add any attributes that do not appear in the schema shown below.\n\n```TypeScript\n{\n first_name: string[],\n last_name?: string\n}\n```\n\nFor Union types the output must EXACTLY match one of the members of the Union type.\n\nPlease enclose the extracted information in valid JSON with the tag name corresponding to the corresponding component ID. Make sure both the keys and the values are in double quotes and make sure to escape any quotes in the response. If you find multiple items that match the same type pick the best one. Unless the type is an array then extract all matches as a tuple. \n\nDo not make anything up everything in your JSON should be from the user input. If you cannot make a valid output from the user inputs that matches the typescript type
@BLamy
BLamy / OpenBackpacking.md
Last active May 18, 2020 01:34
Find Open Backpacking

Pick a park from

https://www.fs.usda.gov/

Navigate to the Recreation section and select that you want to do hiking then backpacking. You will be at a page that looks like this:

https://www.fs.usda.gov/activity/plumas/recreation/hiking/?recid=11182&actid=51
https://www.google.com/flights?lite=0#flt=ROC.SFO.2019-03-07.ROCJFK0DL3283~JFKSFO0DL2926*SFO.PBI.2019-03-11.SFOCLT0AA1783~CLTPBI1AA1786*PBI.ROC.2019-03-15.PBIJFK0B654~JFKROC0B6586;c:USD;e:1;a:DL;sd:1;t:f;tt:m;sp:2.USD.43300
@BLamy
BLamy / Casino.sol
Created May 30, 2018 22:40
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.19+commit.c4cbbb05.js&optimize=true&gist=
pragma solidity ^0.4.20;
contract Casino {
address public owner;
uint256 public minimumBet;
uint256 public totalBet;
uint256 public numberOfBets;
uint256 public maxAmountOfBets = 100;
address[] public players;
struct Player {