@relevanceai/sdk 1.149.0 → 2.0.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.
Files changed (32) hide show
  1. package/README.md +27 -49
  2. package/package.json +3 -2
  3. package/dist-cjs/generated/DiscoveryApi.js +0 -1378
  4. package/dist-cjs/generated/_DiscoveryApiSchemaTypes.js +0 -3
  5. package/dist-cjs/generated/index.js +0 -17
  6. package/dist-cjs/index.js +0 -18
  7. package/dist-cjs/services/discovery/Dataset.js +0 -126
  8. package/dist-cjs/services/discovery/index.js +0 -159
  9. package/dist-cjs/services/index.js +0 -3
  10. package/dist-cjs/shared/BaseClient.js +0 -35
  11. package/dist-cjs/shared/generate.js +0 -90
  12. package/dist-cjs/shared/serviceConfigs.js +0 -10
  13. package/dist-es/generated/DiscoveryApi.js +0 -2123
  14. package/dist-es/generated/_DiscoveryApiSchemaTypes.js +0 -2
  15. package/dist-es/generated/index.js +0 -1
  16. package/dist-es/index.js +0 -2
  17. package/dist-es/services/discovery/Dataset.js +0 -126
  18. package/dist-es/services/discovery/index.js +0 -159
  19. package/dist-es/services/index.js +0 -3
  20. package/dist-es/shared/BaseClient.js +0 -82
  21. package/dist-es/shared/generate.js +0 -224
  22. package/dist-es/shared/serviceConfigs.js +0 -7
  23. package/dist-types/generated/DiscoveryApi.d.ts +0 -518
  24. package/dist-types/generated/_DiscoveryApiSchemaTypes.d.ts +0 -20001
  25. package/dist-types/generated/index.d.ts +0 -1
  26. package/dist-types/index.d.ts +0 -1
  27. package/dist-types/services/discovery/Dataset.d.ts +0 -0
  28. package/dist-types/services/discovery/index.d.ts +0 -0
  29. package/dist-types/services/index.d.ts +0 -0
  30. package/dist-types/shared/BaseClient.d.ts +0 -28
  31. package/dist-types/shared/generate.d.ts +0 -1
  32. package/dist-types/shared/serviceConfigs.d.ts +0 -8
package/README.md CHANGED
@@ -5,20 +5,26 @@ npm i @relevanceai/sdk
5
5
  ```
6
6
  ## Features
7
7
  - Node and Browser support
8
- - Typescript definitions for almost all [relevance.ai](https://relevance.ai/) apis
8
+ - Typescript definitions for almost all [relevanceai.com](https://relevanceai.com/) apis
9
9
  - Insert millions of documents with one function call
10
10
  - Our SearchBuilder makes searching, filtering, and aggregating your data simple
11
11
  # Getting started
12
- Get started in seconds with a demo dataset of popular movies.
12
+ Get started by creating an account in [cloud.relevanceai.com](https://cloud.relevanceai.com) - select the Vector Database onboarding option. Once set up you can fetch your API key and use the below snippet.
13
+
13
14
  ```javascript
14
- import {DiscoveryClient,QueryBuilder} from "@relevanceai/sdk";
15
+ import {VecDBClient,QueryBuilder} from "@relevanceai/sdk";
15
16
 
