Versions

  • v18

    7/27/2024
    Open: Version
    Changes from v17 to v18
    +2
    -1
    ⦚ 38 unchanged lines ⦚
    if (word.length < 3) return Response.json({ error: "too short" });
    if (word.length > 20) return Response.json({ error: "too long" });
    }

    ⦚ 112 unchanged lines ⦚
    ⦚ 38 unchanged lines ⦚
    if (word.length < 3) return Response.json({ error: "too short" });
    if (word.length > 20) return Response.json({ error: "too long" });

    return Response.json({ todo: "tk" });
    }

    ⦚ 112 unchanged lines ⦚
  • v17

    7/27/2024
    Open: Version
    Changes from v16 to v17
    +13
    -2
    ⦚ 4 unchanged lines ⦚
    /**
    * New API:
    * POST /clue { word } => { word, clue, taboo } ~~GameTurn
    * - fetch taboo words from chatAPI
    * - parse taboo words
    ⦚ 18 unchanged lines ⦚
    }

    return chatAPI(req);
    }

    ⦚ 112 unchanged lines ⦚
    ⦚ 4 unchanged lines ⦚
    /**
    * New API:
    * POST / { word } => { word, clue, taboo } ~~GameTurn
    * - fetch taboo words from chatAPI
    * - parse taboo words
    ⦚ 18 unchanged lines ⦚
    }

    return await getClue(req);

    // return chatAPI(req);
    }

    export async function getClue (req: Request): Promise<Response> {
    const body = await req.json();
    const { word } = body;
    if (!word) return Response.json({ error: "Requires word" });
    if (word.length < 3) return Response.json({ error: "too short" });
    if (word.length > 20) return Response.json({ error: "too long" });
    }

    ⦚ 112 unchanged lines ⦚
  • v16

    7/27/2024
    Open: Version
    Changes from v15 to v16
    +8
    -0
    import chatAPI from "https://esm.town/v/jxnblk/motherChat";

    const LENGTH = 128;

    export default async function telephoneAPI(req: Request): Promise<Response> {
    const url = new URL(req.url);
    ⦚ 130 unchanged lines ⦚
    import chatAPI from "https://esm.town/v/jxnblk/motherChat";

    const LENGTH = 128;

    /**
    * New API:
    * POST /clue { word } => { word, clue, taboo } ~~GameTurn
    * - fetch taboo words from chatAPI
    * - parse taboo words
    * - fetch clue
    * - UI can refetch to get a different clue
    */
    export default async function telephoneAPI(req: Request): Promise<Response> {
    const url = new URL(req.url);
    ⦚ 130 unchanged lines ⦚
  • v15

    7/27/2024
    Open: Version
    Changes from v14 to v15
    +12
    -3
    ⦚ 121 unchanged lines ⦚
    }

    export type Message = {
    role: string;
    content: string;
    }
    ⦚ 121 unchanged lines ⦚
    }

    type Message = {
    role: "system" | "user" | "assistant" | null;
    content: string;
    }

    type GameTurn = {
    word: string;
    clue: string;
    taboo: string[];
    guess: string;
    }

    type GameHistory = GameTurn[];
  • v14

    7/27/2024
    Open: Version
    Changes from v13 to v14
    +5
    -0
    ⦚ 120 unchanged lines ⦚
    return last.clue || "";
    }

    ⦚ 120 unchanged lines ⦚
    return last.clue || "";
    }

    export type Message = {
    role: string;
    content: string;
    }
  • v13

    7/27/2024
    Open: Version
    Changes from v12 to v13
    +88
    -1
    import chatAPI from "https://esm.town/v/jxnblk/motherChat";

    export default async function telephoneAPI(req: Request): Promise<Response> {
    const url = new URL(req.url);
    ⦚ 28 unchanged lines ⦚
    const { encode } = await import("https://esm.town/v/jxnblk/comp");
    return encode(str);
    }
    import chatAPI from "https://esm.town/v/jxnblk/motherChat";

    const LENGTH = 128;

    export default async function telephoneAPI(req: Request): Promise<Response> {
    const url = new URL(req.url);
    ⦚ 28 unchanged lines ⦚
    const { encode } = await import("https://esm.town/v/jxnblk/comp");
    return encode(str);
    }

    const seed = [
    {
    role: "system",
    content: `
    You are playing a game like Taboo and have to provide a riddle where the answer is a single word.
    You cannot use the word itself or similar words that would make it easy to guess what the word is.
    Each description should be ${LENGTH} characters or less.
    `,
    // TODO: test out jeopardy rules?
    },
    ];

    function createTabooPrompt(words: string) {
    const word = words.trim();
    if (word.length < 3) return { error: "too short" };
    if (word.length > 20) return { error: "too long" };
    // no spaces??

    return {
    prompt: `List 20-30 words similar to the word: "${word}",
    5-10 words that mean the same thing as "${word}",
    and 5 or more words that are descriptive of what type of thing the word is.
    If the word is a compound word, include the words that make up the compound word.
    List all words in singular and plural form.
  • v12

    7/21/2024
    Open: Version
    Changes from v11 to v12
    +2
    -2
    ⦚ 6 unchanged lines ⦚
    case "/encode":
    const b1 = await req.text();
    const hash = encode(b1);
    console.log({ hash });
    return Response.json({ ok: true, body: hash });
    case "/decode":
    const b2 = await req.text();
    console.log(b2);
    const str = decode(b2);
    console.log(str);
    return Response.json({ ok: true, body: str });
    ⦚ 18 unchanged lines ⦚
    ⦚ 6 unchanged lines ⦚
    case "/encode":
    const b1 = await req.text();
    const hash = await encode(b1);
    console.log({ hash });
    return Response.json({ ok: true, body: hash });
    case "/decode":
    const b2 = await req.text();
    console.log(b2);
    const str = await decode(b2);
    console.log(str);
    return Response.json({ ok: true, body: str });
    ⦚ 18 unchanged lines ⦚
  • v11

    7/21/2024
    Open: Version
    Changes from v10 to v11
    +1
    -0
    ⦚ 7 unchanged lines ⦚
    const b1 = await req.text();
    const hash = encode(b1);
    return Response.json({ ok: true, body: hash });
    case "/decode":
    const b2 = await req.text();
    ⦚ 22 unchanged lines ⦚
    ⦚ 7 unchanged lines ⦚
    const b1 = await req.text();
    const hash = encode(b1);
    console.log({ hash });
    return Response.json({ ok: true, body: hash });
    case "/decode":
    const b2 = await req.text();
    ⦚ 22 unchanged lines ⦚
  • v10

    7/21/2024
    Open: Version
    +34
    -0

    import chatAPI from "https://esm.town/v/jxnblk/motherChat";

    export default async function telephoneAPI(req: Request): Promise<Response> {
    const url = new URL(req.url);

    switch (url.pathname) {
    case "/encode":
    const b1 = await req.text();
    const hash = encode(b1);
    return Response.json({ ok: true, body: hash });
    case "/decode":
    const b2 = await req.text();
    console.log(b2);
    const str = decode(b2);
    console.log(str);
    return Response.json({ ok: true, body: str });
    }

    return chatAPI(req);
    }

    export async function decode(hash: string): Promise<string> {
    const { decode } = await import("https://esm.town/v/jxnblk/comp");
    try {
    return decode(hash);
    } catch (e) {
    return e.toString();
    }
    }

    export async function encode(str: string): Promise<string> {
    const { encode } = await import("https://esm.town/v/jxnblk/comp");
    return encode(str);
    }
Updated: August 13, 2024