wauldo 0.1.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/LICENSE +21 -0
- package/README.md +143 -0
- package/dist/index.d.mts +590 -0
- package/dist/index.d.ts +590 -0
- package/dist/index.js +1212 -0
- package/dist/index.mjs +1176 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Wauldo Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Wauldo TypeScript SDK
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/wauldo)
|
|
4
|
+
[](https://npmjs.com/package/wauldo)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
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
|
+
|
|
10
|
+
Official TypeScript SDK for the [Wauldo API](https://wauldo.com) — the AI inference layer with smart model routing and zero hallucinations.
|
|
11
|
+
|
|
12
|
+
## Why Wauldo?
|
|
13
|
+
|
|
14
|
+
- **Zero hallucinations** — every answer is verified against source documents
|
|
15
|
+
- **Smart model routing** — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
|
|
16
|
+
- **One API, 7+ providers** — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
|
|
17
|
+
- **OpenAI-compatible** — swap your `baseUrl`, keep your existing code
|
|
18
|
+
- **Full audit trail** — confidence score, grounded status, model used, latency on every response
|
|
19
|
+
- **Zero dependencies** — uses Node 18+ built-in APIs (fetch, ReadableStream)
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { HttpClient } from 'wauldo';
|
|
25
|
+
|
|
26
|
+
const client = new HttpClient({ baseUrl: 'https://api.wauldo.com', apiKey: 'YOUR_API_KEY' });
|
|
27
|
+
|
|
28
|
+
const reply = await client.chatSimple('auto', 'What is TypeScript?');
|
|
29
|
+
console.log(reply);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install wauldo
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Requirements:** Node.js 18+, TypeScript 5.0+
|
|
39
|
+
|
|
40
|
+
## Features
|
|
41
|
+
|
|
42
|
+
### Chat Completions
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { HttpClient } from 'wauldo';
|
|
46
|
+
|
|
47
|
+
const client = new HttpClient({ baseUrl: 'https://api.wauldo.com', apiKey: 'YOUR_API_KEY' });
|
|
48
|
+
|
|
49
|
+
const response = await client.chat({
|
|
50
|
+
model: 'auto',
|
|
51
|
+
messages: [
|
|
52
|
+
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
53
|
+
{ role: 'user', content: 'Explain async/await in TypeScript' },
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
console.log(response.choices[0]?.message?.content);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### RAG — Upload & Query
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
// Upload a document
|
|
63
|
+
const upload = await client.ragUpload('Contract text here...', 'contract.txt');
|
|
64
|
+
console.log(`Indexed ${upload.chunks_count} chunks`);
|
|
65
|
+
|
|
66
|
+
// Query with verified answer
|
|
67
|
+
const result = await client.ragQuery('What are the payment terms?');
|
|
68
|
+
console.log(`Answer: ${result.answer}`);
|
|
69
|
+
console.log(`Confidence: ${Math.round(result.audit.confidence * 100)}%`);
|
|
70
|
+
console.log(`Grounded: ${result.audit.grounded}`);
|
|
71
|
+
for (const source of result.sources) {
|
|
72
|
+
console.log(` Source (${Math.round(source.score * 100)}%): ${source.content}`);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Streaming (SSE)
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
const stream = client.chatStream({
|
|
80
|
+
model: 'auto',
|
|
81
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
82
|
+
});
|
|
83
|
+
for await (const chunk of stream) {
|
|
84
|
+
process.stdout.write(chunk);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Conversation Helper
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
const conv = client.conversation({ system: 'You are an expert on TypeScript.', model: 'auto' });
|
|
92
|
+
const reply = await conv.say('What are generics?');
|
|
93
|
+
const followUp = await conv.say('Give me an example');
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Error Handling
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { HttpClient, ServerError } from 'wauldo';
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
const response = await client.chat({
|
|
103
|
+
model: 'auto',
|
|
104
|
+
messages: [{ role: 'user', content: 'Hello' }],
|
|
105
|
+
});
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (error instanceof ServerError) {
|
|
108
|
+
console.error(`Server error [${error.code}]: ${error.message}`);
|
|
109
|
+
} else {
|
|
110
|
+
console.error('Unknown error:', error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## RapidAPI
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const client = new HttpClient({
|
|
119
|
+
baseUrl: 'https://api.wauldo.com',
|
|
120
|
+
headers: {
|
|
121
|
+
'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
|
|
122
|
+
'X-RapidAPI-Host': 'smart-rag-api.p.rapidapi.com',
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Get your free API key (300 req/month): [RapidAPI](https://rapidapi.com/binnewzzin/api/smart-rag-api)
|
|
128
|
+
|
|
129
|
+
## Links
|
|
130
|
+
|
|
131
|
+
- [Website](https://wauldo.com)
|
|
132
|
+
- [Documentation](https://wauldo.com/docs)
|
|
133
|
+
- [Live Demo](https://api.wauldo.com/demo)
|
|
134
|
+
- [Cost Calculator](https://wauldo.com/calculator)
|
|
135
|
+
- [Status](https://wauldo.com/status)
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
Found a bug? Have a feature request? [Open an issue](https://github.com/wauldo/wauldo-sdk-js/issues).
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT — see [LICENSE](./LICENSE)
|