Developer docs · Browse & search
BUILD
Knowledge
Collections of documents agents search: upload, index, bind to an agent or add to one run.
A collection holds documents agents can search. Upload text, Markdown or JSON, up to 10 MiB each, and it's indexed by itself:
ts
const policies = await jwtson.knowledge.ensure({ name: 'Policies' });
const doc = await policies.upload('leave.md', markdown, { metadata: { team: 'people' } });
await doc.indexed(); // searchable from here
await policies.search('parental leave', { topK: 3 }); // the search a run does, as you
await doc.delete();Give an agent collections by name, and they're bound when it's published, so every run of that version searches the same ones. One run can search more on top:
ts
const helper = await jwtson.agents.ensure({ name: 'HR helper', instructions: 'Answer from the policies.', knowledge: ['Policies'] });
await helper.run('How long is parental leave?', { knowledge: ['Benefits'] });An upload under the same idempotencyKey adds the document once. A collection itself isn't removed, only its documents.
From the @jwtson/sdk README, as the code stands.