nosible 0.1.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 +438 -0
- package/dist/index.cjs +1841 -0
- package/dist/index.cjs.map +29 -0
- package/dist/index.js +1815 -0
- package/dist/index.js.map +29 -0
- package/package.json +63 -0
- package/src/api/api.test.ts +366 -0
- package/src/api/index.ts +179 -0
- package/src/api/schemas.ts +152 -0
- package/src/client.test.ts +685 -0
- package/src/client.ts +762 -0
- package/src/index.ts +4 -0
- package/src/scrape/types.ts +119 -0
- package/src/scrape/webPageData.test.ts +302 -0
- package/src/scrape/webPageData.ts +103 -0
- package/src/search/analyze.test.ts +396 -0
- package/src/search/analyze.ts +151 -0
- package/src/search/bulkSearch.ts +62 -0
- package/src/search/result.test.ts +423 -0
- package/src/search/result.ts +391 -0
- package/src/search/result.types.ts +32 -0
- package/src/search/resultFactory.ts +21 -0
- package/src/search/resultSet.io.test.ts +320 -0
- package/src/search/resultSet.test.ts +368 -0
- package/src/search/resultSet.ts +387 -0
- package/src/search/resultSet.types.ts +3 -0
- package/src/search/search.test.ts +299 -0
- package/src/search/search.ts +187 -0
- package/src/search/searchSet.io.test.ts +321 -0
- package/src/search/searchSet.ts +122 -0
- package/src/search/sqlFilter.test.ts +129 -0
- package/src/search/sqlFilter.ts +147 -0
- package/src/test-utils/mocks.ts +159 -0
- package/src/topicTrend/topicTrend.ts +53 -0
- package/src/utils/browser.test.ts +209 -0
- package/src/utils/browser.ts +21 -0
- package/src/utils/fernet.ts +47 -0
- package/src/utils/file.test.ts +81 -0
- package/src/utils/file.ts +195 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/llm.test.ts +279 -0
- package/src/utils/llm.ts +244 -0
- package/src/utils/userPlan.test.ts +332 -0
- package/src/utils/userPlan.ts +211 -0
package/README.md
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/nosible)
|
|
2
|
+
[](https://github.com/NosibleAI/nosible-js/actions)
|
|
3
|
+
[](https://www.typescriptlang.org/)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
# NOSIBLE Search Client
|
|
7
|
+
|
|
8
|
+
A high-level TypeScript/JavaScript client for the [NOSIBLE Search API](https://www.nosible.ai/search/v2/docs/#/).
|
|
9
|
+
Easily integrate the Nosible Search API into your TypeScript and JavaScript projects.
|
|
10
|
+
|
|
11
|
+
## 📄 Documentation
|
|
12
|
+
|
|
13
|
+
You can find the full NOSIBLE Search Client documentation and examples in the [website/docs](./website/docs) directory.
|
|
14
|
+
|
|
15
|
+
## 📦 Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install nosible
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## ⚡ Installing with other package managers
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Using yarn
|
|
25
|
+
yarn add nosible
|
|
26
|
+
|
|
27
|
+
# Using bun
|
|
28
|
+
bun add nosible
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Requirements**:
|
|
32
|
+
|
|
33
|
+
- Node.js 18+
|
|
34
|
+
- TypeScript 5+ (for TypeScript projects)
|
|
35
|
+
|
|
36
|
+
**Dependencies**:
|
|
37
|
+
|
|
38
|
+
- duckdb
|
|
39
|
+
- nodejs-polars
|
|
40
|
+
- apache-arrow
|
|
41
|
+
- openai
|
|
42
|
+
- lunr
|
|
43
|
+
- papaparse
|
|
44
|
+
- zod
|
|
45
|
+
- bottleneck
|
|
46
|
+
- simple-statistics
|
|
47
|
+
|
|
48
|
+
## 🔑 Authentication
|
|
49
|
+
|
|
50
|
+
1. Sign in to [NOSIBLE.AI](https://www.nosible.ai/) and grab your free API key.
|
|
51
|
+
2. Set it as an environment variable or pass directly:
|
|
52
|
+
|
|
53
|
+
### On Windows
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
$Env:NOSIBLE_API_KEY="basic|abcd1234..."
|
|
57
|
+
$Env:LLM_API_KEY="sk-..." # for query expansions (optional)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### On macOS/Linux
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
export NOSIBLE_API_KEY="basic|abcd1234..."
|
|
64
|
+
export LLM_API_KEY="sk-..." # for query expansions (optional)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Or in code
|
|
68
|
+
|
|
69
|
+
As an argument:
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
import {NosibleClient} from "nosible";
|
|
73
|
+
|
|
74
|
+
const client = new NosibleClient({
|
|
75
|
+
apiKey: "basic|abcd1234...",
|
|
76
|
+
llmApiKey: "sk-...", // optional, for LLM features
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
As an environment variable:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import {NosibleClient} from "nosible";
|
|
84
|
+
|
|
85
|
+
process.env.NOSIBLE_API_KEY = "basic|abcd1234...";
|
|
86
|
+
process.env.LLM_API_KEY = "sk-...";
|
|
87
|
+
|
|
88
|
+
const client = new NosibleClient();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 🔍 Your first search
|
|
92
|
+
|
|
93
|
+
To complete your first search:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import {NosibleClient} from "nosible";
|
|
97
|
+
|
|
98
|
+
const client = new NosibleClient({apiKey: "YOUR API KEY"});
|
|
99
|
+
|
|
100
|
+
const results = await client.fastSearch({
|
|
101
|
+
question: "What is Artificial General Intelligence?",
|
|
102
|
+
nResults: 20,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
console.log(results);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## 🤖 AI-Powered Search
|
|
109
|
+
|
|
110
|
+
An AI agent with access to advanced search capabilities in NOSIBLE. It can understand complex queries and provide contextually relevant results.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import {NosibleClient} from "nosible";
|
|
114
|
+
|
|
115
|
+
const client = new NosibleClient({apiKey: "YOUR API KEY"});
|
|
116
|
+
|
|
117
|
+
const results = await client.aiSearch({
|
|
118
|
+
// aiSearch() gives you access to AI-powered search
|
|
119
|
+
prompt: "Find me interesting technical blogs about Monte Carlo Tree Search.",
|
|
120
|
+
agent: "research",
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
console.log(results);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## ✨ Features
|
|
127
|
+
|
|
128
|
+
- 🚀 **Fast Search** - Quick searches optimized for speed (10-100 results)
|
|
129
|
+
- 🤖 **AI Search** - Advanced AI-powered searches with custom instructions
|
|
130
|
+
- 📦 **Bulk Search** - Large-scale data retrieval (1000-10000 results)
|
|
131
|
+
- 🔄 **Parallel Searches** - Execute multiple searches concurrently
|
|
132
|
+
- 🌐 **URL Scraping** - Extract structured content from web pages
|
|
133
|
+
- 📈 **Topic Trends** - Analyze topic popularity over time
|
|
134
|
+
- 🎯 **Advanced Filtering** - SQL filters, date ranges, geographic filters, and more
|
|
135
|
+
- ✅ **Type Safe** - Full TypeScript support with IntelliSense
|
|
136
|
+
- 🔒 **Secure** - API key authentication
|
|
137
|
+
|
|
138
|
+
## 📖 Usage Examples
|
|
139
|
+
|
|
140
|
+
### Fast Search
|
|
141
|
+
|
|
142
|
+
Quick searches with configurable result limits (10-100 results):
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import {NosibleClient} from "nosible";
|
|
146
|
+
|
|
147
|
+
const client = new NosibleClient();
|
|
148
|
+
|
|
149
|
+
// Basic fast search
|
|
150
|
+
const results = await client.fastSearch({
|
|
151
|
+
question: "latest AI technology trends",
|
|
152
|
+
nResults: 20,
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
console.log(`Found ${results.length} results`);
|
|
156
|
+
for (const result of results) {
|
|
157
|
+
console.log(`Title: ${result.title}`);
|
|
158
|
+
console.log(`URL: ${result.url}`);
|
|
159
|
+
console.log(`Similarity: ${result.similarity}`);
|
|
160
|
+
console.log(`Published: ${result.published}`);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Advanced Fast Search with Filters
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
// Search with advanced filtering options
|
|
168
|
+
const filteredResults = await client.fastSearch({
|
|
169
|
+
question: "machine learning startups",
|
|
170
|
+
nResults: 50,
|
|
171
|
+
algorithm: "hybrid-2",
|
|
172
|
+
minSimilarity: 0.7,
|
|
173
|
+
mustInclude: ["artificial intelligence", "funding"],
|
|
174
|
+
mustExclude: ["cryptocurrency"],
|
|
175
|
+
continent: "North America",
|
|
176
|
+
brandSafety: "high",
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### AI-Powered Search
|
|
181
|
+
|
|
182
|
+
Advanced searches with custom instructions:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// AI search with custom instructions
|
|
186
|
+
const aiResults = await client.aiSearch({
|
|
187
|
+
prompt:
|
|
188
|
+
"What are the environmental impacts of renewable energy? Focus on recent studies and quantitative data from the last 2 years.",
|
|
189
|
+
agent: "research",
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
console.log(aiResults);
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Parallel Searches
|
|
196
|
+
|
|
197
|
+
Execute multiple searches concurrently:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
// Search multiple topics in parallel
|
|
201
|
+
const results = await client.fastSearches({
|
|
202
|
+
questions: ["AI in healthcare", "AI in finance", "AI in education"],
|
|
203
|
+
nResults: 20,
|
|
204
|
+
algorithm: "hybrid-2",
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
// Each result is a separate ResultSet
|
|
208
|
+
results.forEach((resultSet, index) => {
|
|
209
|
+
console.log(`Query ${index + 1}: ${resultSet.length} results`);
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Using the Search Class
|
|
214
|
+
|
|
215
|
+
Create reusable search configurations:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import {NosibleClient, Search} from "nosible";
|
|
219
|
+
|
|
220
|
+
const client = new NosibleClient();
|
|
221
|
+
|
|
222
|
+
// Create a search with specific parameters
|
|
223
|
+
const search = new Search({
|
|
224
|
+
question: "quantum computing breakthroughs",
|
|
225
|
+
nResults: 30,
|
|
226
|
+
algorithm: "hybrid-3",
|
|
227
|
+
continent: "Europe",
|
|
228
|
+
publishStart: new Date("2024-01-01"),
|
|
229
|
+
publishEnd: new Date("2025-01-01"),
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// Execute the search
|
|
233
|
+
const results = await client.fastSearch({search});
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Bulk Search
|
|
237
|
+
|
|
238
|
+
Large-scale data collection (1000-10000 results):
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
// Bulk search for comprehensive data gathering
|
|
242
|
+
const bulkResults = await client.bulkSearch({
|
|
243
|
+
question: "all articles about artificial intelligence",
|
|
244
|
+
nResults: 5000,
|
|
245
|
+
algorithm: "hybrid-2",
|
|
246
|
+
minSimilarity: 0.6,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
console.log(`Retrieved ${bulkResults.length} results`);
|
|
250
|
+
|
|
251
|
+
// Export to JSON for analysis
|
|
252
|
+
const data = bulkResults.toJSON();
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### URL Scraping
|
|
256
|
+
|
|
257
|
+
Extract structured content from web pages:
|
|
258
|
+
|
|
259
|
+
```typescript
|
|
260
|
+
// Scrape a specific URL
|
|
261
|
+
const webpage = await client.scrapeUrl("https://example.com/article");
|
|
262
|
+
|
|
263
|
+
console.log(`Title: ${webpage.title}`);
|
|
264
|
+
console.log(`Author: ${webpage.author}`);
|
|
265
|
+
console.log(`Published: ${webpage.published}`);
|
|
266
|
+
console.log(`Content: ${webpage.content}`);
|
|
267
|
+
|
|
268
|
+
// Scrape search results
|
|
269
|
+
const searchResults = await client.fastSearch({
|
|
270
|
+
question: "latest tech news",
|
|
271
|
+
nResults: 5,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
for (const result of searchResults) {
|
|
275
|
+
const fullArticle = await client.scrapeUrl(result.url);
|
|
276
|
+
console.log(`Full article: ${fullArticle.content}`);
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Topic Trends Analysis
|
|
281
|
+
|
|
282
|
+
Analyze topic popularity over time:
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
// Analyze trends for a topic
|
|
286
|
+
const trends = await client.topicTrend("artificial intelligence");
|
|
287
|
+
|
|
288
|
+
console.log(`Topic: ${trends.query}`);
|
|
289
|
+
console.log(`Data points: ${trends.data.length}`);
|
|
290
|
+
|
|
291
|
+
trends.data.forEach((point) => {
|
|
292
|
+
console.log(`Date: ${point.date}, Popularity: ${point.popularity}`);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Trend analysis with filtering
|
|
296
|
+
const filteredTrends = await client.topicTrend(
|
|
297
|
+
"machine learning",
|
|
298
|
+
'continent = "North America" AND published >= "2023-01-01"'
|
|
299
|
+
);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Advanced Filtering with SQL Filters
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
// Search with date range filters
|
|
306
|
+
const recentResults = await client.fastSearch({
|
|
307
|
+
question: "climate change solutions",
|
|
308
|
+
nResults: 50,
|
|
309
|
+
publishStart: new Date("2024-01-01"),
|
|
310
|
+
publishEnd: new Date("2025-01-01"),
|
|
311
|
+
certain: true, // Only verified/certain results
|
|
312
|
+
includeNetlocs: ["nature.com", "sciencedaily.com"],
|
|
313
|
+
excludeNetlocs: ["example.com"],
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Search specific companies
|
|
317
|
+
const companyResults = await client.fastSearch({
|
|
318
|
+
question: "product launches",
|
|
319
|
+
nResults: 30,
|
|
320
|
+
companies: ["Apple", "Google", "Microsoft"],
|
|
321
|
+
industry: "Technology",
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Client Configuration with Defaults
|
|
326
|
+
|
|
327
|
+
```typescript
|
|
328
|
+
// Initialize client with default search parameters
|
|
329
|
+
const client = new NosibleClient({
|
|
330
|
+
apiKey: "your-api-key",
|
|
331
|
+
searchDefaults: {
|
|
332
|
+
nResults: 50,
|
|
333
|
+
algorithm: "hybrid-2",
|
|
334
|
+
continent: "North America",
|
|
335
|
+
brandSafety: "high",
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// All searches will use these defaults unless overridden
|
|
340
|
+
const results = await client.fastSearch({
|
|
341
|
+
question: "tech startups",
|
|
342
|
+
// Will use nResults: 50, algorithm: 'hybrid-2', etc.
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Working with ResultSet
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
// ResultSet provides enhanced functionality
|
|
350
|
+
const results = await client.fastSearch({
|
|
351
|
+
question: "renewable energy",
|
|
352
|
+
nResults: 100,
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Access results as array
|
|
356
|
+
console.log(`Total: ${results.length}`);
|
|
357
|
+
|
|
358
|
+
// Iterate through results
|
|
359
|
+
for (const result of results) {
|
|
360
|
+
console.log(result.title);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Convert to JSON for export
|
|
364
|
+
const jsonData = results.toJSON();
|
|
365
|
+
|
|
366
|
+
// Filter and sort
|
|
367
|
+
const highQuality = results.filter((r) => r.similarity > 0.8);
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## 🛠️ Development
|
|
371
|
+
|
|
372
|
+
Contributing to this package:
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Install dependencies
|
|
376
|
+
bun install
|
|
377
|
+
|
|
378
|
+
# Run tests
|
|
379
|
+
bun test
|
|
380
|
+
|
|
381
|
+
# Build the package
|
|
382
|
+
bun run build
|
|
383
|
+
|
|
384
|
+
# Generate documentation
|
|
385
|
+
bun run docs:generate
|
|
386
|
+
|
|
387
|
+
# Start documentation dev server
|
|
388
|
+
bun run docs:dev
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## 🏗️ Project Structure
|
|
392
|
+
|
|
393
|
+
```text
|
|
394
|
+
nosible-js/
|
|
395
|
+
├── src/
|
|
396
|
+
│ ├── api/ # API client and schemas
|
|
397
|
+
│ ├── client.ts # Main NosibleClient class
|
|
398
|
+
│ ├── search/ # Search functionality and classes
|
|
399
|
+
│ ├── scrape/ # URL scraping functionality
|
|
400
|
+
│ ├── topicTrend/ # Topic trend analysis
|
|
401
|
+
│ ├── utils/ # Utility functions
|
|
402
|
+
│ └── index.ts # Package exports
|
|
403
|
+
├── website/ # Docusaurus documentation site
|
|
404
|
+
│ ├── docs/ # Documentation pages
|
|
405
|
+
│ └── src/ # Custom pages and components
|
|
406
|
+
├── dist/ # Built package (generated)
|
|
407
|
+
└── package.json # Package configuration
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## 📚 Additional Examples
|
|
411
|
+
|
|
412
|
+
For more detailed examples and guides:
|
|
413
|
+
|
|
414
|
+
- [Getting Started Guide](./website/docs/getting-started.md)
|
|
415
|
+
- [Examples](./website/docs/examples.md)
|
|
416
|
+
- [API Reference](./website/docs/api/) (auto-generated with TypeDoc)
|
|
417
|
+
|
|
418
|
+
Run the documentation site locally:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
bun run docs:dev
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
## 🤝 Contributing
|
|
425
|
+
|
|
426
|
+
Contributions are welcome! Please ensure tests pass and documentation is updated.
|
|
427
|
+
|
|
428
|
+
## 📡 API Reference
|
|
429
|
+
|
|
430
|
+
View the complete [NOSIBLE Search API Swagger Documentation](https://www.nosible.ai/search/v2/docs/#/) for detailed endpoint information.
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
© 2025 Nosible Inc. | [Privacy Policy](https://www.nosible.ai/privacy) | [Terms](https://www.nosible.ai/terms)
|
|
435
|
+
|
|
436
|
+
## 📄 License
|
|
437
|
+
|
|
438
|
+
MIT
|