News for hackers. Stuff that matters.
Re:Show HN: MonkeyPatch – Cheap, fast and predictable LLM fu... by whoiskatrin on Wednesday November 15, 2023 @01:30PM (#38280403)
Would love to try a typescript implementation. Any plans to do that?
Re:Show HN: MonkeyPatch – Cheap, fast and predictable LLM fu... by JackHopkins on Wednesday November 15, 2023 @01:53PM (#38280730)
Great to know! We're working on extending MonkeyPatch to typescript, the work-in-progress repository can be found here https://github.com/monkeypatch/monkey-patch.ts

We will keep you posted on when it'll be ready for trying out!

Re:Show HN: MonkeyPatch – Cheap, fast and predictable LLM fu... by jumploops on Wednesday November 15, 2023 @06:45PM (#38284015)
I built a similar library for Typescript: https://github.com/jumploops/magic

Please note: it requires the use of ttypescript or ts-patch, as Typescript transformers aren’t supported by default!

Re:Show HN: MonkeyPatch – Cheap, fast and predictable LLM fu... by JackHopkins on Wednesday November 15, 2023 @07:06PM (#38284197)
Cool! Thanks for sharing. What do you mean that Ts transformers aren’t supported by default? Is this like a runtime modification of types?
Re:Show HN: MonkeyPatch – Cheap, fast and predictable LLM fu... by jumploops on Saturday November 18, 2023 @08:47PM (#38327448)
tl;dr - TypeScript transformers are used to modify the AST before Javascript is emitted.

The magic functions library uses a transformer to take the TypeScript types and port them to JSON schema, such that they're available during runtime. This JSON schema is then used to validate that the response from the LLM matches the expected type signature of the function (and err if it doesn't).

Because TypeScript doesn't support 3rd party "transformers" by default, you're forced to hack around it (via ttypescript or ts-patch). This is especially problematic when TypeScript has a major version change, as the workarounds need to be modified accordingly; this often takes significant time.

Here's the long-lived Github issue: https://github.com/microsoft/TypeScript/issues/14419

And here's the newest proposal to add official support: https://github.com/microsoft/TypeScript/issues/54276