16
- const discovery = new DiscoveryClient({
17
- project:'dummy-collections',
18
- api_key:'UzdYRktIY0JxNmlvb1NpOFNsenU6VGdTU0s4UjhUR0NsaDdnQTVwUkpKZw',
17
+ const discovery = new VecDBClient({
18
+ project: '',
19
+ api_key: '',
20
+ endpoint: ''
19
21
  });
20
22
  const dataset = discovery.dataset('1000-movies');
21
- const {results} = await dataset.search(QueryBuilder().text('Las Vegas'));
23
+
24
+ const movies = [{ title: 'Lord of the Rings: The Fellowship of the Ring', grenre: 'action', budget: 100 }, ...]
25
+ await dataset.insertDocuments(movies, [{ model_name: 'text-embedding-ada-002', field: 'title' }]);
26
+
27
+ const {results} = await dataset.search(QueryBuilder().vector('title_vector_', { query: 'LOTR', model: 'text-embeddings-ada-002' }));
22
28
  ```
23
29
  ## Set up your credentials
24
30
  ### Option 1 - Use environment variables
@@ -27,7 +33,7 @@ First, set environment variables in your shell before you run your code.
27
33
  set RELEVANCE_PROJECT to your project name.
28
34
 
29
35
  set RELEVANCE_API_KEY to your api key.
30
- for more information, view the docs here: [Authorization docs](https://discovery.relevance.ai/reference/api-usage)
36
+ for more information, view the docs here: [Authorization docs](https://discovery.relevanceai.com/reference/api-usage)
31
37
 
32
38
  Heres a template to copy and paste in for linux environments:
33
39
  ```bash
@@ -36,13 +42,13 @@ export RELEVANCE_API_KEY=#########
36
42
  ```
37
43
  The SDK will use these variables when making api calls. You can then initialise your client like this:
38
44
  ```javascript
39
- import {DiscoveryClient} from "@relevanceai/sdk";
40
- const discovery = new DiscoveryClient({});
45
+ import {VecDBClient} from "@relevanceai/sdk";
46
+ const client = new VecDBClient({});
41
47
  ```
42
48
  ### Option 2 - Passing them in code.
43
49
  ```javascript
44
- import {DiscoveryClient} from "@relevanceai/sdk";
45
- const discovery = new DiscoveryClient({
50
+ import {VecDBClient} from "@relevanceai/sdk";
51
+ const client = new VecDBClient({
46
52
  project:'########',
47
53
  api_key:'########',
48
54
  });
@@ -50,18 +56,18 @@ const discovery = new DiscoveryClient({
50
56
  # Examples
51
57
  ### You can import builders and type definitions like this
52
58
  ```javascript
53
- import {QueryBuilder,DiscoveryClient,BulkInsertOutput} from "@relevanceai/sdk";
59
+ import {QueryBuilder,VecDBClient,BulkInsertOutput} from "@relevanceai/sdk";
54
60
  ```
55
61
  ## Insert millions of items with one function call
56
62
  ```javascript
57
- const discovery = new DiscoveryClient({ });
63
+ const discovery = new VecDBClient({ ... });
58
64
  const dataset = discovery.dataset('tshirts-prod');
59
65
  // Here we create some demo data. Replace this with your real data
60
66
  const fakeVector = [];
61
67
  for (let i = 0; i < 768; i++) fakeVector.push(1);
62
68
  const tshirtsData = [];
63
69
  for (let i = 0; i < 10000; i++) {
64
- tshirtsData.push({_id:`tshirt-${i}1`,color:'red',price:i/1000,'title_text@1-0_vector_':fakeVector});
70
+ tshirtsData.push({_id:`tshirt-${i}1`,color:'red',price:i/1000,'title-fake_vector_':fakeVector});
65
71
  tshirtsData.push({_id:`tshirt-${i}2`,color:'blue',price:i/1000});
66
72
  tshirtsData.push({_id:`tshirt-${i}3`,color:'orange',price:i/1000});
67
73
  }
@@ -74,7 +80,7 @@ const res = await dataset.insertDocuments(tshirtsData,{batchSize:10000});
74
80
  ## Text Search and Vector Search
75
81
  ```javascript
76
82
  const builder = QueryBuilder();
77
- builder.query('red').text().vector('title_text@1-0_vector_',0.5).minimumRelevance(0.1);
83
+ builder.query('red').text().vector('title-fake_vector_',0.5).minimumRelevance(0.1);
78
84
  // .text() searches all fields. alternatively, use .text(field1).text(field2)... to search specific fields
79
85
  const searchResults = await dataset.search(builder);
80
86
  ```
@@ -103,41 +109,13 @@ const filteredItems = await dataset.search(filters);
103
109
  aggregateStats: {}
104
110
  }
105
111
  ```
106
- ## Summarise your data using aggregations
107
- ```javascript
108
- const aggregates = QueryBuilder();
109
- aggregates.aggregate('color').aggregateStats('price',10);
110
- const aggregatesResult = await dataset.search(aggregates);
111
- ```
112
- ### aggregates will output:
113
- ```javascript
114
- {
115
- aggregates:{
116
- color: {
117
- results: { blue: 10000, orange: 10000, red: 10000 },
118
- aggregates: {}
119
- },
120
- price: {
121
- results: {
122
- '0': 0000,
123
- '10': 3000,
124
- '20': 3000,
125
- '30': 3000,
126
- '40': 3000,
127
- '50': 3000,
128
- '60': 3000,
129
- '70': 3000,
130
- '80': 3000,
131
- '90': 3000
132
- },
133
- aggregates: {}
134
- }
135
- }
136
- }
112
+
113
+
137
114
  ```
138
115
  ## Call raw api methods directly
139
116
  ```javascript
140
- const rawClient = new DiscoveryApiClient({dataset_id:'tshirts-prod'});
141
- const {body} = await rawClient.FastSearch({filters:[{match:{key:'_id',value:`tshirt-01`}}]});
117
+ const discovery = new VecDBClient({ ... });
118
+ const dataset = discovery.dataset('tshirts-prod');
119
+ const {body} = await dataset.apiClient.FastSearch({filters:[{match:{key:'_id',value:`tshirt-01`}}]});
142
120
  expect((body.results[0] as any).color).toBe('red')
143
121
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relevanceai/sdk",
3
- "version": "1.149.0",
3
+ "version": "2.0.0",
4
4
  "description": "Javascript client for RelevanceAI APIs. Browser, Node.js and typescript support.",
5
5
  "main": "./dist-cjs/index.js",
6
6
  "types": "./dist-types/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  "build": "tsc -p tsconfig.json && tsc -p tsconfig.es.json && tsc -p tsconfig.types.json",
13
13
  "generate": "ts-node ./src/shared/generate.ts",
14
14
  "test": "jest",
15
- "prepare": "npm run build"
15
+ "prepare": "npm run build",
16
+ "sample": "ts-node ./test/sample.test.mjs"
16
17
  },
17
18
  "repository": {
18
19
  "type": "git",