@zerocost/sdk 0.10.0 → 0.12.0
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/dist/core/widget-render.d.ts +8 -0
- package/dist/index.cjs +881 -156
- package/dist/index.d.ts +15 -19
- package/dist/index.js +881 -156
- package/dist/modules/llm-data.d.ts +39 -12
- package/dist/modules/widget.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,12 @@ export interface LLMDataConfig {
|
|
|
5
5
|
apiErrors: boolean;
|
|
6
6
|
sampleRate: number;
|
|
7
7
|
}
|
|
8
|
+
type ConversationRole = 'user' | 'assistant' | 'system' | 'tool' | 'unknown';
|
|
9
|
+
interface ConversationMessage {
|
|
10
|
+
role: ConversationRole;
|
|
11
|
+
content: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
}
|
|
8
14
|
export declare class LLMDataModule {
|
|
9
15
|
private client;
|
|
10
16
|
private config;
|
|
@@ -13,27 +19,48 @@ export declare class LLMDataModule {
|
|
|
13
19
|
private clickHandler;
|
|
14
20
|
private errorHandler;
|
|
15
21
|
private fetchOriginal;
|
|
22
|
+
private mutationObserver;
|
|
23
|
+
private conversationScanTimer;
|
|
24
|
+
private isSampledSession;
|
|
25
|
+
private observedConversations;
|
|
26
|
+
private conversationCounter;
|
|
16
27
|
constructor(client: ZerocostClient);
|
|
17
|
-
/**
|
|
18
|
-
* Start capturing LLM training data based on server config.
|
|
19
|
-
*/
|
|
20
28
|
start(config: LLMDataConfig): void;
|
|
21
29
|
stop(): void;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
* explicitly send their AI interactions).
|
|
25
|
-
*/
|
|
26
|
-
trackPrompt(prompt: string, response?: string, meta?: Record<string, any>): void;
|
|
27
|
-
/**
|
|
28
|
-
* Manually track an API error.
|
|
29
|
-
*/
|
|
30
|
+
trackPrompt(prompt: string, response?: string, meta?: Record<string, unknown>): void;
|
|
31
|
+
trackConversation(messages: ConversationMessage[], meta?: Record<string, unknown>): void;
|
|
30
32
|
trackError(endpoint: string, status: number, message?: string): void;
|
|
31
33
|
private captureUIInteractions;
|
|
32
34
|
private interceptPrompts;
|
|
35
|
+
private captureConversationSurfaces;
|
|
36
|
+
private scheduleConversationScan;
|
|
37
|
+
private scanConversationSurfaces;
|
|
33
38
|
private captureAPIErrors;
|
|
39
|
+
private pushConversationMessage;
|
|
40
|
+
private pushConversationSummary;
|
|
34
41
|
private pushEvent;
|
|
35
42
|
private flush;
|
|
36
|
-
/** Basic PII scrubbing */
|
|
37
43
|
private scrub;
|
|
38
44
|
private getPath;
|
|
45
|
+
private canCapture;
|
|
46
|
+
private sanitizeMeta;
|
|
47
|
+
private extractRequestMeta;
|
|
48
|
+
private parseRequestBody;
|
|
49
|
+
private extractMessagesFromUnknown;
|
|
50
|
+
private normalizeMessage;
|
|
51
|
+
private extractContent;
|
|
52
|
+
private extractResponseMessages;
|
|
53
|
+
private extractAssistantMessages;
|
|
54
|
+
private findConversationContainers;
|
|
55
|
+
private looksLikeConversationContainer;
|
|
56
|
+
private buildConversationSnapshot;
|
|
57
|
+
private isUsableMessageNode;
|
|
58
|
+
private messageFromNode;
|
|
59
|
+
private detectRole;
|
|
60
|
+
private extractConversationTitle;
|
|
61
|
+
private getConversationId;
|
|
62
|
+
private getMessageFingerprint;
|
|
63
|
+
private safePathname;
|
|
64
|
+
private normalizeRole;
|
|
39
65
|
}
|
|
66
|
+
export {};
|
package/dist/modules/widget.d.ts
CHANGED
|
@@ -18,10 +18,11 @@ export declare class WidgetModule {
|
|
|
18
18
|
theme: string;
|
|
19
19
|
}, widget?: Partial<SelectedWidgetConfig> | null): Promise<void>;
|
|
20
20
|
autoInject(): Promise<void>;
|
|
21
|
-
private
|
|
21
|
+
private resolveSelectedWidgets;
|
|
22
22
|
private normalizeConfigs;
|
|
23
23
|
private mountSingleFormat;
|
|
24
24
|
private ensureInlineTarget;
|
|
25
|
+
private findChatContainer;
|
|
25
26
|
mount(targetElementId: string, options?: {
|
|
26
27
|
format?: string;
|
|
27
28
|
refreshInterval?: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export interface UserConsent {
|
|
|
11
11
|
}
|
|
12
12
|
export interface AdUnitConfig {
|
|
13
13
|
placementId: string;
|
|
14
|
-
format: 'video' | '
|
|
14
|
+
format: 'floating-video' | 'tooltip-ad' | 'sponsored-card' | 'inline-text';
|
|
15
15
|
targetElementId?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface TrackingEvent {
|