@embed-ai/sdk 0.1.2 → 0.1.4
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/package.json +13 -4
- package/src/client.d.ts +15 -1
- package/src/client.js +33 -20
- package/src/feed/index.js +22 -33
- package/src/feed/namespace.d.ts +7 -8
- package/src/feed/namespace.js +13 -14
- package/src/index.js +21 -16
- package/src/interfaces/index.js +20 -11
- package/src/search/index.d.ts +2 -0
- package/src/search/index.js +14 -0
- package/src/search/namespace.d.ts +182 -0
- package/src/search/namespace.js +209 -0
- package/src/search/post.d.ts +45 -0
- package/src/search/post.js +70 -0
- package/src/search/user.d.ts +80 -0
- package/src/search/user.js +124 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embed-ai/sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"main": "src/index.js",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"description": "The typescript sdk package for embed AI APIs.",
|
|
7
7
|
"repository": {
|
|
@@ -26,11 +26,20 @@
|
|
|
26
26
|
"build-annotate": "babel dist --plugins annotate-pure-calls --out-dir dist --source-maps",
|
|
27
27
|
"fix-deps": "bun scripts/fix-deps.js",
|
|
28
28
|
"check": "tsc -b tsconfig.json",
|
|
29
|
-
"test": "
|
|
29
|
+
"test": "echo '⚠️ No unit tests available - SDK tests require API keys' && echo ' Run test:integration instead'",
|
|
30
|
+
"test:integration": "vitest run --reporter=verbose",
|
|
31
|
+
"test:ui": "vitest --ui",
|
|
32
|
+
"test:posts": "vitest run test/search-posts.test.ts",
|
|
33
|
+
"test:users": "vitest run test/search-users.test.ts",
|
|
34
|
+
"test:feed": "vitest run test/feed.test.ts",
|
|
30
35
|
"coverage": "vitest --coverage"
|
|
31
36
|
},
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"@embed-ai/types": "^0.1.
|
|
38
|
+
"@embed-ai/types": "^0.1.3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@effect/vitest": "latest",
|
|
42
|
+
"vitest": "latest"
|
|
34
43
|
},
|
|
35
44
|
"peerDependencies": {
|
|
36
45
|
"effect": ">=3.0.0"
|
package/src/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FeedNamespace } from "./feed/namespace.js";
|
|
2
|
+
import { SearchNamespace } from "./search/namespace.js";
|
|
2
3
|
declare const NetworkError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
3
4
|
readonly _tag: "NetworkError";
|
|
4
5
|
} & Readonly<A>;
|
|
@@ -105,7 +106,7 @@ export interface mbdClientConfig {
|
|
|
105
106
|
readonly retry?: RetryConfig;
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
|
-
* Main Embed API client providing access to personalized feeds
|
|
109
|
+
* Main Embed API client providing access to personalized feeds, feed management, and search
|
|
109
110
|
*
|
|
110
111
|
* @example
|
|
111
112
|
* ```typescript
|
|
@@ -121,11 +122,18 @@ export interface mbdClientConfig {
|
|
|
121
122
|
* name: 'My Custom Feed',
|
|
122
123
|
* description: 'A feed for my app'
|
|
123
124
|
* })
|
|
125
|
+
*
|
|
126
|
+
* // Search for similar users
|
|
127
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
128
|
+
*
|
|
129
|
+
* // Search users by query
|
|
130
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
124
131
|
* ```
|
|
125
132
|
*/
|
|
126
133
|
export declare class mbdClient {
|
|
127
134
|
private http;
|
|
128
135
|
readonly feed: FeedNamespace;
|
|
136
|
+
readonly search: SearchNamespace;
|
|
129
137
|
constructor(token?: string, options?: mbdClientConfig);
|
|
130
138
|
}
|
|
131
139
|
/**
|
|
@@ -151,6 +159,12 @@ export declare class mbdClient {
|
|
|
151
159
|
* description: 'A feed for my app'
|
|
152
160
|
* })
|
|
153
161
|
*
|
|
162
|
+
* // Search for similar users
|
|
163
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
164
|
+
*
|
|
165
|
+
* // Search users by query
|
|
166
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
167
|
+
*
|
|
154
168
|
* // With configuration
|
|
155
169
|
* const client = getClient('your-api-key', {
|
|
156
170
|
* retry: {
|
package/src/client.js
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TimeoutError = exports.ParseError = exports.
|
|
6
|
+
exports.mbdClient = exports.TimeoutError = exports.ParseError = exports.HttpRequestError = exports.NetworkError = void 0;
|
|
7
7
|
exports.getClient = getClient;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
8
|
+
const effect_1 = /*#__PURE__*/require("effect");
|
|
9
|
+
const Data = /*#__PURE__*/require("effect/Data");
|
|
10
|
+
const Effect = /*#__PURE__*/require("effect/Effect");
|
|
11
|
+
const Schedule = /*#__PURE__*/require("effect/Schedule");
|
|
12
|
+
const namespace_js_1 = /*#__PURE__*/require("./feed/namespace.js");
|
|
13
|
+
const namespace_js_2 = /*#__PURE__*/require("./search/namespace.js");
|
|
15
14
|
// ============================================================================
|
|
16
15
|
// ERROR TYPES
|
|
17
16
|
// ============================================================================
|
|
@@ -19,25 +18,25 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
19
18
|
* Network-related errors (connection issues, DNS failures, etc.)
|
|
20
19
|
*/
|
|
21
20
|
class NetworkError extends Data.TaggedError("NetworkError") {}
|
|
21
|
+
exports.NetworkError = NetworkError;
|
|
22
22
|
/**
|
|
23
23
|
* HTTP response errors (4xx, 5xx status codes)
|
|
24
24
|
*/
|
|
25
|
-
exports.NetworkError = NetworkError;
|
|
26
25
|
class HttpRequestError extends Data.TaggedError("HttpRequestError") {}
|
|
26
|
+
exports.HttpRequestError = HttpRequestError;
|
|
27
27
|
/**
|
|
28
28
|
* JSON parsing errors
|
|
29
29
|
*/
|
|
30
|
-
exports.HttpRequestError = HttpRequestError;
|
|
31
30
|
class ParseError extends Data.TaggedError("ParseError") {}
|
|
31
|
+
exports.ParseError = ParseError;
|
|
32
32
|
/**
|
|
33
33
|
* Timeout errors
|
|
34
34
|
*/
|
|
35
|
-
exports.ParseError = ParseError;
|
|
36
35
|
class TimeoutError extends Data.TaggedError("TimeoutError") {}
|
|
36
|
+
exports.TimeoutError = TimeoutError;
|
|
37
37
|
/**
|
|
38
38
|
* Default retry configuration
|
|
39
39
|
*/
|
|
40
|
-
exports.TimeoutError = TimeoutError;
|
|
41
40
|
const DEFAULT_RETRY_CONFIG = {
|
|
42
41
|
exponentialBackoff: true,
|
|
43
42
|
initialDelay: 1000,
|
|
@@ -77,7 +76,7 @@ class HttpClient {
|
|
|
77
76
|
* Create a timeout effect that fails after the specified duration
|
|
78
77
|
*/
|
|
79
78
|
createTimeoutEffect(timeoutMs) {
|
|
80
|
-
return (0,
|
|
79
|
+
return (0, effect_1.pipe)(Effect.sleep(`${timeoutMs} millis`), Effect.flatMap(() => Effect.fail(new TimeoutError({
|
|
81
80
|
message: `Request timed out after ${timeoutMs}ms`,
|
|
82
81
|
timeoutMs
|
|
83
82
|
}))));
|
|
@@ -170,12 +169,12 @@ class HttpClient {
|
|
|
170
169
|
} = this.config.retry;
|
|
171
170
|
let baseSchedule;
|
|
172
171
|
if (exponentialBackoff) {
|
|
173
|
-
baseSchedule = (0,
|
|
172
|
+
baseSchedule = (0, effect_1.pipe)(Schedule.exponential(`${initialDelay} millis`), Schedule.either(Schedule.spaced(`${maxDelay} millis`)), Schedule.compose(Schedule.recurs(maxRetries)));
|
|
174
173
|
} else {
|
|
175
|
-
baseSchedule = (0,
|
|
174
|
+
baseSchedule = (0, effect_1.pipe)(Schedule.spaced(`${initialDelay} millis`), Schedule.compose(Schedule.recurs(maxRetries)));
|
|
176
175
|
}
|
|
177
176
|
// Only retry on specific errors
|
|
178
|
-
return (0,
|
|
177
|
+
return (0, effect_1.pipe)(baseSchedule, Schedule.whileInput(error => {
|
|
179
178
|
switch (error._tag) {
|
|
180
179
|
case "NetworkError":
|
|
181
180
|
return true;
|
|
@@ -203,7 +202,7 @@ class HttpClient {
|
|
|
203
202
|
const requestWithTimeout = Effect.race(fetchEffect, timeoutEffect);
|
|
204
203
|
// Apply retry logic
|
|
205
204
|
const retrySchedule = this.createRetrySchedule();
|
|
206
|
-
return (0,
|
|
205
|
+
return (0, effect_1.pipe)(requestWithTimeout, Effect.retry(retrySchedule), Effect.tapError(error => Effect.logError("HTTP request failed after retries", error)));
|
|
207
206
|
}
|
|
208
207
|
/**
|
|
209
208
|
* Make a POST request to the API with Effect-based error handling and retries
|
|
@@ -238,7 +237,7 @@ class HttpClient {
|
|
|
238
237
|
// MAIN CLIENT
|
|
239
238
|
// ============================================================================
|
|
240
239
|
/**
|
|
241
|
-
* Main Embed API client providing access to personalized feeds
|
|
240
|
+
* Main Embed API client providing access to personalized feeds, feed management, and search
|
|
242
241
|
*
|
|
243
242
|
* @example
|
|
244
243
|
* ```typescript
|
|
@@ -254,11 +253,18 @@ class HttpClient {
|
|
|
254
253
|
* name: 'My Custom Feed',
|
|
255
254
|
* description: 'A feed for my app'
|
|
256
255
|
* })
|
|
256
|
+
*
|
|
257
|
+
* // Search for similar users
|
|
258
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
259
|
+
*
|
|
260
|
+
* // Search users by query
|
|
261
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
257
262
|
* ```
|
|
258
263
|
*/
|
|
259
264
|
class mbdClient {
|
|
260
265
|
http;
|
|
261
266
|
feed;
|
|
267
|
+
search;
|
|
262
268
|
constructor(token, options) {
|
|
263
269
|
if (!token && !options?.token) {
|
|
264
270
|
throw new Error("Token is required");
|
|
@@ -268,9 +274,11 @@ class mbdClient {
|
|
|
268
274
|
...options
|
|
269
275
|
};
|
|
270
276
|
this.http = new HttpClient(config);
|
|
271
|
-
this.feed = new
|
|
277
|
+
this.feed = new namespace_js_1.FeedNamespace(this.http);
|
|
278
|
+
this.search = new namespace_js_2.SearchNamespace(this.http);
|
|
272
279
|
}
|
|
273
280
|
}
|
|
281
|
+
exports.mbdClient = mbdClient;
|
|
274
282
|
/**
|
|
275
283
|
* Get a new Embed Client instance
|
|
276
284
|
*
|
|
@@ -294,6 +302,12 @@ class mbdClient {
|
|
|
294
302
|
* description: 'A feed for my app'
|
|
295
303
|
* })
|
|
296
304
|
*
|
|
305
|
+
* // Search for similar users
|
|
306
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
307
|
+
*
|
|
308
|
+
* // Search users by query
|
|
309
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
310
|
+
*
|
|
297
311
|
* // With configuration
|
|
298
312
|
* const client = getClient('your-api-key', {
|
|
299
313
|
* retry: {
|
|
@@ -303,7 +317,6 @@ class mbdClient {
|
|
|
303
317
|
* })
|
|
304
318
|
* ```
|
|
305
319
|
*/
|
|
306
|
-
exports.mbdClient = mbdClient;
|
|
307
320
|
function getClient(token, options) {
|
|
308
321
|
return new mbdClient(token, options);
|
|
309
322
|
}
|
package/src/feed/index.js
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
3
22
|
Object.defineProperty(exports, "__esModule", {
|
|
4
23
|
value: true
|
|
5
24
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (key in exports && exports[key] === _feed[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _feed[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _management = require("./management.js");
|
|
18
|
-
Object.keys(_management).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _management[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _management[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _namespace = require("./namespace.js");
|
|
29
|
-
Object.keys(_namespace).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _namespace[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _namespace[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
25
|
+
__exportStar(require("./feed.js"), exports);
|
|
26
|
+
__exportStar(require("./management.js"), exports);
|
|
27
|
+
__exportStar(require("./namespace.js"), exports);
|
|
39
28
|
//# sourceMappingURL=index.js.map
|
package/src/feed/namespace.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ForYouResponse, ListFeedsResponse
|
|
1
|
+
import type { CreateFeedOptions, FeedCreateUpdateResponse, FeedGetResponse, ForYouResponse, ListFeedsResponse } from "@embed-ai/types";
|
|
2
2
|
import type { IHttpClient } from "../interfaces/index.js";
|
|
3
3
|
import type { FeedOptions } from "./feed.js";
|
|
4
4
|
/**
|
|
@@ -8,8 +8,8 @@ import type { FeedOptions } from "./feed.js";
|
|
|
8
8
|
* ```typescript
|
|
9
9
|
* const client = getClient('your-api-key')
|
|
10
10
|
*
|
|
11
|
-
* // Get personalized feed
|
|
12
|
-
* const feed = await client.feed.byUserId('16085')
|
|
11
|
+
* // Get personalized feed based on the For-You template
|
|
12
|
+
* const feed = await client.feed.byUserId('16085', 'feed_390')
|
|
13
13
|
*
|
|
14
14
|
* // Create a custom feed
|
|
15
15
|
* const customFeed = await client.feed.createConfig({
|
|
@@ -32,7 +32,7 @@ export declare class FeedNamespace {
|
|
|
32
32
|
* @example
|
|
33
33
|
* ```typescript
|
|
34
34
|
* const client = getClient("your-api-key")
|
|
35
|
-
* const feed = await client.feed.byUserId("16085", {
|
|
35
|
+
* const feed = await client.feed.byUserId("16085", "feed_390", {
|
|
36
36
|
* top_k: 10,
|
|
37
37
|
* return_metadata: true
|
|
38
38
|
* })
|
|
@@ -52,7 +52,7 @@ export declare class FeedNamespace {
|
|
|
52
52
|
* @example
|
|
53
53
|
* ```typescript
|
|
54
54
|
* const client = getClient("your-api-key")
|
|
55
|
-
* const feed = await client.feed.byWalletAddress("0x1234...", {
|
|
55
|
+
* const feed = await client.feed.byWalletAddress("0x1234...", "feed_390", {
|
|
56
56
|
* top_k: 15,
|
|
57
57
|
* })
|
|
58
58
|
* console.log(feed[0].metadata?.author.username) // Access author username
|
|
@@ -124,8 +124,7 @@ export declare class FeedNamespace {
|
|
|
124
124
|
* @example
|
|
125
125
|
* ```typescript
|
|
126
126
|
* const client = getClient("your-api-key")
|
|
127
|
-
* await client.feed.updateConfig({
|
|
128
|
-
* config_id: "feed_123",
|
|
127
|
+
* await client.feed.updateConfig("feed_123", {
|
|
129
128
|
* name: "Updated Feed Name",
|
|
130
129
|
* config: {
|
|
131
130
|
* filters: {
|
|
@@ -136,6 +135,6 @@ export declare class FeedNamespace {
|
|
|
136
135
|
* console.log("Feed updated successfully")
|
|
137
136
|
* ```
|
|
138
137
|
*/
|
|
139
|
-
updateConfig(feedId: string, options:
|
|
138
|
+
updateConfig(feedId: string, options: CreateFeedOptions): Promise<void>;
|
|
140
139
|
}
|
|
141
140
|
//# sourceMappingURL=namespace.d.ts.map
|
package/src/feed/namespace.js
CHANGED
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.FeedNamespace = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const feed_js_1 = /*#__PURE__*/require("./feed.js");
|
|
8
|
+
const management_js_1 = /*#__PURE__*/require("./management.js");
|
|
9
9
|
/**
|
|
10
10
|
* Feed namespace containing all feed-related operations
|
|
11
11
|
*
|
|
@@ -13,8 +13,8 @@ var _management = require("./management.js");
|
|
|
13
13
|
* ```typescript
|
|
14
14
|
* const client = getClient('your-api-key')
|
|
15
15
|
*
|
|
16
|
-
* // Get personalized feed
|
|
17
|
-
* const feed = await client.feed.byUserId('16085')
|
|
16
|
+
* // Get personalized feed based on the For-You template
|
|
17
|
+
* const feed = await client.feed.byUserId('16085', 'feed_390')
|
|
18
18
|
*
|
|
19
19
|
* // Create a custom feed
|
|
20
20
|
* const customFeed = await client.feed.createConfig({
|
|
@@ -42,7 +42,7 @@ class FeedNamespace {
|
|
|
42
42
|
* @example
|
|
43
43
|
* ```typescript
|
|
44
44
|
* const client = getClient("your-api-key")
|
|
45
|
-
* const feed = await client.feed.byUserId("16085", {
|
|
45
|
+
* const feed = await client.feed.byUserId("16085", "feed_390", {
|
|
46
46
|
* top_k: 10,
|
|
47
47
|
* return_metadata: true
|
|
48
48
|
* })
|
|
@@ -51,7 +51,7 @@ class FeedNamespace {
|
|
|
51
51
|
* ```
|
|
52
52
|
*/
|
|
53
53
|
async byUserId(userId, feedId, options) {
|
|
54
|
-
return (0,
|
|
54
|
+
return (0, feed_js_1.byUserId)(this.http, userId, feedId, options);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Get personalized "For You" feed by wallet address
|
|
@@ -64,7 +64,7 @@ class FeedNamespace {
|
|
|
64
64
|
* @example
|
|
65
65
|
* ```typescript
|
|
66
66
|
* const client = getClient("your-api-key")
|
|
67
|
-
* const feed = await client.feed.byWalletAddress("0x1234...", {
|
|
67
|
+
* const feed = await client.feed.byWalletAddress("0x1234...", "feed_390", {
|
|
68
68
|
* top_k: 15,
|
|
69
69
|
* })
|
|
70
70
|
* console.log(feed[0].metadata?.author.username) // Access author username
|
|
@@ -72,7 +72,7 @@ class FeedNamespace {
|
|
|
72
72
|
* ```
|
|
73
73
|
*/
|
|
74
74
|
async byWalletAddress(walletAddress, feedId, options) {
|
|
75
|
-
return (0,
|
|
75
|
+
return (0, feed_js_1.byWalletAddress)(this.http, walletAddress, feedId, options);
|
|
76
76
|
}
|
|
77
77
|
// ============================================================================
|
|
78
78
|
// FEED MANAGEMENT METHODS
|
|
@@ -101,7 +101,7 @@ class FeedNamespace {
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
async createConfig(options) {
|
|
104
|
-
return (0,
|
|
104
|
+
return (0, management_js_1.createConfig)(this.http, options);
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* Get a feed configuration by feedId
|
|
@@ -118,7 +118,7 @@ class FeedNamespace {
|
|
|
118
118
|
* ```
|
|
119
119
|
*/
|
|
120
120
|
async getConfig(feedId) {
|
|
121
|
-
return (0,
|
|
121
|
+
return (0, management_js_1.getConfig)(this.http, feedId);
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
124
124
|
* List all feed configurations for the account
|
|
@@ -135,7 +135,7 @@ class FeedNamespace {
|
|
|
135
135
|
* ```
|
|
136
136
|
*/
|
|
137
137
|
async listConfigs(visibility = "private") {
|
|
138
|
-
return (0,
|
|
138
|
+
return (0, management_js_1.listConfigs)(this.http, visibility);
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Update an existing feed configuration
|
|
@@ -147,8 +147,7 @@ class FeedNamespace {
|
|
|
147
147
|
* @example
|
|
148
148
|
* ```typescript
|
|
149
149
|
* const client = getClient("your-api-key")
|
|
150
|
-
* await client.feed.updateConfig({
|
|
151
|
-
* config_id: "feed_123",
|
|
150
|
+
* await client.feed.updateConfig("feed_123", {
|
|
152
151
|
* name: "Updated Feed Name",
|
|
153
152
|
* config: {
|
|
154
153
|
* filters: {
|
|
@@ -160,7 +159,7 @@ class FeedNamespace {
|
|
|
160
159
|
* ```
|
|
161
160
|
*/
|
|
162
161
|
async updateConfig(feedId, options) {
|
|
163
|
-
return (0,
|
|
162
|
+
return (0, management_js_1.updateConfig)(this.http, feedId, options);
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
exports.FeedNamespace = FeedNamespace;
|
package/src/index.js
CHANGED
|
@@ -3,48 +3,53 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
exports.FeedNamespace = exports.TimeoutError = exports.ParseError = exports.NetworkError = exports.HttpRequestError = exports.mbdClient = exports.getClient = void 0;
|
|
7
|
+
// Export the main client factory function
|
|
8
|
+
var client_js_1 = /*#__PURE__*/require("./client.js");
|
|
9
|
+
Object.defineProperty(exports, "getClient", {
|
|
7
10
|
enumerable: true,
|
|
8
11
|
get: function () {
|
|
9
|
-
return
|
|
12
|
+
return client_js_1.getClient;
|
|
10
13
|
}
|
|
11
14
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "mbdClient", {
|
|
13
16
|
enumerable: true,
|
|
14
17
|
get: function () {
|
|
15
|
-
return
|
|
18
|
+
return client_js_1.mbdClient;
|
|
16
19
|
}
|
|
17
20
|
});
|
|
18
|
-
|
|
21
|
+
// Export error types for error handling
|
|
22
|
+
var client_js_2 = /*#__PURE__*/require("./client.js");
|
|
23
|
+
Object.defineProperty(exports, "HttpRequestError", {
|
|
19
24
|
enumerable: true,
|
|
20
25
|
get: function () {
|
|
21
|
-
return
|
|
26
|
+
return client_js_2.HttpRequestError;
|
|
22
27
|
}
|
|
23
28
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
29
|
+
Object.defineProperty(exports, "NetworkError", {
|
|
25
30
|
enumerable: true,
|
|
26
31
|
get: function () {
|
|
27
|
-
return
|
|
32
|
+
return client_js_2.NetworkError;
|
|
28
33
|
}
|
|
29
34
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
35
|
+
Object.defineProperty(exports, "ParseError", {
|
|
31
36
|
enumerable: true,
|
|
32
37
|
get: function () {
|
|
33
|
-
return
|
|
38
|
+
return client_js_2.ParseError;
|
|
34
39
|
}
|
|
35
40
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
41
|
+
Object.defineProperty(exports, "TimeoutError", {
|
|
37
42
|
enumerable: true,
|
|
38
43
|
get: function () {
|
|
39
|
-
return
|
|
44
|
+
return client_js_2.TimeoutError;
|
|
40
45
|
}
|
|
41
46
|
});
|
|
42
|
-
|
|
47
|
+
// Export feed namespace
|
|
48
|
+
var namespace_js_1 = /*#__PURE__*/require("./feed/namespace.js");
|
|
49
|
+
Object.defineProperty(exports, "FeedNamespace", {
|
|
43
50
|
enumerable: true,
|
|
44
51
|
get: function () {
|
|
45
|
-
return
|
|
52
|
+
return namespace_js_1.FeedNamespace;
|
|
46
53
|
}
|
|
47
54
|
});
|
|
48
|
-
var _client = require("./client.js");
|
|
49
|
-
var _namespace = require("./feed/namespace.js");
|
|
50
55
|
//# sourceMappingURL=index.js.map
|
package/src/interfaces/index.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return m[k];
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
} : function (o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
});
|
|
19
|
+
var __exportStar = void 0 && (void 0).__exportStar || function (m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
3
22
|
Object.defineProperty(exports, "__esModule", {
|
|
4
23
|
value: true
|
|
5
24
|
});
|
|
6
|
-
|
|
7
|
-
Object.keys(_http).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _http[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _http[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
25
|
+
__exportStar(require("./http.js"), exports);
|
|
17
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SearchNamespace = void 0;
|
|
7
|
+
var namespace_js_1 = /*#__PURE__*/require("./namespace.js");
|
|
8
|
+
Object.defineProperty(exports, "SearchNamespace", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () {
|
|
11
|
+
return namespace_js_1.SearchNamespace;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { AllLabels, LabelCategories, PostLabelsResponse, PostSemanticSearchResponse, UserLabelsResponse, UserSemanticSearchResponse, UserSimilarityResponse, UserTopByLabelResponse } from "@embed-ai/types";
|
|
2
|
+
import type { IHttpClient } from "../interfaces/index.js";
|
|
3
|
+
import type { PostLabelsOptions, PostSemanticSearchOptions } from "./post.js";
|
|
4
|
+
import type { UserLabelsOptions, UserSemanticSearchOptions, UserSimilarOptions, UserTopByLabelOptions } from "./user.js";
|
|
5
|
+
/**
|
|
6
|
+
* Users namespace containing all user search operations
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const client = getClient('your-api-key')
|
|
11
|
+
*
|
|
12
|
+
* // Find similar users
|
|
13
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
14
|
+
*
|
|
15
|
+
* // Search users by query
|
|
16
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
17
|
+
*
|
|
18
|
+
* // Get top users by label
|
|
19
|
+
* const topUsers = await client.search.users.getTopByLabel('science_technology')
|
|
20
|
+
*
|
|
21
|
+
* // Get labels for users
|
|
22
|
+
* const labels = await client.search.users.getLabels(['16085', '239'])
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class UsersNamespace {
|
|
26
|
+
private http;
|
|
27
|
+
constructor(http: IHttpClient);
|
|
28
|
+
/**
|
|
29
|
+
* Get similar users for a given user ID
|
|
30
|
+
*
|
|
31
|
+
* @param userId - The user ID (fid) to find similar users for
|
|
32
|
+
* @param options - Optional configuration with top_k parameter (default: 25)
|
|
33
|
+
* @returns Promise<UserSimilarityResponse> - Array of similar users with scores
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const client = getClient("your-api-key")
|
|
38
|
+
* const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
|
|
39
|
+
* console.log(similarUsers[0].user_id) // "3"
|
|
40
|
+
* console.log(similarUsers[0].score) // 0.931880295
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
similar(userId: string, options?: UserSimilarOptions): Promise<UserSimilarityResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Search for users by semantic query
|
|
46
|
+
*
|
|
47
|
+
* @param query - The text query to search for similar users
|
|
48
|
+
* @param options - Optional configuration with top_k parameter (default: 25)
|
|
49
|
+
* @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const client = getClient("your-api-key")
|
|
54
|
+
* const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
|
|
55
|
+
* console.log(users[0].user_id) // "444746"
|
|
56
|
+
* console.log(users[0].score) // 0.697465777
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
byQuery(query: string, options?: UserSemanticSearchOptions): Promise<UserSemanticSearchResponse>;
|
|
60
|
+
/**
|
|
61
|
+
* Get top users by AI label
|
|
62
|
+
*
|
|
63
|
+
* @param label - The AI label to get top users for
|
|
64
|
+
* @param options - Optional configuration including top_k (default: 100, max: 1000), minimum_activity_count (default: 10), ratio_min (default: 0.75), conf_min (default: 0.6)
|
|
65
|
+
* @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const client = getClient("your-api-key")
|
|
70
|
+
* const topUsers = await client.search.users.getTopByLabel("science_technology", {
|
|
71
|
+
* top_k: 50,
|
|
72
|
+
* minimum_activity_count: 20,
|
|
73
|
+
* ratio_min: 0.8,
|
|
74
|
+
* conf_min: 0.7
|
|
75
|
+
* })
|
|
76
|
+
* console.log(topUsers[0].user_id) // "520701"
|
|
77
|
+
* console.log(topUsers[0].score) // 0.9471641778666666
|
|
78
|
+
* console.log(topUsers[0].count) // 12
|
|
79
|
+
* console.log(topUsers[0].ratio) // 1
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
getTopByLabel(label: AllLabels, options?: UserTopByLabelOptions): Promise<UserTopByLabelResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Get AI labels for a list of users
|
|
85
|
+
*
|
|
86
|
+
* @param userList - Array of user IDs to get labels for
|
|
87
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
88
|
+
* @param options - Optional configuration
|
|
89
|
+
* @returns Promise<UserLabelsResponse> - Array of users with their AI labels
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const client = getClient("your-api-key")
|
|
94
|
+
* const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
|
|
95
|
+
* console.log(userLabels[0].user_id) // "16085"
|
|
96
|
+
* console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
|
|
97
|
+
* console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
getLabels(userList: Array<string>, labelCategory?: LabelCategories, options?: UserLabelsOptions): Promise<UserLabelsResponse>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Posts namespace containing all post search operations
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const client = getClient('your-api-key')
|
|
108
|
+
*
|
|
109
|
+
* // Get labels for posts
|
|
110
|
+
* const postLabels = await client.search.posts.getLabels(['0x123...', '0x456...'])
|
|
111
|
+
*
|
|
112
|
+
* // Search posts by query
|
|
113
|
+
* const posts = await client.search.posts.byQuery('web3 developments')
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare class PostsNamespace {
|
|
117
|
+
private http;
|
|
118
|
+
constructor(http: IHttpClient);
|
|
119
|
+
/**
|
|
120
|
+
* Get AI labels for a list of casts
|
|
121
|
+
*
|
|
122
|
+
* @param itemsList - Array of cast IDs to get labels for
|
|
123
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
124
|
+
* @param options - Optional configuration
|
|
125
|
+
* @returns Promise<PostLabelsResponse> - Array of casts with their AI labels
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const client = getClient("your-api-key")
|
|
130
|
+
* const postLabels = await client.search.posts.getLabels([
|
|
131
|
+
* "0x4888649440c8cfd3ef6e28f2096a201d20253176",
|
|
132
|
+
* "0x0ecf95b73aa54d583877821ece241e94de701404"
|
|
133
|
+
* ], "moderation")
|
|
134
|
+
* console.log(postLabels[0].moderation[0].label) // "sexual"
|
|
135
|
+
* console.log(postLabels[0].moderation[0].score) // 0.0006675918
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
getLabels(itemsList: Array<string>, labelCategory?: LabelCategories, options?: PostLabelsOptions): Promise<PostLabelsResponse>;
|
|
139
|
+
/**
|
|
140
|
+
* Search for casts by semantic query
|
|
141
|
+
*
|
|
142
|
+
* @param query - The text query to search for similar casts
|
|
143
|
+
* @param options - Optional configuration with top_k (default: 10, max: 100), return_ai_labels, return_metadata, and filters
|
|
144
|
+
* @returns Promise<PostSemanticSearchResponse> - Array of posts with item_id and scores
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const client = getClient("your-api-key")
|
|
149
|
+
* const posts = await client.search.posts.byQuery("web3 developments", {
|
|
150
|
+
* top_k: 10,
|
|
151
|
+
* return_ai_labels: true,
|
|
152
|
+
* return_metadata: true
|
|
153
|
+
* })
|
|
154
|
+
* console.log(posts[0].item_id) // "0x4c8e2e329dc481f4c445ff8c367a1df4a8694317"
|
|
155
|
+
* console.log(posts[0].score) // 0.864244163
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
byQuery(query: string, options?: PostSemanticSearchOptions): Promise<PostSemanticSearchResponse>;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Search namespace containing all search-related operations
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const client = getClient('your-api-key')
|
|
166
|
+
*
|
|
167
|
+
* // Access user search methods
|
|
168
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
169
|
+
* const searchResults = await client.search.users.byQuery('web3 developers')
|
|
170
|
+
*
|
|
171
|
+
* // Access post search methods
|
|
172
|
+
* const posts = await client.search.posts.byQuery('web3 developments')
|
|
173
|
+
* const postLabels = await client.search.posts.getLabels(['0x123...'])
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare class SearchNamespace {
|
|
177
|
+
private http;
|
|
178
|
+
readonly users: UsersNamespace;
|
|
179
|
+
readonly posts: PostsNamespace;
|
|
180
|
+
constructor(http: IHttpClient);
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=namespace.d.ts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SearchNamespace = exports.PostsNamespace = exports.UsersNamespace = void 0;
|
|
7
|
+
const post_js_1 = /*#__PURE__*/require("./post.js");
|
|
8
|
+
const user_js_1 = /*#__PURE__*/require("./user.js");
|
|
9
|
+
/**
|
|
10
|
+
* Users namespace containing all user search operations
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const client = getClient('your-api-key')
|
|
15
|
+
*
|
|
16
|
+
* // Find similar users
|
|
17
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
18
|
+
*
|
|
19
|
+
* // Search users by query
|
|
20
|
+
* const users = await client.search.users.byQuery('web3 developers')
|
|
21
|
+
*
|
|
22
|
+
* // Get top users by label
|
|
23
|
+
* const topUsers = await client.search.users.getTopByLabel('science_technology')
|
|
24
|
+
*
|
|
25
|
+
* // Get labels for users
|
|
26
|
+
* const labels = await client.search.users.getLabels(['16085', '239'])
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class UsersNamespace {
|
|
30
|
+
http;
|
|
31
|
+
constructor(http) {
|
|
32
|
+
this.http = http;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get similar users for a given user ID
|
|
36
|
+
*
|
|
37
|
+
* @param userId - The user ID (fid) to find similar users for
|
|
38
|
+
* @param options - Optional configuration with top_k parameter (default: 25)
|
|
39
|
+
* @returns Promise<UserSimilarityResponse> - Array of similar users with scores
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const client = getClient("your-api-key")
|
|
44
|
+
* const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
|
|
45
|
+
* console.log(similarUsers[0].user_id) // "3"
|
|
46
|
+
* console.log(similarUsers[0].score) // 0.931880295
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
async similar(userId, options) {
|
|
50
|
+
return (0, user_js_1.similar)(this.http, userId, options);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Search for users by semantic query
|
|
54
|
+
*
|
|
55
|
+
* @param query - The text query to search for similar users
|
|
56
|
+
* @param options - Optional configuration with top_k parameter (default: 25)
|
|
57
|
+
* @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const client = getClient("your-api-key")
|
|
62
|
+
* const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
|
|
63
|
+
* console.log(users[0].user_id) // "444746"
|
|
64
|
+
* console.log(users[0].score) // 0.697465777
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
async byQuery(query, options) {
|
|
68
|
+
return (0, user_js_1.byQuery)(this.http, query, options);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get top users by AI label
|
|
72
|
+
*
|
|
73
|
+
* @param label - The AI label to get top users for
|
|
74
|
+
* @param options - Optional configuration including top_k (default: 100, max: 1000), minimum_activity_count (default: 10), ratio_min (default: 0.75), conf_min (default: 0.6)
|
|
75
|
+
* @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* const client = getClient("your-api-key")
|
|
80
|
+
* const topUsers = await client.search.users.getTopByLabel("science_technology", {
|
|
81
|
+
* top_k: 50,
|
|
82
|
+
* minimum_activity_count: 20,
|
|
83
|
+
* ratio_min: 0.8,
|
|
84
|
+
* conf_min: 0.7
|
|
85
|
+
* })
|
|
86
|
+
* console.log(topUsers[0].user_id) // "520701"
|
|
87
|
+
* console.log(topUsers[0].score) // 0.9471641778666666
|
|
88
|
+
* console.log(topUsers[0].count) // 12
|
|
89
|
+
* console.log(topUsers[0].ratio) // 1
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
async getTopByLabel(label, options) {
|
|
93
|
+
return (0, user_js_1.getTopByLabel)(this.http, label, options);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get AI labels for a list of users
|
|
97
|
+
*
|
|
98
|
+
* @param userList - Array of user IDs to get labels for
|
|
99
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
100
|
+
* @param options - Optional configuration
|
|
101
|
+
* @returns Promise<UserLabelsResponse> - Array of users with their AI labels
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const client = getClient("your-api-key")
|
|
106
|
+
* const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
|
|
107
|
+
* console.log(userLabels[0].user_id) // "16085"
|
|
108
|
+
* console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
|
|
109
|
+
* console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
async getLabels(userList, labelCategory = "all", options) {
|
|
113
|
+
return (0, user_js_1.getLabels)(this.http, userList, labelCategory, options);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.UsersNamespace = UsersNamespace;
|
|
117
|
+
/**
|
|
118
|
+
* Posts namespace containing all post search operations
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const client = getClient('your-api-key')
|
|
123
|
+
*
|
|
124
|
+
* // Get labels for posts
|
|
125
|
+
* const postLabels = await client.search.posts.getLabels(['0x123...', '0x456...'])
|
|
126
|
+
*
|
|
127
|
+
* // Search posts by query
|
|
128
|
+
* const posts = await client.search.posts.byQuery('web3 developments')
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
class PostsNamespace {
|
|
132
|
+
http;
|
|
133
|
+
constructor(http) {
|
|
134
|
+
this.http = http;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Get AI labels for a list of casts
|
|
138
|
+
*
|
|
139
|
+
* @param itemsList - Array of cast IDs to get labels for
|
|
140
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
141
|
+
* @param options - Optional configuration
|
|
142
|
+
* @returns Promise<PostLabelsResponse> - Array of casts with their AI labels
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const client = getClient("your-api-key")
|
|
147
|
+
* const postLabels = await client.search.posts.getLabels([
|
|
148
|
+
* "0x4888649440c8cfd3ef6e28f2096a201d20253176",
|
|
149
|
+
* "0x0ecf95b73aa54d583877821ece241e94de701404"
|
|
150
|
+
* ], "moderation")
|
|
151
|
+
* console.log(postLabels[0].moderation[0].label) // "sexual"
|
|
152
|
+
* console.log(postLabels[0].moderation[0].score) // 0.0006675918
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
async getLabels(itemsList, labelCategory = "all", options) {
|
|
156
|
+
return (0, post_js_1.getLabels)(this.http, itemsList, labelCategory, options);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Search for casts by semantic query
|
|
160
|
+
*
|
|
161
|
+
* @param query - The text query to search for similar casts
|
|
162
|
+
* @param options - Optional configuration with top_k (default: 10, max: 100), return_ai_labels, return_metadata, and filters
|
|
163
|
+
* @returns Promise<PostSemanticSearchResponse> - Array of posts with item_id and scores
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* const client = getClient("your-api-key")
|
|
168
|
+
* const posts = await client.search.posts.byQuery("web3 developments", {
|
|
169
|
+
* top_k: 10,
|
|
170
|
+
* return_ai_labels: true,
|
|
171
|
+
* return_metadata: true
|
|
172
|
+
* })
|
|
173
|
+
* console.log(posts[0].item_id) // "0x4c8e2e329dc481f4c445ff8c367a1df4a8694317"
|
|
174
|
+
* console.log(posts[0].score) // 0.864244163
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
async byQuery(query, options) {
|
|
178
|
+
return (0, post_js_1.byQuery)(this.http, query, options);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.PostsNamespace = PostsNamespace;
|
|
182
|
+
/**
|
|
183
|
+
* Search namespace containing all search-related operations
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const client = getClient('your-api-key')
|
|
188
|
+
*
|
|
189
|
+
* // Access user search methods
|
|
190
|
+
* const similarUsers = await client.search.users.similar('16085')
|
|
191
|
+
* const searchResults = await client.search.users.byQuery('web3 developers')
|
|
192
|
+
*
|
|
193
|
+
* // Access post search methods
|
|
194
|
+
* const posts = await client.search.posts.byQuery('web3 developments')
|
|
195
|
+
* const postLabels = await client.search.posts.getLabels(['0x123...'])
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
class SearchNamespace {
|
|
199
|
+
http;
|
|
200
|
+
users;
|
|
201
|
+
posts;
|
|
202
|
+
constructor(http) {
|
|
203
|
+
this.http = http;
|
|
204
|
+
this.users = new UsersNamespace(this.http);
|
|
205
|
+
this.posts = new PostsNamespace(this.http);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.SearchNamespace = SearchNamespace;
|
|
209
|
+
//# sourceMappingURL=namespace.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { LabelCategories, LabelsForItems, PostLabelsResponse, PostSemanticSearchResponse, SemanticSearch } from "@embed-ai/types";
|
|
2
|
+
import type { IHttpClient } from "../interfaces/index.js";
|
|
3
|
+
export type PostLabelsOptions = Omit<LabelsForItems, "items_list" | "label_category">;
|
|
4
|
+
export type PostSemanticSearchOptions = Omit<SemanticSearch, "query">;
|
|
5
|
+
/**
|
|
6
|
+
* Get AI labels for a list of casts
|
|
7
|
+
*
|
|
8
|
+
* @param httpClient - HTTP client instance
|
|
9
|
+
* @param itemsList - Array of cast IDs to get labels for
|
|
10
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
11
|
+
* @param options - Optional configuration
|
|
12
|
+
* @returns Promise<PostLabelsResponse> - Array of casts with their AI labels
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const postLabels = await client.search.posts.getLabels([
|
|
17
|
+
* "0x4888649440c8cfd3ef6e28f2096a201d20253176",
|
|
18
|
+
* "0x0ecf95b73aa54d583877821ece241e94de701404"
|
|
19
|
+
* ], "moderation")
|
|
20
|
+
* console.log(postLabels[0].moderation[0].label) // "sexual"
|
|
21
|
+
* console.log(postLabels[0].moderation[0].score) // 0.0006675918
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLabels(httpClient: IHttpClient, itemsList: Array<string>, labelCategory?: LabelCategories, options?: PostLabelsOptions): Promise<PostLabelsResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Search for casts by semantic query
|
|
27
|
+
*
|
|
28
|
+
* @param httpClient - HTTP client instance
|
|
29
|
+
* @param query - The text query to search for similar casts
|
|
30
|
+
* @param options - Optional configuration with top_k (default: 10, max: 100), return_ai_labels, return_metadata, and filters
|
|
31
|
+
* @returns Promise<PostSemanticSearchResponse> - Object with items_list containing cast IDs and scores
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const posts = await client.search.posts.byQuery("web3 developments", {
|
|
36
|
+
* top_k: 10,
|
|
37
|
+
* return_ai_labels: true,
|
|
38
|
+
* return_metadata: true
|
|
39
|
+
* })
|
|
40
|
+
* console.log(posts.items_list[0].item_id) // "0x4c8e2e329dc481f4c445ff8c367a1df4a8694317"
|
|
41
|
+
* console.log(posts.items_list[0].score) // 0.864244163
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function byQuery(httpClient: IHttpClient, query: string, options?: PostSemanticSearchOptions): Promise<PostSemanticSearchResponse>;
|
|
45
|
+
//# sourceMappingURL=post.d.ts.map
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLabels = getLabels;
|
|
7
|
+
exports.byQuery = byQuery;
|
|
8
|
+
/**
|
|
9
|
+
* Get AI labels for a list of casts
|
|
10
|
+
*
|
|
11
|
+
* @param httpClient - HTTP client instance
|
|
12
|
+
* @param itemsList - Array of cast IDs to get labels for
|
|
13
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
14
|
+
* @param options - Optional configuration
|
|
15
|
+
* @returns Promise<PostLabelsResponse> - Array of casts with their AI labels
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const postLabels = await client.search.posts.getLabels([
|
|
20
|
+
* "0x4888649440c8cfd3ef6e28f2096a201d20253176",
|
|
21
|
+
* "0x0ecf95b73aa54d583877821ece241e94de701404"
|
|
22
|
+
* ], "moderation")
|
|
23
|
+
* console.log(postLabels[0].moderation[0].label) // "sexual"
|
|
24
|
+
* console.log(postLabels[0].moderation[0].score) // 0.0006675918
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
async function getLabels(httpClient, itemsList, labelCategory = "all", options) {
|
|
28
|
+
const params = {
|
|
29
|
+
items_list: itemsList,
|
|
30
|
+
label_category: labelCategory,
|
|
31
|
+
...options
|
|
32
|
+
};
|
|
33
|
+
const response = await httpClient.post("/v2/farcaster/casts/labels/for-items", params);
|
|
34
|
+
return response.body;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Search for casts by semantic query
|
|
38
|
+
*
|
|
39
|
+
* @param httpClient - HTTP client instance
|
|
40
|
+
* @param query - The text query to search for similar casts
|
|
41
|
+
* @param options - Optional configuration with top_k (default: 10, max: 100), return_ai_labels, return_metadata, and filters
|
|
42
|
+
* @returns Promise<PostSemanticSearchResponse> - Object with items_list containing cast IDs and scores
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const posts = await client.search.posts.byQuery("web3 developments", {
|
|
47
|
+
* top_k: 10,
|
|
48
|
+
* return_ai_labels: true,
|
|
49
|
+
* return_metadata: true
|
|
50
|
+
* })
|
|
51
|
+
* console.log(posts.items_list[0].item_id) // "0x4c8e2e329dc481f4c445ff8c367a1df4a8694317"
|
|
52
|
+
* console.log(posts.items_list[0].score) // 0.864244163
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
async function byQuery(httpClient, query, options) {
|
|
56
|
+
const top_k = options?.top_k ?? 10;
|
|
57
|
+
const params = {
|
|
58
|
+
query,
|
|
59
|
+
top_k,
|
|
60
|
+
...options
|
|
61
|
+
};
|
|
62
|
+
const response = await httpClient.post("/v2/farcaster/casts/search/semantic", params);
|
|
63
|
+
// Handle both response formats - sometimes it's a direct array, sometimes it's wrapped in items_list
|
|
64
|
+
if (Array.isArray(response.body)) {
|
|
65
|
+
return response.body;
|
|
66
|
+
} else {
|
|
67
|
+
return response.body.items_list;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=post.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { AllLabels, LabelCategories, LabelsForUsers, LabelsTopUsers, UserLabelsResponse, UserSemanticSearchResponse, UsersFeedSimilar, UserSimilarityResponse, UsersSemanticSearch, UserTopByLabelResponse } from "@embed-ai/types";
|
|
2
|
+
import type { IHttpClient } from "../interfaces/index.js";
|
|
3
|
+
export type UserSimilarOptions = Omit<UsersFeedSimilar, "user_id">;
|
|
4
|
+
export type UserSemanticSearchOptions = Omit<UsersSemanticSearch, "query">;
|
|
5
|
+
export type UserTopByLabelOptions = Omit<LabelsTopUsers, "label">;
|
|
6
|
+
export type UserLabelsOptions = Omit<LabelsForUsers, "users_list" | "label_category">;
|
|
7
|
+
/**
|
|
8
|
+
* Get similar users for a given user ID
|
|
9
|
+
*
|
|
10
|
+
* @param httpClient - HTTP client instance
|
|
11
|
+
* @param userId - The user ID (fid) to find similar users for
|
|
12
|
+
* @param options - Optional configuration with top_k parameter
|
|
13
|
+
* @returns Promise<UserSimilarityResponse> - Array of similar users with scores
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
|
|
18
|
+
* console.log(similarUsers[0].user_id) // "3"
|
|
19
|
+
* console.log(similarUsers[0].score) // 0.931880295
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function similar(httpClient: IHttpClient, userId: string, options?: UserSimilarOptions): Promise<UserSimilarityResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* Search for users by semantic query
|
|
25
|
+
*
|
|
26
|
+
* @param httpClient - HTTP client instance
|
|
27
|
+
* @param query - The text query to search for similar users
|
|
28
|
+
* @param options - Optional configuration with top_k parameter
|
|
29
|
+
* @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
|
|
34
|
+
* console.log(users[0].user_id) // "444746"
|
|
35
|
+
* console.log(users[0].score) // 0.697465777
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function byQuery(httpClient: IHttpClient, query: string, options?: UserSemanticSearchOptions): Promise<UserSemanticSearchResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Get top users by AI label
|
|
41
|
+
*
|
|
42
|
+
* @param httpClient - HTTP client instance
|
|
43
|
+
* @param label - The AI label to get top users for
|
|
44
|
+
* @param options - Optional configuration including top_k, minimum_activity_count, ratio_min, conf_min
|
|
45
|
+
* @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* const topUsers = await client.search.users.getTopByLabel("science_technology", {
|
|
50
|
+
* top_k: 50,
|
|
51
|
+
* minimum_activity_count: 20,
|
|
52
|
+
* ratio_min: 0.8,
|
|
53
|
+
* conf_min: 0.7
|
|
54
|
+
* })
|
|
55
|
+
* console.log(topUsers[0].user_id) // "520701"
|
|
56
|
+
* console.log(topUsers[0].score) // 0.9471641778666666
|
|
57
|
+
* console.log(topUsers[0].count) // 12
|
|
58
|
+
* console.log(topUsers[0].ratio) // 1
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTopByLabel(httpClient: IHttpClient, label: AllLabels, options?: UserTopByLabelOptions): Promise<UserTopByLabelResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Get AI labels for a list of users
|
|
64
|
+
*
|
|
65
|
+
* @param httpClient - HTTP client instance
|
|
66
|
+
* @param userList - Array of user IDs to get labels for
|
|
67
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
68
|
+
* @param options - Optional configuration
|
|
69
|
+
* @returns Promise<UserLabelsResponse> - Array of users with their AI labels
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
|
|
74
|
+
* console.log(userLabels[0].user_id) // "16085"
|
|
75
|
+
* console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
|
|
76
|
+
* console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare function getLabels(httpClient: IHttpClient, userList: Array<string>, labelCategory?: LabelCategories, options?: UserLabelsOptions): Promise<UserLabelsResponse>;
|
|
80
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.similar = similar;
|
|
7
|
+
exports.byQuery = byQuery;
|
|
8
|
+
exports.getTopByLabel = getTopByLabel;
|
|
9
|
+
exports.getLabels = getLabels;
|
|
10
|
+
/**
|
|
11
|
+
* Get similar users for a given user ID
|
|
12
|
+
*
|
|
13
|
+
* @param httpClient - HTTP client instance
|
|
14
|
+
* @param userId - The user ID (fid) to find similar users for
|
|
15
|
+
* @param options - Optional configuration with top_k parameter
|
|
16
|
+
* @returns Promise<UserSimilarityResponse> - Array of similar users with scores
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const similarUsers = await client.search.users.similar("16085", { top_k: 10 })
|
|
21
|
+
* console.log(similarUsers[0].user_id) // "3"
|
|
22
|
+
* console.log(similarUsers[0].score) // 0.931880295
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
async function similar(httpClient, userId, options) {
|
|
26
|
+
const top_k = options?.top_k ?? 25;
|
|
27
|
+
const params = {
|
|
28
|
+
user_id: userId,
|
|
29
|
+
top_k,
|
|
30
|
+
...options
|
|
31
|
+
};
|
|
32
|
+
const response = await httpClient.post("/v2/farcaster/users/feed/similar", params);
|
|
33
|
+
return response.body;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Search for users by semantic query
|
|
37
|
+
*
|
|
38
|
+
* @param httpClient - HTTP client instance
|
|
39
|
+
* @param query - The text query to search for similar users
|
|
40
|
+
* @param options - Optional configuration with top_k parameter
|
|
41
|
+
* @returns Promise<UserSemanticSearchResponse> - Array of users matching the query with scores
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const users = await client.search.users.byQuery("web3 developers", { top_k: 10 })
|
|
46
|
+
* console.log(users[0].user_id) // "444746"
|
|
47
|
+
* console.log(users[0].score) // 0.697465777
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
async function byQuery(httpClient, query, options) {
|
|
51
|
+
const top_k = options?.top_k ?? 25;
|
|
52
|
+
const params = {
|
|
53
|
+
query,
|
|
54
|
+
top_k,
|
|
55
|
+
...options
|
|
56
|
+
};
|
|
57
|
+
const response = await httpClient.post("/v2/farcaster/users/search/semantic", params);
|
|
58
|
+
return response.body;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get top users by AI label
|
|
62
|
+
*
|
|
63
|
+
* @param httpClient - HTTP client instance
|
|
64
|
+
* @param label - The AI label to get top users for
|
|
65
|
+
* @param options - Optional configuration including top_k, minimum_activity_count, ratio_min, conf_min
|
|
66
|
+
* @returns Promise<UserTopByLabelResponse> - Array of top users for the label with scores, counts, and ratios
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const topUsers = await client.search.users.getTopByLabel("science_technology", {
|
|
71
|
+
* top_k: 50,
|
|
72
|
+
* minimum_activity_count: 20,
|
|
73
|
+
* ratio_min: 0.8,
|
|
74
|
+
* conf_min: 0.7
|
|
75
|
+
* })
|
|
76
|
+
* console.log(topUsers[0].user_id) // "520701"
|
|
77
|
+
* console.log(topUsers[0].score) // 0.9471641778666666
|
|
78
|
+
* console.log(topUsers[0].count) // 12
|
|
79
|
+
* console.log(topUsers[0].ratio) // 1
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async function getTopByLabel(httpClient, label, options) {
|
|
83
|
+
const top_k = options?.top_k ?? 100;
|
|
84
|
+
const minimum_activity_count = options?.minimum_activity_count ?? 10;
|
|
85
|
+
const ratio_min = options?.ratio_min ?? 0.75;
|
|
86
|
+
const conf_min = options?.conf_min ?? 0.6;
|
|
87
|
+
const params = {
|
|
88
|
+
label,
|
|
89
|
+
top_k,
|
|
90
|
+
minimum_activity_count,
|
|
91
|
+
ratio_min,
|
|
92
|
+
conf_min,
|
|
93
|
+
...options
|
|
94
|
+
};
|
|
95
|
+
const response = await httpClient.post("/v2/farcaster/users/labels/top-users", params);
|
|
96
|
+
return response.body;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Get AI labels for a list of users
|
|
100
|
+
*
|
|
101
|
+
* @param httpClient - HTTP client instance
|
|
102
|
+
* @param userList - Array of user IDs to get labels for
|
|
103
|
+
* @param labelCategory - The category of labels to retrieve (default: "all")
|
|
104
|
+
* @param options - Optional configuration
|
|
105
|
+
* @returns Promise<UserLabelsResponse> - Array of users with their AI labels
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* const userLabels = await client.search.users.getLabels(["16085", "239", "3"], "topics")
|
|
110
|
+
* console.log(userLabels[0].user_id) // "16085"
|
|
111
|
+
* console.log(userLabels[0].ai_labels.topics[0].label) // "arts_culture"
|
|
112
|
+
* console.log(userLabels[0].ai_labels.topics[0].score) // 0.023266956986850353
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
async function getLabels(httpClient, userList, labelCategory = "all", options) {
|
|
116
|
+
const params = {
|
|
117
|
+
users_list: userList,
|
|
118
|
+
label_category: labelCategory,
|
|
119
|
+
...options
|
|
120
|
+
};
|
|
121
|
+
const response = await httpClient.post("/v2/farcaster/users/labels/for-users", params);
|
|
122
|
+
return response.body;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=user.js.map
|