wauldo 0.1.1 → 0.3.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/README.md +15 -1
- package/dist/index.d.mts +83 -1
- package/dist/index.d.ts +83 -1
- package/dist/index.js +47 -0
- package/dist/index.mjs +47 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
> **Verified AI answers from your documents.** Every response includes source citations, confidence scores, and an audit trail — or we don't answer at all.
|
|
9
9
|
|
|
10
|
-
Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing and
|
|
10
|
+
Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing, zero hallucinations, and standalone fact-checking.
|
|
11
11
|
|
|
12
12
|
## Why Wauldo?
|
|
13
13
|
|
|
14
|
+
- **Fact-Check API** — verify any claim against source context, get verdict (verified/weak/rejected), action (allow/review/block), and structured reason
|
|
14
15
|
- **Zero hallucinations** — every answer is verified against source documents
|
|
15
16
|
- **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
|
|
16
17
|
- **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
|
|
@@ -93,6 +94,19 @@ const reply = await conv.say('What are generics?');
|
|
|
93
94
|
const followUp = await conv.say('Give me an example');
|
|
94
95
|
```
|
|
95
96
|
|
|
97
|
+
### Fact-Check — Verify Claims
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
const result = await client.factCheck({
|
|
101
|
+
text: 'Returns are accepted within 60 days.',
|
|
102
|
+
source_context: 'Our policy allows returns within 14 days.',
|
|
103
|
+
mode: 'lexical',
|
|
104
|
+
});
|
|
105
|
+
console.log(result.verdict); // "rejected"
|
|
106
|
+
console.log(result.action); // "block"
|
|
107
|
+
result.claims.forEach(c => console.log(`${c.text} → ${c.verdict} (${c.reason})`));
|
|
108
|
+
```
|
|
109
|
+
|
|
96
110
|
## Error Handling
|
|
97
111
|
|
|
98
112
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -312,6 +312,58 @@ interface RagQueryResponse {
|
|
|
312
312
|
interface OrchestratorResponse {
|
|
313
313
|
final_output: string;
|
|
314
314
|
}
|
|
315
|
+
interface FactCheckRequest {
|
|
316
|
+
text: string;
|
|
317
|
+
source_context: string;
|
|
318
|
+
mode?: 'lexical' | 'hybrid' | 'semantic';
|
|
319
|
+
}
|
|
320
|
+
interface ClaimResult {
|
|
321
|
+
text: string;
|
|
322
|
+
claim_type: string;
|
|
323
|
+
supported: boolean;
|
|
324
|
+
confidence: number;
|
|
325
|
+
confidence_label: string;
|
|
326
|
+
verdict: string;
|
|
327
|
+
action: string;
|
|
328
|
+
reason?: string | null;
|
|
329
|
+
evidence?: string | null;
|
|
330
|
+
}
|
|
331
|
+
interface FactCheckResponse {
|
|
332
|
+
verdict: string;
|
|
333
|
+
action: string;
|
|
334
|
+
hallucination_rate: number;
|
|
335
|
+
mode: string;
|
|
336
|
+
total_claims: number;
|
|
337
|
+
supported_claims: number;
|
|
338
|
+
confidence: number;
|
|
339
|
+
claims: ClaimResult[];
|
|
340
|
+
mode_warning?: string | null;
|
|
341
|
+
processing_time_ms: number;
|
|
342
|
+
}
|
|
343
|
+
interface SourceChunk {
|
|
344
|
+
name: string;
|
|
345
|
+
content: string;
|
|
346
|
+
}
|
|
347
|
+
interface CitationDetail {
|
|
348
|
+
citation: string;
|
|
349
|
+
source_name: string;
|
|
350
|
+
is_valid: boolean;
|
|
351
|
+
}
|
|
352
|
+
interface VerifyCitationRequest {
|
|
353
|
+
text: string;
|
|
354
|
+
sources?: SourceChunk[];
|
|
355
|
+
threshold?: number;
|
|
356
|
+
}
|
|
357
|
+
interface VerifyCitationResponse {
|
|
358
|
+
citation_ratio: number;
|
|
359
|
+
has_sufficient_citations: boolean;
|
|
360
|
+
sentence_count: number;
|
|
361
|
+
citation_count: number;
|
|
362
|
+
uncited_sentences: string[];
|
|
363
|
+
citations?: CitationDetail[];
|
|
364
|
+
phantom_count?: number;
|
|
365
|
+
processing_time_ms: number;
|
|
366
|
+
}
|
|
315
367
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
316
368
|
interface ChatClientLike {
|
|
317
369
|
chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
|
|
@@ -469,6 +521,36 @@ declare class HttpClient {
|
|
|
469
521
|
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
470
522
|
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
471
523
|
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/**
|
|
525
|
+
* POST /v1/fact-check — Verify claims against source context.
|
|
526
|
+
*
|
|
527
|
+
* @param request - Text and source context to verify
|
|
528
|
+
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* const result = await client.factCheck({
|
|
533
|
+
* text: 'Returns accepted within 60 days.',
|
|
534
|
+
* source_context: 'Our policy allows returns within 14 days.',
|
|
535
|
+
* mode: 'lexical',
|
|
536
|
+
* });
|
|
537
|
+
* console.log(result.verdict); // "rejected"
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
541
|
+
/**
|
|
542
|
+
* POST /v1/verify — Verify citations in AI-generated text.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const result = await client.verifyCitation({
|
|
547
|
+
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
548
|
+
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
549
|
+
* });
|
|
550
|
+
* console.log(result.phantom_count); // 0
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
472
554
|
}
|
|
473
555
|
|
|
474
556
|
/**
|
|
@@ -589,4 +671,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
589
671
|
constructor(toolName: string);
|
|
590
672
|
}
|
|
591
673
|
|
|
592
|
-
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, 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 };
|
|
674
|
+
export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, 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 SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
|
package/dist/index.d.ts
CHANGED
|
@@ -312,6 +312,58 @@ interface RagQueryResponse {
|
|
|
312
312
|
interface OrchestratorResponse {
|
|
313
313
|
final_output: string;
|
|
314
314
|
}
|
|
315
|
+
interface FactCheckRequest {
|
|
316
|
+
text: string;
|
|
317
|
+
source_context: string;
|
|
318
|
+
mode?: 'lexical' | 'hybrid' | 'semantic';
|
|
319
|
+
}
|
|
320
|
+
interface ClaimResult {
|
|
321
|
+
text: string;
|
|
322
|
+
claim_type: string;
|
|
323
|
+
supported: boolean;
|
|
324
|
+
confidence: number;
|
|
325
|
+
confidence_label: string;
|
|
326
|
+
verdict: string;
|
|
327
|
+
action: string;
|
|
328
|
+
reason?: string | null;
|
|
329
|
+
evidence?: string | null;
|
|
330
|
+
}
|
|
331
|
+
interface FactCheckResponse {
|
|
332
|
+
verdict: string;
|
|
333
|
+
action: string;
|
|
334
|
+
hallucination_rate: number;
|
|
335
|
+
mode: string;
|
|
336
|
+
total_claims: number;
|
|
337
|
+
supported_claims: number;
|
|
338
|
+
confidence: number;
|
|
339
|
+
claims: ClaimResult[];
|
|
340
|
+
mode_warning?: string | null;
|
|
341
|
+
processing_time_ms: number;
|
|
342
|
+
}
|
|
343
|
+
interface SourceChunk {
|
|
344
|
+
name: string;
|
|
345
|
+
content: string;
|
|
346
|
+
}
|
|
347
|
+
interface CitationDetail {
|
|
348
|
+
citation: string;
|
|
349
|
+
source_name: string;
|
|
350
|
+
is_valid: boolean;
|
|
351
|
+
}
|
|
352
|
+
interface VerifyCitationRequest {
|
|
353
|
+
text: string;
|
|
354
|
+
sources?: SourceChunk[];
|
|
355
|
+
threshold?: number;
|
|
356
|
+
}
|
|
357
|
+
interface VerifyCitationResponse {
|
|
358
|
+
citation_ratio: number;
|
|
359
|
+
has_sufficient_citations: boolean;
|
|
360
|
+
sentence_count: number;
|
|
361
|
+
citation_count: number;
|
|
362
|
+
uncited_sentences: string[];
|
|
363
|
+
citations?: CitationDetail[];
|
|
364
|
+
phantom_count?: number;
|
|
365
|
+
processing_time_ms: number;
|
|
366
|
+
}
|
|
315
367
|
/** Minimal interface required by Conversation — implemented by both HttpClient and MockHttpClient */
|
|
316
368
|
interface ChatClientLike {
|
|
317
369
|
chat(request: ChatRequest, options?: RequestOptions): Promise<ChatResponse>;
|
|
@@ -469,6 +521,36 @@ declare class HttpClient {
|
|
|
469
521
|
orchestrate(prompt: string): Promise<OrchestratorResponse>;
|
|
470
522
|
/** POST /v1/orchestrator/parallel — Run all 4 specialists in parallel */
|
|
471
523
|
orchestrateParallel(prompt: string): Promise<OrchestratorResponse>;
|
|
524
|
+
/**
|
|
525
|
+
* POST /v1/fact-check — Verify claims against source context.
|
|
526
|
+
*
|
|
527
|
+
* @param request - Text and source context to verify
|
|
528
|
+
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* const result = await client.factCheck({
|
|
533
|
+
* text: 'Returns accepted within 60 days.',
|
|
534
|
+
* source_context: 'Our policy allows returns within 14 days.',
|
|
535
|
+
* mode: 'lexical',
|
|
536
|
+
* });
|
|
537
|
+
* console.log(result.verdict); // "rejected"
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
factCheck(request: FactCheckRequest): Promise<FactCheckResponse>;
|
|
541
|
+
/**
|
|
542
|
+
* POST /v1/verify — Verify citations in AI-generated text.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const result = await client.verifyCitation({
|
|
547
|
+
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
548
|
+
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
549
|
+
* });
|
|
550
|
+
* console.log(result.phantom_count); // 0
|
|
551
|
+
* ```
|
|
552
|
+
*/
|
|
553
|
+
verifyCitation(request: VerifyCitationRequest): Promise<VerifyCitationResponse>;
|
|
472
554
|
}
|
|
473
555
|
|
|
474
556
|
/**
|
|
@@ -589,4 +671,4 @@ declare class ToolNotFoundError extends WauldoError {
|
|
|
589
671
|
constructor(toolName: string);
|
|
590
672
|
}
|
|
591
673
|
|
|
592
|
-
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, 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 };
|
|
674
|
+
export { AgentClient, type CallToolResponse, type ChatChoice, type ChatClientLike, type ChatMessage, type ChatRequest, type ChatResponse, type ChatUsage, type Chunk, type ChunkResult, type CitationDetail, type ClaimResult, type ClientOptions, type Concept, type ConceptResult, ConnectionError, Conversation, type DetailLevel, type EmbeddingData, type EmbeddingResponse, type EmbeddingUsage, type FactCheckRequest, type FactCheckResponse, type GraphNode, 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 SourceChunk, type SourceType, TimeoutError, type ToolContent, type ToolDefinition, ToolNotFoundError, ValidationError, type VerifyCitationRequest, type VerifyCitationResponse, WauldoError, chatContent };
|
package/dist/index.js
CHANGED
|
@@ -1097,6 +1097,53 @@ var HttpClient = class {
|
|
|
1097
1097
|
);
|
|
1098
1098
|
return validateResponse(data, "OrchestratorResponse");
|
|
1099
1099
|
}
|
|
1100
|
+
// ── Fact-Check endpoints ──────────────────────────────────────────────
|
|
1101
|
+
/**
|
|
1102
|
+
* POST /v1/fact-check — Verify claims against source context.
|
|
1103
|
+
*
|
|
1104
|
+
* @param request - Text and source context to verify
|
|
1105
|
+
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```typescript
|
|
1109
|
+
* const result = await client.factCheck({
|
|
1110
|
+
* text: 'Returns accepted within 60 days.',
|
|
1111
|
+
* source_context: 'Our policy allows returns within 14 days.',
|
|
1112
|
+
* mode: 'lexical',
|
|
1113
|
+
* });
|
|
1114
|
+
* console.log(result.verdict); // "rejected"
|
|
1115
|
+
* ```
|
|
1116
|
+
*/
|
|
1117
|
+
async factCheck(request) {
|
|
1118
|
+
const data = await fetchWithRetry(
|
|
1119
|
+
this.retryConfig,
|
|
1120
|
+
"POST",
|
|
1121
|
+
"/v1/fact-check",
|
|
1122
|
+
request
|
|
1123
|
+
);
|
|
1124
|
+
return validateResponse(data, "FactCheckResponse");
|
|
1125
|
+
}
|
|
1126
|
+
/**
|
|
1127
|
+
* POST /v1/verify — Verify citations in AI-generated text.
|
|
1128
|
+
*
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```ts
|
|
1131
|
+
* const result = await client.verifyCitation({
|
|
1132
|
+
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
1133
|
+
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
1134
|
+
* });
|
|
1135
|
+
* console.log(result.phantom_count); // 0
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
async verifyCitation(request) {
|
|
1139
|
+
const data = await fetchWithRetry(
|
|
1140
|
+
this.retryConfig,
|
|
1141
|
+
"POST",
|
|
1142
|
+
"/v1/verify",
|
|
1143
|
+
request
|
|
1144
|
+
);
|
|
1145
|
+
return validateResponse(data, "VerifyCitationResponse");
|
|
1146
|
+
}
|
|
1100
1147
|
};
|
|
1101
1148
|
|
|
1102
1149
|
// src/mock_client.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1061,6 +1061,53 @@ var HttpClient = class {
|
|
|
1061
1061
|
);
|
|
1062
1062
|
return validateResponse(data, "OrchestratorResponse");
|
|
1063
1063
|
}
|
|
1064
|
+
// ── Fact-Check endpoints ──────────────────────────────────────────────
|
|
1065
|
+
/**
|
|
1066
|
+
* POST /v1/fact-check — Verify claims against source context.
|
|
1067
|
+
*
|
|
1068
|
+
* @param request - Text and source context to verify
|
|
1069
|
+
* @returns FactCheckResponse with verdict, action, and per-claim results
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```typescript
|
|
1073
|
+
* const result = await client.factCheck({
|
|
1074
|
+
* text: 'Returns accepted within 60 days.',
|
|
1075
|
+
* source_context: 'Our policy allows returns within 14 days.',
|
|
1076
|
+
* mode: 'lexical',
|
|
1077
|
+
* });
|
|
1078
|
+
* console.log(result.verdict); // "rejected"
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
async factCheck(request) {
|
|
1082
|
+
const data = await fetchWithRetry(
|
|
1083
|
+
this.retryConfig,
|
|
1084
|
+
"POST",
|
|
1085
|
+
"/v1/fact-check",
|
|
1086
|
+
request
|
|
1087
|
+
);
|
|
1088
|
+
return validateResponse(data, "FactCheckResponse");
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* POST /v1/verify — Verify citations in AI-generated text.
|
|
1092
|
+
*
|
|
1093
|
+
* @example
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* const result = await client.verifyCitation({
|
|
1096
|
+
* text: 'Rust was released in 2010 [Source: rust_book].',
|
|
1097
|
+
* sources: [{ name: 'rust_book', content: 'Rust was first released in 2010.' }],
|
|
1098
|
+
* });
|
|
1099
|
+
* console.log(result.phantom_count); // 0
|
|
1100
|
+
* ```
|
|
1101
|
+
*/
|
|
1102
|
+
async verifyCitation(request) {
|
|
1103
|
+
const data = await fetchWithRetry(
|
|
1104
|
+
this.retryConfig,
|
|
1105
|
+
"POST",
|
|
1106
|
+
"/v1/verify",
|
|
1107
|
+
request
|
|
1108
|
+
);
|
|
1109
|
+
return validateResponse(data, "VerifyCitationResponse");
|
|
1110
|
+
}
|
|
1064
1111
|
};
|
|
1065
1112
|
|
|
1066
1113
|
// src/mock_client.ts
|