wauldo 0.6.0 → 0.7.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 +9 -36
- package/dist/index.d.mts +39 -176
- package/dist/index.d.ts +39 -176
- package/dist/index.js +44 -278
- package/dist/index.mjs +41 -277
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,35 +28,12 @@
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Quickstart (30 seconds)
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
npm install wauldo
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
```typescript
|
|
38
|
-
import { MockHttpClient } from 'wauldo';
|
|
39
|
-
|
|
40
|
-
const client = new MockHttpClient();
|
|
41
|
-
|
|
42
|
-
// Upload, query, fact-check — all offline
|
|
43
|
-
await client.ragUpload('Refund policy allows returns within 60 days.', 'policy.txt');
|
|
44
|
-
const result = await client.ragQuery('What is the refund policy?');
|
|
45
|
-
console.log(result.answer); // "Mock answer for: What is the refund policy?"
|
|
46
|
-
|
|
47
|
-
const check = await client.factCheck({
|
|
48
|
-
text: 'Returns accepted within 30 days.',
|
|
49
|
-
source_context: 'Refund policy allows returns within 60 days.',
|
|
50
|
-
});
|
|
51
|
-
console.log(check.verdict); // "rejected"
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Run the full quickstart: `npx tsx examples/quickstart.ts`
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Quickstart with real API
|
|
59
|
-
|
|
60
37
|
```typescript
|
|
61
38
|
import { HttpClient } from 'wauldo';
|
|
62
39
|
|
|
@@ -126,14 +103,14 @@ console.log(`Confidence: ${Math.round(result.audit.confidence * 100)}%`);
|
|
|
126
103
|
console.log(`Grounded: ${result.audit.grounded}`);
|
|
127
104
|
```
|
|
128
105
|
|
|
129
|
-
###
|
|
106
|
+
### Guard — fact-check any LLM output
|
|
130
107
|
|
|
131
108
|
```typescript
|
|
132
|
-
const result = await client.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
const result = await client.guard(
|
|
110
|
+
'Returns are accepted within 60 days.',
|
|
111
|
+
'Our policy allows returns within 14 days.',
|
|
112
|
+
'lexical',
|
|
113
|
+
);
|
|
137
114
|
console.log(result.verdict); // "rejected"
|
|
138
115
|
console.log(result.action); // "block"
|
|
139
116
|
console.log(result.claims[0].reason); // "numerical_mismatch"
|
|
@@ -172,9 +149,7 @@ const followUp = await conv.say('Give me an example');
|
|
|
172
149
|
|
|
173
150
|
- **Pre-generation fact extraction** — numbers, dates, limits injected as constraints
|
|
174
151
|
- **Post-generation grounding check** — every answer verified against sources
|
|
175
|
-
- **
|
|
176
|
-
- **Analytics & Insights** — track token savings, cache performance, cost per hour, and per-tenant traffic
|
|
177
|
-
- **Fact-check API** — verify any claim against any source (3 modes)
|
|
152
|
+
- **Guard API** — verify any claim against any source (3 modes: lexical, hybrid, semantic)
|
|
178
153
|
- **Native PDF/DOCX upload** — server-side extraction with quality scoring
|
|
179
154
|
- **Smart model routing** — auto-selects cheapest model that meets quality
|
|
180
155
|
- **OpenAI-compatible** — swap your `baseUrl`, keep your existing code
|
|
@@ -218,9 +193,7 @@ Free tier (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-
|
|
|
218
193
|
|
|
219
194
|
## Contributing
|
|
220
195
|
|
|
221
|
-
PRs welcome
|
|
222
|
-
|
|
223
|
-
Check the [good first issues](https://github.com/wauldo/wauldo-sdk-js/labels/good%20first%20issue) to get started.
|
|
196
|
+
PRs welcome. Check the [good first issues](https://github.com/wauldo/wauldo-sdk-js/labels/good%20first%20issue).
|
|
224
197
|
|
|
225
198
|
## License
|
|
226
199
|
|
package/dist/index.d.mts
CHANGED
|
@@ -277,22 +277,6 @@ interface RagUploadResponse {
|
|
|
277
277
|
document_id: string;
|
|
278
278
|
chunks_count: number;
|
|
279
279
|
}
|
|
280
|
-
interface DocumentQuality {
|
|
281
|
-
score: number;
|
|
282
|
-
label: string;
|
|
283
|
-
word_count: number;
|
|
284
|
-
line_density: number;
|
|
285
|
-
avg_line_length: number;
|
|
286
|
-
paragraph_count: number;
|
|
287
|
-
}
|
|
288
|
-
interface UploadFileResponse {
|
|
289
|
-
document_id: string;
|
|
290
|
-
chunks_count: number;
|
|
291
|
-
indexed_at: string;
|
|
292
|
-
content_type: string;
|
|
293
|
-
trace_id: string;
|
|
294
|
-
quality?: DocumentQuality;
|
|
295
|
-
}
|
|
296
280
|
interface RagSource {
|
|
297
281
|
document_id: string;
|
|
298
282
|
content: string;
|
|
@@ -325,26 +309,20 @@ interface RagQueryResponse {
|
|
|
325
309
|
confidence?: number;
|
|
326
310
|
grounded?: boolean;
|
|
327
311
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
interface FactCheckRequest {
|
|
332
|
-
text: string;
|
|
333
|
-
source_context: string;
|
|
334
|
-
mode?: 'lexical' | 'hybrid' | 'semantic';
|
|
335
|
-
}
|
|
336
|
-
interface ClaimResult {
|
|
312
|
+
/** A single verified claim from the Guard response */
|
|
313
|
+
interface GuardClaim {
|
|
337
314
|
text: string;
|
|
338
|
-
claim_type
|
|
315
|
+
claim_type?: string;
|
|
339
316
|
supported: boolean;
|
|
340
317
|
confidence: number;
|
|
341
|
-
confidence_label
|
|
318
|
+
confidence_label?: string;
|
|
342
319
|
verdict: string;
|
|
343
320
|
action: string;
|
|
344
321
|
reason?: string | null;
|
|
345
322
|
evidence?: string | null;
|
|
346
323
|
}
|
|
347
|
-
|
|
324
|
+
/** Response from POST /v1/fact-check — the Guard verification API */
|
|
325
|
+
interface GuardResponse {
|
|
348
326
|
verdict: string;
|
|
349
327
|
action: string;
|
|
350
328
|
hallucination_rate: number;
|
|
@@ -352,85 +330,18 @@ interface FactCheckResponse {
|
|
|
352
330
|
total_claims: number;
|
|
353
331
|
supported_claims: number;
|
|
354
332
|
confidence: number;
|
|
355
|
-
claims:
|
|
356
|
-
mode_warning?: string
|
|
357
|
-
processing_time_ms
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
interface VerifyCitationRequest {
|
|
369
|
-
text: string;
|
|
370
|
-
sources?: SourceChunk[];
|
|
371
|
-
threshold?: number;
|
|
372
|
-
}
|
|
373
|
-
interface VerifyCitationResponse {
|
|
374
|
-
citation_ratio: number;
|
|
375
|
-
has_sufficient_citations: boolean;
|
|
376
|
-
sentence_count: number;
|
|
377
|
-
citation_count: number;
|
|
378
|
-
uncited_sentences: string[];
|
|
379
|
-
citations?: CitationDetail[];
|
|
380
|
-
phantom_count?: number;
|
|
381
|
-
processing_time_ms: number;
|
|
382
|
-
}
|
|
383
|
-
interface GuardResult {
|
|
384
|
-
safe: boolean;
|
|
385
|
-
verdict: string;
|
|
386
|
-
action: string;
|
|
387
|
-
reason: string | null;
|
|
388
|
-
confidence: number;
|
|
389
|
-
}
|
|
390
|
-
interface InsightsResponse {
|
|
391
|
-
tig_key: string;
|
|
392
|
-
total_requests: number;
|
|
393
|
-
intelligence_requests: number;
|
|
394
|
-
fallback_requests: number;
|
|
395
|
-
tokens: {
|
|
396
|
-
baseline_total: number;
|
|
397
|
-
real_total: number;
|
|
398
|
-
saved_total: number;
|
|
399
|
-
saved_percent_avg: number;
|
|
400
|
-
};
|
|
401
|
-
cost: {
|
|
402
|
-
estimated_usd_saved: number;
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
interface AnalyticsResponse {
|
|
406
|
-
cache: {
|
|
407
|
-
total_requests: number;
|
|
408
|
-
cache_hit_rate: number;
|
|
409
|
-
avg_latency_ms: number;
|
|
410
|
-
p95_latency_ms: number;
|
|
411
|
-
};
|
|
412
|
-
tokens: {
|
|
413
|
-
total_baseline: number;
|
|
414
|
-
total_real: number;
|
|
415
|
-
total_saved: number;
|
|
416
|
-
avg_savings_percent: number;
|
|
417
|
-
};
|
|
418
|
-
uptime_secs: number;
|
|
419
|
-
}
|
|
420
|
-
interface TrafficSummary {
|
|
421
|
-
total_requests_today: number;
|
|
422
|
-
total_tokens_today: number;
|
|
423
|
-
top_tenants: Array<{
|
|
424
|
-
tenant_id: string;
|
|
425
|
-
requests_today: number;
|
|
426
|
-
tokens_used: number;
|
|
427
|
-
success_rate: number;
|
|
428
|
-
avg_latency_ms: number;
|
|
429
|
-
}>;
|
|
430
|
-
error_rate: number;
|
|
431
|
-
avg_latency_ms: number;
|
|
432
|
-
p95_latency_ms: number;
|
|
433
|
-
uptime_secs: number;
|
|
333
|
+
claims: GuardClaim[];
|
|
334
|
+
mode_warning?: string;
|
|
335
|
+
processing_time_ms?: number;
|
|
336
|
+
}
|
|
337
|
+
/** Check if a GuardResponse allows the content through */
|
|
338
|
+
declare function guardIsSafe(response: GuardResponse): boolean;
|
|
339
|
+
/** Check if a GuardResponse blocks the content */
|
|
340
|
+
declare function guardIsBlocked(response: GuardResponse): boolean;
|
|
341
|
+
/** Guard verification modes */
|
|
342
|
+
type GuardMode = 'lexical' | 'hybrid' | 'semantic';
|
|
343
|
+
interface OrchestratorResponse {
|
|
344
|
+
final_output: string;
|
|
434
345
|
}
|
|
435
346
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
436
347
|
interface ChatClientLike {
|
|
@@ -555,19 +466,6 @@ declare class HttpClient {
|
|
|
555
466
|
* @returns Upload confirmation with document_id and chunks_count
|
|
556
467
|
*/
|
|
557
468
|
ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
|
|
558
|
-
/**
|
|
559
|
-
* POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
|
|
560
|
-
*
|
|
561
|
-
* @param file - File content as Buffer/Uint8Array
|
|
562
|
-
* @param filename - The filename (determines content type detection)
|
|
563
|
-
* @param options - Optional title, tags, timeoutMs
|
|
564
|
-
* @returns Upload confirmation with quality scoring
|
|
565
|
-
*/
|
|
566
|
-
uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
|
|
567
|
-
title?: string;
|
|
568
|
-
tags?: string;
|
|
569
|
-
timeoutMs?: number;
|
|
570
|
-
}): Promise<UploadFileResponse>;
|
|
571
469
|
/** POST /v1/query — Query RAG knowledge base */
|
|
572
470
|
ragQuery(query: string, topK?: number, options?: {
|
|
573
471
|
debug?: boolean;
|
|
@@ -598,57 +496,33 @@ declare class HttpClient {
|
|
|
598
496
|
* @returns The answer string
|
|
599
497
|
*/
|
|
600
498
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
601
|
-
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
602
|
-
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
603
|
-
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
604
|
-
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
605
499
|
/**
|
|
606
|
-
* POST /v1/fact-check — Verify claims against source context.
|
|
500
|
+
* POST /v1/fact-check — Verify text claims against source context.
|
|
607
501
|
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
502
|
+
* Guard is a hallucination firewall: checks whether LLM output is supported
|
|
503
|
+
* by source documents. Blocks wrong answers before they reach users.
|
|
610
504
|
*
|
|
611
|
-
* @
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* source_context: 'Our policy allows returns within 14 days.',
|
|
616
|
-
* mode: 'lexical',
|
|
617
|
-
* });
|
|
618
|
-
* console.log(result.verdict); // "rejected"
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
622
|
-
/**
|
|
623
|
-
* POST /v1/verify — Verify citations in AI-generated text.
|
|
505
|
+
* @param text - The LLM-generated text to verify
|
|
506
|
+
* @param sourceContext - The ground-truth source document(s)
|
|
507
|
+
* @param mode - "lexical" (<1ms), "hybrid" (~50ms), or "semantic" (~500ms)
|
|
508
|
+
* @param options - Optional per-request overrides
|
|
624
509
|
*
|
|
625
510
|
* @example
|
|
626
|
-
* ```
|
|
627
|
-
* const result = await client.
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
511
|
+
* ```typescript
|
|
512
|
+
* const result = await client.guard(
|
|
513
|
+
* 'Returns accepted within 60 days',
|
|
514
|
+
* 'Our return policy: 14 days.',
|
|
515
|
+
* );
|
|
516
|
+
* if (result.action === 'block') {
|
|
517
|
+
* console.log('Hallucination caught:', result.claims[0]?.reason);
|
|
518
|
+
* }
|
|
632
519
|
* ```
|
|
633
520
|
*/
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
guard(text: string, source: string, mode?: 'lexical' | 'hybrid' | 'semantic'): Promise<GuardResult>;
|
|
640
|
-
/**
|
|
641
|
-
* GET /v1/insights — ROI metrics for your API key
|
|
642
|
-
*/
|
|
643
|
-
getInsights(): Promise<InsightsResponse>;
|
|
644
|
-
/**
|
|
645
|
-
* GET /v1/analytics — Usage analytics and cache performance
|
|
646
|
-
*/
|
|
647
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
648
|
-
/**
|
|
649
|
-
* GET /v1/analytics/traffic — Per-tenant traffic monitoring
|
|
650
|
-
*/
|
|
651
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
521
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, options?: RequestOptions): Promise<GuardResponse>;
|
|
522
|
+
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
523
|
+
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
525
|
+
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
652
526
|
}
|
|
653
527
|
|
|
654
528
|
/**
|
|
@@ -719,17 +593,6 @@ declare class MockHttpClient {
|
|
|
719
593
|
system?: string;
|
|
720
594
|
model?: string;
|
|
721
595
|
}): Conversation;
|
|
722
|
-
uploadFile(_file: Uint8Array | Buffer, filename: string, options?: {
|
|
723
|
-
title?: string;
|
|
724
|
-
tags?: string;
|
|
725
|
-
timeoutMs?: number;
|
|
726
|
-
}): Promise<UploadFileResponse>;
|
|
727
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
728
|
-
guard(text: string, source: string, mode?: string): Promise<GuardResult>;
|
|
729
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
730
|
-
getInsights(): Promise<InsightsResponse>;
|
|
731
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
732
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
733
596
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
734
597
|
private record;
|
|
735
598
|
}
|
|
@@ -780,4 +643,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
780
643
|
constructor(toolName: string);
|
|
781
644
|
}
|
|
782
645
|
|
|
783
|
-
export { AgentClient, type
|
|
646
|
+
export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent, guardIsBlocked, guardIsSafe };
|
package/dist/index.d.ts
CHANGED
|
@@ -277,22 +277,6 @@ interface RagUploadResponse {
|
|
|
277
277
|
document_id: string;
|
|
278
278
|
chunks_count: number;
|
|
279
279
|
}
|
|
280
|
-
interface DocumentQuality {
|
|
281
|
-
score: number;
|
|
282
|
-
label: string;
|
|
283
|
-
word_count: number;
|
|
284
|
-
line_density: number;
|
|
285
|
-
avg_line_length: number;
|
|
286
|
-
paragraph_count: number;
|
|
287
|
-
}
|
|
288
|
-
interface UploadFileResponse {
|
|
289
|
-
document_id: string;
|
|
290
|
-
chunks_count: number;
|
|
291
|
-
indexed_at: string;
|
|
292
|
-
content_type: string;
|
|
293
|
-
trace_id: string;
|
|
294
|
-
quality?: DocumentQuality;
|
|
295
|
-
}
|
|
296
280
|
interface RagSource {
|
|
297
281
|
document_id: string;
|
|
298
282
|
content: string;
|
|
@@ -325,26 +309,20 @@ interface RagQueryResponse {
|
|
|
325
309
|
confidence?: number;
|
|
326
310
|
grounded?: boolean;
|
|
327
311
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
}
|
|
331
|
-
interface FactCheckRequest {
|
|
332
|
-
text: string;
|
|
333
|
-
source_context: string;
|
|
334
|
-
mode?: 'lexical' | 'hybrid' | 'semantic';
|
|
335
|
-
}
|
|
336
|
-
interface ClaimResult {
|
|
312
|
+
/** A single verified claim from the Guard response */
|
|
313
|
+
interface GuardClaim {
|
|
337
314
|
text: string;
|
|
338
|
-
claim_type
|
|
315
|
+
claim_type?: string;
|
|
339
316
|
supported: boolean;
|
|
340
317
|
confidence: number;
|
|
341
|
-
confidence_label
|
|
318
|
+
confidence_label?: string;
|
|
342
319
|
verdict: string;
|
|
343
320
|
action: string;
|
|
344
321
|
reason?: string | null;
|
|
345
322
|
evidence?: string | null;
|
|
346
323
|
}
|
|
347
|
-
|
|
324
|
+
/** Response from POST /v1/fact-check — the Guard verification API */
|
|
325
|
+
interface GuardResponse {
|
|
348
326
|
verdict: string;
|
|
349
327
|
action: string;
|
|
350
328
|
hallucination_rate: number;
|
|
@@ -352,85 +330,18 @@ interface FactCheckResponse {
|
|
|
352
330
|
total_claims: number;
|
|
353
331
|
supported_claims: number;
|
|
354
332
|
confidence: number;
|
|
355
|
-
claims:
|
|
356
|
-
mode_warning?: string
|
|
357
|
-
processing_time_ms
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
interface VerifyCitationRequest {
|
|
369
|
-
text: string;
|
|
370
|
-
sources?: SourceChunk[];
|
|
371
|
-
threshold?: number;
|
|
372
|
-
}
|
|
373
|
-
interface VerifyCitationResponse {
|
|
374
|
-
citation_ratio: number;
|
|
375
|
-
has_sufficient_citations: boolean;
|
|
376
|
-
sentence_count: number;
|
|
377
|
-
citation_count: number;
|
|
378
|
-
uncited_sentences: string[];
|
|
379
|
-
citations?: CitationDetail[];
|
|
380
|
-
phantom_count?: number;
|
|
381
|
-
processing_time_ms: number;
|
|
382
|
-
}
|
|
383
|
-
interface GuardResult {
|
|
384
|
-
safe: boolean;
|
|
385
|
-
verdict: string;
|
|
386
|
-
action: string;
|
|
387
|
-
reason: string | null;
|
|
388
|
-
confidence: number;
|
|
389
|
-
}
|
|
390
|
-
interface InsightsResponse {
|
|
391
|
-
tig_key: string;
|
|
392
|
-
total_requests: number;
|
|
393
|
-
intelligence_requests: number;
|
|
394
|
-
fallback_requests: number;
|
|
395
|
-
tokens: {
|
|
396
|
-
baseline_total: number;
|
|
397
|
-
real_total: number;
|
|
398
|
-
saved_total: number;
|
|
399
|
-
saved_percent_avg: number;
|
|
400
|
-
};
|
|
401
|
-
cost: {
|
|
402
|
-
estimated_usd_saved: number;
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
interface AnalyticsResponse {
|
|
406
|
-
cache: {
|
|
407
|
-
total_requests: number;
|
|
408
|
-
cache_hit_rate: number;
|
|
409
|
-
avg_latency_ms: number;
|
|
410
|
-
p95_latency_ms: number;
|
|
411
|
-
};
|
|
412
|
-
tokens: {
|
|
413
|
-
total_baseline: number;
|
|
414
|
-
total_real: number;
|
|
415
|
-
total_saved: number;
|
|
416
|
-
avg_savings_percent: number;
|
|
417
|
-
};
|
|
418
|
-
uptime_secs: number;
|
|
419
|
-
}
|
|
420
|
-
interface TrafficSummary {
|
|
421
|
-
total_requests_today: number;
|
|
422
|
-
total_tokens_today: number;
|
|
423
|
-
top_tenants: Array<{
|
|
424
|
-
tenant_id: string;
|
|
425
|
-
requests_today: number;
|
|
426
|
-
tokens_used: number;
|
|
427
|
-
success_rate: number;
|
|
428
|
-
avg_latency_ms: number;
|
|
429
|
-
}>;
|
|
430
|
-
error_rate: number;
|
|
431
|
-
avg_latency_ms: number;
|
|
432
|
-
p95_latency_ms: number;
|
|
433
|
-
uptime_secs: number;
|
|
333
|
+
claims: GuardClaim[];
|
|
334
|
+
mode_warning?: string;
|
|
335
|
+
processing_time_ms?: number;
|
|
336
|
+
}
|
|
337
|
+
/** Check if a GuardResponse allows the content through */
|
|
338
|
+
declare function guardIsSafe(response: GuardResponse): boolean;
|
|
339
|
+
/** Check if a GuardResponse blocks the content */
|
|
340
|
+
declare function guardIsBlocked(response: GuardResponse): boolean;
|
|
341
|
+
/** Guard verification modes */
|
|
342
|
+
type GuardMode = 'lexical' | 'hybrid' | 'semantic';
|
|
343
|
+
interface OrchestratorResponse {
|
|
344
|
+
final_output: string;
|
|
434
345
|
}
|
|
435
346
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
436
347
|
interface ChatClientLike {
|
|
@@ -555,19 +466,6 @@ declare class HttpClient {
|
|
|
555
466
|
* @returns Upload confirmation with document_id and chunks_count
|
|
556
467
|
*/
|
|
557
468
|
ragUpload(content: string, filename?: string, options?: RequestOptions): Promise<RagUploadResponse>;
|
|
558
|
-
/**
|
|
559
|
-
* POST /v1/upload-file — Upload a file (PDF, DOCX, text, image) for RAG indexing.
|
|
560
|
-
*
|
|
561
|
-
* @param file - File content as Buffer/Uint8Array
|
|
562
|
-
* @param filename - The filename (determines content type detection)
|
|
563
|
-
* @param options - Optional title, tags, timeoutMs
|
|
564
|
-
* @returns Upload confirmation with quality scoring
|
|
565
|
-
*/
|
|
566
|
-
uploadFile(file: Uint8Array | Buffer, filename: string, options?: {
|
|
567
|
-
title?: string;
|
|
568
|
-
tags?: string;
|
|
569
|
-
timeoutMs?: number;
|
|
570
|
-
}): Promise<UploadFileResponse>;
|
|
571
469
|
/** POST /v1/query — Query RAG knowledge base */
|
|
572
470
|
ragQuery(query: string, topK?: number, options?: {
|
|
573
471
|
debug?: boolean;
|
|
@@ -598,57 +496,33 @@ declare class HttpClient {
|
|
|
598
496
|
* @returns The answer string
|
|
599
497
|
*/
|
|
600
498
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
601
|
-
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
602
|
-
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
603
|
-
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
604
|
-
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
605
499
|
/**
|
|
606
|
-
* POST /v1/fact-check — Verify claims against source context.
|
|
500
|
+
* POST /v1/fact-check — Verify text claims against source context.
|
|
607
501
|
*
|
|
608
|
-
*
|
|
609
|
-
*
|
|
502
|
+
* Guard is a hallucination firewall: checks whether LLM output is supported
|
|
503
|
+
* by source documents. Blocks wrong answers before they reach users.
|
|
610
504
|
*
|
|
611
|
-
* @
|
|
612
|
-
*
|
|
613
|
-
*
|
|
614
|
-
*
|
|
615
|
-
* source_context: 'Our policy allows returns within 14 days.',
|
|
616
|
-
* mode: 'lexical',
|
|
617
|
-
* });
|
|
618
|
-
* console.log(result.verdict); // "rejected"
|
|
619
|
-
* ```
|
|
620
|
-
*/
|
|
621
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
622
|
-
/**
|
|
623
|
-
* POST /v1/verify — Verify citations in AI-generated text.
|
|
505
|
+
* @param text - The LLM-generated text to verify
|
|
506
|
+
* @param sourceContext - The ground-truth source document(s)
|
|
507
|
+
* @param mode - "lexical" (<1ms), "hybrid" (~50ms), or "semantic" (~500ms)
|
|
508
|
+
* @param options - Optional per-request overrides
|
|
624
509
|
*
|
|
625
510
|
* @example
|
|
626
|
-
* ```
|
|
627
|
-
* const result = await client.
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
511
|
+
* ```typescript
|
|
512
|
+
* const result = await client.guard(
|
|
513
|
+
* 'Returns accepted within 60 days',
|
|
514
|
+
* 'Our return policy: 14 days.',
|
|
515
|
+
* );
|
|
516
|
+
* if (result.action === 'block') {
|
|
517
|
+
* console.log('Hallucination caught:', result.claims[0]?.reason);
|
|
518
|
+
* }
|
|
632
519
|
* ```
|
|
633
520
|
*/
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
guard(text: string, source: string, mode?: 'lexical' | 'hybrid' | 'semantic'): Promise<GuardResult>;
|
|
640
|
-
/**
|
|
641
|
-
* GET /v1/insights — ROI metrics for your API key
|
|
642
|
-
*/
|
|
643
|
-
getInsights(): Promise<InsightsResponse>;
|
|
644
|
-
/**
|
|
645
|
-
* GET /v1/analytics — Usage analytics and cache performance
|
|
646
|
-
*/
|
|
647
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
648
|
-
/**
|
|
649
|
-
* GET /v1/analytics/traffic — Per-tenant traffic monitoring
|
|
650
|
-
*/
|
|
651
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
521
|
+
guard(text: string, sourceContext: string, mode?: GuardMode, options?: RequestOptions): Promise<GuardResponse>;
|
|
522
|
+
/** POST /v1/orchestrator/execute — Route to best specialist agent */
|
|
523
|
+
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
525
|
+
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
652
526
|
}
|
|
653
527
|
|
|
654
528
|
/**
|
|
@@ -719,17 +593,6 @@ declare class MockHttpClient {
|
|
|
719
593
|
system?: string;
|
|
720
594
|
model?: string;
|
|
721
595
|
}): Conversation;
|
|
722
|
-
uploadFile(_file: Uint8Array | Buffer, filename: string, options?: {
|
|
723
|
-
title?: string;
|
|
724
|
-
tags?: string;
|
|
725
|
-
timeoutMs?: number;
|
|
726
|
-
}): Promise<UploadFileResponse>;
|
|
727
|
-
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
728
|
-
guard(text: string, source: string, mode?: string): Promise<GuardResult>;
|
|
729
|
-
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
730
|
-
getInsights(): Promise<InsightsResponse>;
|
|
731
|
-
getAnalytics(minutes?: number): Promise<AnalyticsResponse>;
|
|
732
|
-
getAnalyticsTraffic(): Promise<TrafficSummary>;
|
|
733
596
|
ragAsk(question: string, text: string, source?: string): Promise<string>;
|
|
734
597
|
private record;
|
|
735
598
|
}
|
|
@@ -780,4 +643,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
780
643
|
constructor(toolName: string);
|
|
781
644
|
}
|
|
782
645
|
|
|
783
|
-
export { AgentClient, type
|
|
646
|
+
export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type GraphNode, type GuardClaim, type GuardMode, type GuardResponse, HttpClient, type HttpClientConfig, type KnowledgeGraphResult, type LogLevel, MockHttpClient, type ModelInfo, type ModelList, type OrchestratorResponse, type PlanOptions, type PlanResult, type PlanStep, type RagAuditInfo, type RagQueryResponse, type RagSource, type RagUploadResponse, type ReasoningOptions, type ReasoningResult, type RequestOptions, type RetrievalResult, ServerError, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, WauldoError, chatContent, guardIsBlocked, guardIsSafe };
|