Skip to content

Commit

Permalink
docs: minor improvement to README and fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
iislucas committed Oct 27, 2024
1 parent 0cf6336 commit 53374be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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"
}
}

0 comments on commit 53374be

Please sign in to comment.