@kat-ai/sdk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +86 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @kat-ai/sdk
|
|
2
|
+
|
|
3
|
+
Primary SDK for running KAT agents.
|
|
4
|
+
|
|
5
|
+
Use `@kat-ai/sdk` on the server to run the full pipeline, stream trace data, build framework-specific responses, and work with KAT types.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @kat-ai/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
KAT expects these environment variables:
|
|
14
|
+
|
|
15
|
+
```env
|
|
16
|
+
OPENAI_API_KEY=sk-...
|
|
17
|
+
PINECONE_API_KEY=...
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { runAgent } from '@kat-ai/sdk';
|
|
24
|
+
|
|
25
|
+
const result = await runAgent({
|
|
26
|
+
message: 'My toaster T100 is not heating',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
switch (result.outcome.type) {
|
|
30
|
+
case 'answer':
|
|
31
|
+
console.log(result.outcome.answer);
|
|
32
|
+
console.log(result.outcome.citations);
|
|
33
|
+
break;
|
|
34
|
+
case 'follow_up':
|
|
35
|
+
console.log(result.outcome.question);
|
|
36
|
+
console.log(result.outcome.options);
|
|
37
|
+
break;
|
|
38
|
+
case 'blocked':
|
|
39
|
+
console.log(result.outcome.reason);
|
|
40
|
+
break;
|
|
41
|
+
case 'out_of_scope':
|
|
42
|
+
console.log(result.outcome.message);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
For multi-turn conversations, pass the previous context and intent back into the next run:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const turn1 = await runAgent({ message: 'Help with my toaster' });
|
|
51
|
+
|
|
52
|
+
const turn2 = await runAgent({
|
|
53
|
+
message: 'T100',
|
|
54
|
+
sessionId: turn1.sessionId,
|
|
55
|
+
previousContext: turn1.context,
|
|
56
|
+
previousIntent: turn1.intent,
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Common Exports
|
|
61
|
+
|
|
62
|
+
- `runAgent`, `runAgentStreaming`: high-level execution entrypoints
|
|
63
|
+
- `toChatResponse`, `toNextResponse`: adapters for standard JSON and Next.js handlers
|
|
64
|
+
- `toVercelAIResponse`, `toVercelAIStreamingResponse`: Vercel AI SDK adapters
|
|
65
|
+
- `extractCitationsFromTrace`, `toChatCitations`: citation helpers
|
|
66
|
+
- `setRuntimeConfig`, `getRuntimeConfig`: runtime configuration overrides
|
|
67
|
+
- `createPipelineContext`, `withDisambiguation`, `withPlanning`, `withExecution`: lower-level composition APIs
|
|
68
|
+
|
|
69
|
+
## Client-Safe Entry
|
|
70
|
+
|
|
71
|
+
Use `@kat-ai/sdk/client` in browser or client-component code when you only need types and stream annotation parsing:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { parseStreamAnnotation, type StreamAnnotation } from '@kat-ai/sdk/client';
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Related Packages
|
|
78
|
+
|
|
79
|
+
- `@kat-ai/react`: UI components for citations and follow-up selections
|
|
80
|
+
- `@kat-ai/cli`: scaffolding, introspection, and workflow commands
|
|
81
|
+
- `@kat-ai/eval`: layered evaluation toolkit for manifests, retrieval, and agent behavior
|
|
82
|
+
|
|
83
|
+
## Docs
|
|
84
|
+
|
|
85
|
+
- Repository: [github.com/pinecone-io/KAT](https://github.com/pinecone-io/KAT)
|
|
86
|
+
- API docs: [docs-site/docs/api](https://github.com/pinecone-io/KAT/tree/main/docs-site/docs/api)
|