teckel-ai 0.3.2 → 0.3.5
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 +39 -31
- package/dist/{schemas.d.ts → index.d.mts} +192 -20
- package/dist/index.d.ts +386 -7
- package/dist/index.js +2 -22
- package/dist/index.mjs +2 -0
- package/package.json +23 -12
- package/dist/conversation.d.ts +0 -64
- package/dist/conversation.js +0 -363
- package/dist/schemas.js +0 -69
- package/dist/tracer.d.ts +0 -18
- package/dist/tracer.js +0 -45
- package/dist/types.d.ts +0 -88
- package/dist/types.js +0 -6
package/README.md
CHANGED
|
@@ -1,53 +1,61 @@
|
|
|
1
1
|
# teckel-ai
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript/JavaScript SDK for [Teckel AI](https://teckel.ai)- Get insight into your AI systems, track topics of your choosing, and identify and fix knowledge gaps.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install teckel-ai
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
**
|
|
11
|
+
**Requirements:** Node.js 18+ (or Bun, Deno, serverless runtimes)
|
|
10
12
|
|
|
11
|
-
##
|
|
13
|
+
## Quick Start
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
```typescript
|
|
16
|
+
import { TeckelTracer } from 'teckel-ai';
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
// Initialize once at startup
|
|
19
|
+
const tracer = new TeckelTracer({
|
|
20
|
+
apiKey: process.env.TECKEL_API_KEY
|
|
21
|
+
});
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
// In your API handler
|
|
24
|
+
async function handleChat(userQuestion: string, sessionId: string) {
|
|
25
|
+
const conversation = tracer.start({ sessionRef: sessionId });
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
// Your existing RAG logic
|
|
28
|
+
const chunks = await vectorDB.search(userQuestion);
|
|
29
|
+
const answer = await llm.generate(userQuestion, chunks);
|
|
23
30
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
// Send trace (non-blocking)
|
|
32
|
+
conversation.trace({
|
|
33
|
+
query: userQuestion,
|
|
34
|
+
response: answer,
|
|
35
|
+
documents: chunks.map((chunk, i) => ({
|
|
36
|
+
documentRef: chunk.id,
|
|
37
|
+
documentName: chunk.title,
|
|
38
|
+
documentText: chunk.content,
|
|
39
|
+
}))
|
|
40
|
+
});
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
// For serverless: flush before returning
|
|
43
|
+
await conversation.flush();
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
return answer;
|
|
46
|
+
}
|
|
47
|
+
```
|
|
34
48
|
|
|
35
|
-
##
|
|
49
|
+
## Documentation
|
|
36
50
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
- An LLM-based application (RAG system, chatbot, AI agent)
|
|
51
|
+
- **Full SDK Reference:** [docs.teckel.ai/docs/typescript-sdk-reference](https://docs.teckel.ai/docs/typescript-sdk-reference)
|
|
52
|
+
- **Getting Started:** [docs.teckel.ai/docs/getting-started](https://docs.teckel.ai/docs/getting-started)
|
|
40
53
|
|
|
41
54
|
## Support
|
|
42
55
|
|
|
43
|
-
- **
|
|
44
|
-
- **
|
|
45
|
-
- **Email**: support@teckel.ai
|
|
56
|
+
- **Email:** support@teckel.ai
|
|
57
|
+
- **Website** [teckel.ai](https://teckel.ai)
|
|
46
58
|
|
|
47
59
|
## License
|
|
48
60
|
|
|
49
61
|
MIT
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
Version 0.3.2
|
|
@@ -1,11 +1,178 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Type definitions for teckel-ai SDK v0.3.5
|
|
5
|
+
* Simple, clean types matching existing database schema
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
/**
|
|
8
|
+
* SDK Configuration
|
|
9
|
+
*/
|
|
10
|
+
interface TeckelConfig {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Conversation options
|
|
18
|
+
* sessionRef IS the conversation identifier
|
|
19
|
+
*
|
|
20
|
+
* Naming convention:
|
|
21
|
+
* - *Ref = Client-provided identifier (TEXT)
|
|
22
|
+
* - *Id = Server-generated internal ID (UUID)
|
|
23
|
+
*/
|
|
24
|
+
interface ConversationOptions {
|
|
25
|
+
sessionRef?: string;
|
|
26
|
+
userRef?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Document structure for RAG systems
|
|
31
|
+
* Matches existing documents + chunk_events schema
|
|
32
|
+
*/
|
|
33
|
+
interface Document {
|
|
34
|
+
documentRef: string;
|
|
35
|
+
documentName: string;
|
|
36
|
+
documentText: string;
|
|
37
|
+
documentLastUpdated?: string;
|
|
38
|
+
sourceUri?: string;
|
|
39
|
+
sourceType?: string;
|
|
40
|
+
similarity?: number;
|
|
41
|
+
rank?: number;
|
|
42
|
+
ownerEmail?: string;
|
|
43
|
+
documentType?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Token usage tracking
|
|
47
|
+
*/
|
|
48
|
+
interface TokenUsage {
|
|
49
|
+
prompt: number;
|
|
50
|
+
completion: number;
|
|
51
|
+
total: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Trace data for a single query-response interaction
|
|
55
|
+
* Matches existing traces table schema
|
|
56
|
+
*/
|
|
57
|
+
interface TraceData {
|
|
58
|
+
query: string;
|
|
59
|
+
response: string;
|
|
60
|
+
model?: string;
|
|
61
|
+
responseTimeMs?: number;
|
|
62
|
+
documents?: Document[];
|
|
63
|
+
tokens?: TokenUsage;
|
|
64
|
+
metadata?: Record<string, unknown>;
|
|
65
|
+
traceRef?: string;
|
|
66
|
+
userRef?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Feedback types
|
|
70
|
+
*/
|
|
71
|
+
type FeedbackType = 'thumbs_up' | 'thumbs_down' | 'flag' | 'rating';
|
|
72
|
+
/**
|
|
73
|
+
* User feedback signal
|
|
74
|
+
*/
|
|
75
|
+
interface FeedbackData {
|
|
76
|
+
type: FeedbackType;
|
|
77
|
+
value?: string;
|
|
78
|
+
comment?: string;
|
|
79
|
+
traceRef?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Result returned when a trace is created
|
|
83
|
+
*/
|
|
84
|
+
interface TraceResult {
|
|
85
|
+
traceRef: string;
|
|
86
|
+
turnNumber: number;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Conversation class for teckel-ai SDK v0.3.5
|
|
91
|
+
* Manages a single conversation with fire-and-forget semantics
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
/** Internal type - sessionRef is guaranteed by TeckelTracer.start() */
|
|
95
|
+
interface ResolvedConversationOptions extends ConversationOptions {
|
|
96
|
+
sessionRef: string;
|
|
97
|
+
}
|
|
98
|
+
declare class Conversation {
|
|
99
|
+
private readonly apiKey;
|
|
100
|
+
private readonly endpoint;
|
|
101
|
+
private readonly sessionRef;
|
|
102
|
+
private readonly userRef?;
|
|
103
|
+
private readonly metadata?;
|
|
104
|
+
private readonly startedAt;
|
|
105
|
+
private readonly debug;
|
|
106
|
+
private readonly timeoutMs;
|
|
107
|
+
private turnCount;
|
|
108
|
+
private startPromise;
|
|
109
|
+
private sendQueue;
|
|
110
|
+
constructor(apiKey: string, endpoint: string, options: ResolvedConversationOptions, debug?: boolean, extras?: {
|
|
111
|
+
timeoutMs: number;
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Record a trace (single query-response interaction)
|
|
115
|
+
* Fire-and-forget by default - never blocks
|
|
116
|
+
* For serverless, call flush() before function termination
|
|
117
|
+
*/
|
|
118
|
+
trace(data: TraceData): TraceResult | void;
|
|
119
|
+
/**
|
|
120
|
+
* Add user feedback signal
|
|
121
|
+
* Never throws - gracefully handles errors
|
|
122
|
+
*/
|
|
123
|
+
feedback(data: FeedbackData): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* End the conversation
|
|
126
|
+
* Flushes all pending traces before sending end signal
|
|
127
|
+
* Never throws - gracefully handles errors
|
|
128
|
+
*/
|
|
129
|
+
end(): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Read-only properties
|
|
132
|
+
*/
|
|
133
|
+
get id(): string;
|
|
134
|
+
get turns(): number;
|
|
135
|
+
get started(): Date;
|
|
136
|
+
private fetchWithRetry;
|
|
137
|
+
private _startConversation;
|
|
138
|
+
private _sendTrace;
|
|
139
|
+
private _sendFeedback;
|
|
140
|
+
private _endConversation;
|
|
141
|
+
private enqueueSend;
|
|
142
|
+
/**
|
|
143
|
+
* Flush queued sends with a bounded timeout.
|
|
144
|
+
* Returns when the queue is empty or the timeout elapses (whichever comes first).
|
|
145
|
+
*/
|
|
146
|
+
flush(timeoutMs?: number): Promise<void>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* TeckelTracer - Main SDK class for teckel-ai v0.3.5
|
|
151
|
+
* Simple, lightweight SDK for AI conversation tracking
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
declare class TeckelTracer {
|
|
155
|
+
private readonly apiKey;
|
|
156
|
+
private readonly endpoint;
|
|
157
|
+
private readonly debug;
|
|
158
|
+
private readonly timeoutMs;
|
|
159
|
+
constructor(config: TeckelConfig);
|
|
160
|
+
/**
|
|
161
|
+
* Start a new conversation
|
|
162
|
+
* sessionRef IS the public conversation identifier
|
|
163
|
+
* If not provided, auto-generates one as 'auto:{8-char-uuid}'
|
|
164
|
+
*/
|
|
165
|
+
start(options?: ConversationOptions): Conversation;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Zod validation schemas for teckel-ai SDK v0.3.5
|
|
170
|
+
*/
|
|
171
|
+
|
|
5
172
|
/**
|
|
6
173
|
* Document schema
|
|
7
174
|
*/
|
|
8
|
-
|
|
175
|
+
declare const DocumentSchema: z.ZodObject<{
|
|
9
176
|
documentRef: z.ZodString;
|
|
10
177
|
documentName: z.ZodString;
|
|
11
178
|
documentText: z.ZodString;
|
|
@@ -42,7 +209,7 @@ export declare const DocumentSchema: z.ZodObject<{
|
|
|
42
209
|
/**
|
|
43
210
|
* Token usage schema
|
|
44
211
|
*/
|
|
45
|
-
|
|
212
|
+
declare const TokenUsageSchema: z.ZodObject<{
|
|
46
213
|
prompt: z.ZodNumber;
|
|
47
214
|
completion: z.ZodNumber;
|
|
48
215
|
total: z.ZodNumber;
|
|
@@ -58,7 +225,7 @@ export declare const TokenUsageSchema: z.ZodObject<{
|
|
|
58
225
|
/**
|
|
59
226
|
* Trace data schema
|
|
60
227
|
*/
|
|
61
|
-
|
|
228
|
+
declare const TraceDataSchema: z.ZodObject<{
|
|
62
229
|
query: z.ZodString;
|
|
63
230
|
response: z.ZodString;
|
|
64
231
|
model: z.ZodOptional<z.ZodString>;
|
|
@@ -110,8 +277,9 @@ export declare const TraceDataSchema: z.ZodObject<{
|
|
|
110
277
|
completion: number;
|
|
111
278
|
total: number;
|
|
112
279
|
}>>;
|
|
113
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
280
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
114
281
|
traceRef: z.ZodOptional<z.ZodString>;
|
|
282
|
+
userRef: z.ZodOptional<z.ZodString>;
|
|
115
283
|
}, "strip", z.ZodTypeAny, {
|
|
116
284
|
query: string;
|
|
117
285
|
response: string;
|
|
@@ -134,8 +302,9 @@ export declare const TraceDataSchema: z.ZodObject<{
|
|
|
134
302
|
completion: number;
|
|
135
303
|
total: number;
|
|
136
304
|
} | undefined;
|
|
137
|
-
metadata?: Record<string,
|
|
305
|
+
metadata?: Record<string, unknown> | undefined;
|
|
138
306
|
traceRef?: string | undefined;
|
|
307
|
+
userRef?: string | undefined;
|
|
139
308
|
}, {
|
|
140
309
|
query: string;
|
|
141
310
|
response: string;
|
|
@@ -158,29 +327,30 @@ export declare const TraceDataSchema: z.ZodObject<{
|
|
|
158
327
|
completion: number;
|
|
159
328
|
total: number;
|
|
160
329
|
} | undefined;
|
|
161
|
-
metadata?: Record<string,
|
|
330
|
+
metadata?: Record<string, unknown> | undefined;
|
|
162
331
|
traceRef?: string | undefined;
|
|
332
|
+
userRef?: string | undefined;
|
|
163
333
|
}>;
|
|
164
334
|
/**
|
|
165
335
|
* Conversation options schema
|
|
166
336
|
*/
|
|
167
|
-
|
|
168
|
-
sessionRef: z.ZodString
|
|
169
|
-
|
|
170
|
-
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
337
|
+
declare const ConversationOptionsSchema: z.ZodObject<{
|
|
338
|
+
sessionRef: z.ZodOptional<z.ZodString>;
|
|
339
|
+
userRef: z.ZodOptional<z.ZodString>;
|
|
340
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
171
341
|
}, "strip", z.ZodTypeAny, {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
342
|
+
metadata?: Record<string, unknown> | undefined;
|
|
343
|
+
userRef?: string | undefined;
|
|
344
|
+
sessionRef?: string | undefined;
|
|
175
345
|
}, {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
346
|
+
metadata?: Record<string, unknown> | undefined;
|
|
347
|
+
userRef?: string | undefined;
|
|
348
|
+
sessionRef?: string | undefined;
|
|
179
349
|
}>;
|
|
180
350
|
/**
|
|
181
351
|
* Feedback data schema
|
|
182
352
|
*/
|
|
183
|
-
|
|
353
|
+
declare const FeedbackDataSchema: z.ZodObject<{
|
|
184
354
|
type: z.ZodEnum<["thumbs_up", "thumbs_down", "flag", "rating"]>;
|
|
185
355
|
value: z.ZodOptional<z.ZodString>;
|
|
186
356
|
comment: z.ZodOptional<z.ZodString>;
|
|
@@ -199,7 +369,7 @@ export declare const FeedbackDataSchema: z.ZodObject<{
|
|
|
199
369
|
/**
|
|
200
370
|
* Config schema
|
|
201
371
|
*/
|
|
202
|
-
|
|
372
|
+
declare const TeckelConfigSchema: z.ZodObject<{
|
|
203
373
|
apiKey: z.ZodString;
|
|
204
374
|
endpoint: z.ZodOptional<z.ZodString>;
|
|
205
375
|
debug: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -215,3 +385,5 @@ export declare const TeckelConfigSchema: z.ZodObject<{
|
|
|
215
385
|
debug?: boolean | undefined;
|
|
216
386
|
timeoutMs?: number | undefined;
|
|
217
387
|
}>;
|
|
388
|
+
|
|
389
|
+
export { Conversation, type ConversationOptions, ConversationOptionsSchema, type Document, DocumentSchema, type FeedbackData, FeedbackDataSchema, type FeedbackType, type TeckelConfig, TeckelConfigSchema, TeckelTracer, type TokenUsage, TokenUsageSchema, type TraceData, TraceDataSchema, type TraceResult };
|