From 1c8910601e053567486a1088229a3a7877523d89 Mon Sep 17 00:00:00 2001 From: "Lucas Dixon (iislucas)" Date: Sun, 27 Oct 2024 15:05:13 +0100 Subject: [PATCH 1/2] docs: minor improvement to README and fix deps --- README.md | 11 ++++++++--- package.json | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dad7a4e..089384a 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,18 @@ template. For example: ```ts +import { nv, template } from 'ts-llmt'; + const thingVar = nv('thing'); const thing2Var = nv('thing2'); -const whatIsAtoB = template`what is a ${thingVar} to ${thing2Var}?`; +// The type of `whatIsAtoB` is inferred to be `Template<"thing" | "thing2">` +const whatIsAtoB = template`what is a ${thingVar} to a ${thing2Var}?`; +// Replacing the thing variable give type: `Template<"thing2">` const whatIsTabletoB = whatIsAtoB.vars.thing.substStr('table'); -expect(whatIsTabletoB.escaped).toEqual('what is a table to {{thing2}}?'); +// The escaped raw form of this template is as so: +expect(whatIsTabletoB.escaped).toEqual('what is a table to a {{thing2}}?'); ``` A nice feature of this is that you get as "as-you-type" error checking, and @@ -30,7 +35,7 @@ type-checking like so: ```ts whatIsAtoB.substs({ thing: 'table', thing2: 'chair' }); -expect(whatIsTabletoB.escaped).toEqual('what is a table to chair?'); +expect(whatIsTabletoB.escaped).toEqual('what is a table to a chair?'); ``` ## Environment diff --git a/package.json b/package.json index ed89304..94beeed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-llmt", - "version": "0.0.2", + "version": "0.0.0", "description": "Experimental TypeScript library for Large Language Model Templates", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -53,10 +53,10 @@ "ts-jest": "^29.1.3", "ts-node": "^10.9.2", "typescript-eslint": "^7.10.0", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "typescript": "^5.4.5" }, "dependencies": { - "underscore": "^1.13.6", - "typescript": "^5.4.5" + "underscore": "^1.13.6" } } \ No newline at end of file From 53374be25bbe6a814f76a14c3666b157fba8b20c Mon Sep 17 00:00:00 2001 From: "Lucas Dixon (iislucas)" Date: Sun, 27 Oct 2024 15:05:13 +0100 Subject: [PATCH 2/2] docs: minor improvement to README and fix deps --- README.md | 11 ++++++++--- package.json | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index dad7a4e..089384a 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,18 @@ template. For example: ```ts +import { nv, template } from 'ts-llmt'; + const thingVar = nv('thing'); const thing2Var = nv('thing2'); -const whatIsAtoB = template`what is a ${thingVar} to ${thing2Var}?`; +// The type of `whatIsAtoB` is inferred to be `Template<"thing" | "thing2">` +const whatIsAtoB = template`what is a ${thingVar} to a ${thing2Var}?`; +// Replacing the thing variable give type: `Template<"thing2">` const whatIsTabletoB = whatIsAtoB.vars.thing.substStr('table'); -expect(whatIsTabletoB.escaped).toEqual('what is a table to {{thing2}}?'); +// The escaped raw form of this template is as so: +expect(whatIsTabletoB.escaped).toEqual('what is a table to a {{thing2}}?'); ``` A nice feature of this is that you get as "as-you-type" error checking, and @@ -30,7 +35,7 @@ type-checking like so: ```ts whatIsAtoB.substs({ thing: 'table', thing2: 'chair' }); -expect(whatIsTabletoB.escaped).toEqual('what is a table to chair?'); +expect(whatIsTabletoB.escaped).toEqual('what is a table to a chair?'); ``` ## Environment diff --git a/package.json b/package.json index ed89304..94beeed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ts-llmt", - "version": "0.0.2", + "version": "0.0.0", "description": "Experimental TypeScript library for Large Language Model Templates", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -53,10 +53,10 @@ "ts-jest": "^29.1.3", "ts-node": "^10.9.2", "typescript-eslint": "^7.10.0", - "yargs": "^17.7.2" + "yargs": "^17.7.2", + "typescript": "^5.4.5" }, "dependencies": { - "underscore": "^1.13.6", - "typescript": "^5.4.5" + "underscore": "^1.13.6" } } \ No newline at end of file