orangeslice 1.7.9 → 1.7.10

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 CHANGED
@@ -16,6 +16,7 @@ Your AI agent gets:
16
16
  - Anti-patterns to avoid
17
17
  - Performance rules
18
18
  - **Parallelization patterns** — agents must run queries in parallel, never sequentially
19
+ - **AI structured output** — extract structured data from text with `orangeslice.ai.generateObject()`
19
20
 
20
21
  ## 🚨 CRITICAL: Always Parallelize
21
22
 
@@ -124,6 +125,38 @@ orangeslice.b2b.configure({
124
125
  });
125
126
  ```
126
127
 
128
+ ### `orangeslice.ai.generateObject<T>(options): Promise<T>`
129
+
130
+ Generate structured data from text using AI.
131
+
132
+ ```typescript
133
+ const result = await orangeslice.ai.generateObject({
134
+ prompt: "Extract company info: Stripe was founded in 2010 by Patrick Collison",
135
+ schema: {
136
+ type: "object",
137
+ properties: {
138
+ company: { type: "string" },
139
+ year: { type: "number" },
140
+ founder: { type: "string" }
141
+ },
142
+ required: ["company", "year"]
143
+ }
144
+ });
145
+ // { company: "Stripe", year: 2010, founder: "Patrick Collison" }
146
+ ```
147
+
148
+ ### `orangeslice.ai.extract<T>(text, schema, instructions?): Promise<T>`
149
+
150
+ Convenience method to extract structured data from text.
151
+
152
+ ```typescript
153
+ const data = await orangeslice.ai.extract(
154
+ "Apple Inc was founded in 1976 by Steve Jobs in Cupertino",
155
+ { type: "object", properties: { company: { type: "string" }, year: { type: "number" } } },
156
+ "Extract the company name and founding year"
157
+ );
158
+ ```
159
+
127
160
  ## Restrictions
128
161
 
129
162
  - No direct contact data (email/phone)
package/dist/ai.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Configure the AI client
3
+ */
4
+ export declare function configure(options: {
5
+ proxyUrl?: string;
6
+ concurrency?: number;
7
+ minDelayMs?: number;
8
+ }): void;
9
+ export interface JsonSchema {
10
+ type: "object" | "array" | "string" | "number" | "boolean";
11
+ properties?: Record<string, JsonSchema>;
12
+ items?: JsonSchema;
13
+ required?: string[];
14
+ description?: string;
15
+ enum?: (string | number)[];
16
+ }
17
+ export interface GenerateObjectOptions {
18
+ prompt: string;
19
+ schema: JsonSchema;
20
+ system?: string;
21
+ }
22
+ /**
23
+ * Generate a structured object from a prompt using AI.
24
+ * Automatically rate-limited and concurrency-controlled.
25
+ *
26
+ * @example
27
+ * const result = await ai.generateObject({
28
+ * prompt: "Extract company info: Apple Inc was founded in 1976 by Steve Jobs",
29
+ * schema: {
30
+ * type: "object",
31
+ * properties: {
32
+ * company: { type: "string" },
33
+ * year: { type: "number" },
34
+ * founder: { type: "string" }
35
+ * },
36
+ * required: ["company", "year"]
37
+ * }
38
+ * });
39
+ * // { company: "Apple Inc", year: 1976, founder: "Steve Jobs" }
40
+ */
41
+ export declare function generateObject<T = unknown>(options: GenerateObjectOptions): Promise<T>;
42
+ /**
43
+ * Convenience method to extract structured data from text.
44
+ *
45
+ * @example
46
+ * const data = await ai.extract(
47
+ * "Apple Inc was founded in 1976 by Steve Jobs in Cupertino",
48
+ * { type: "object", properties: { company: { type: "string" }, year: { type: "number" } } },
49
+ * "Extract the company name and founding year"
50
+ * );
51
+ */
52
+ export declare function extract<T = unknown>(text: string, schema: JsonSchema, instructions?: string): Promise<T>;
53
+ export declare const ai: {
54
+ generateObject: typeof generateObject;
55
+ extract: typeof extract;
56
+ configure: typeof configure;
57
+ };
package/dist/ai.js ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ai = void 0;
4
+ exports.configure = configure;
5
+ exports.generateObject = generateObject;
6
+ exports.extract = extract;
7
+ const queue_1 = require("./queue");
8
+ // Default config
9
+ let config = {
10
+ proxyUrl: process.env.ORANGESLICE_AI_URL || "https://orangeslice.ai/api/function?functionId=generateObject",
11
+ concurrency: 10,
12
+ minDelayMs: 10, // 10ms between requests = max 100/sec
13
+ };
14
+ // Create queue and rate limiter with defaults
15
+ let queue = (0, queue_1.createQueue)(config.concurrency);
16
+ let rateLimiter = (0, queue_1.createRateLimiter)(config.minDelayMs);
17
+ /**
18
+ * Configure the AI client
19
+ */
20
+ function configure(options) {
21
+ if (options.proxyUrl)
22
+ config.proxyUrl = options.proxyUrl;
23
+ if (options.concurrency) {
24
+ config.concurrency = options.concurrency;
25
+ queue = (0, queue_1.createQueue)(options.concurrency);
26
+ }
27
+ if (options.minDelayMs !== undefined) {
28
+ config.minDelayMs = options.minDelayMs;
29
+ rateLimiter = (0, queue_1.createRateLimiter)(options.minDelayMs);
30
+ }
31
+ }
32
+ /**
33
+ * Generate a structured object from a prompt using AI.
34
+ * Automatically rate-limited and concurrency-controlled.
35
+ *
36
+ * @example
37
+ * const result = await ai.generateObject({
38
+ * prompt: "Extract company info: Apple Inc was founded in 1976 by Steve Jobs",
39
+ * schema: {
40
+ * type: "object",
41
+ * properties: {
42
+ * company: { type: "string" },
43
+ * year: { type: "number" },
44
+ * founder: { type: "string" }
45
+ * },
46
+ * required: ["company", "year"]
47
+ * }
48
+ * });
49
+ * // { company: "Apple Inc", year: 1976, founder: "Steve Jobs" }
50
+ */
51
+ async function generateObject(options) {
52
+ return queue(async () => {
53
+ return rateLimiter(async () => {
54
+ const response = await fetch(config.proxyUrl, {
55
+ method: "POST",
56
+ headers: { "Content-Type": "application/json" },
57
+ body: JSON.stringify(options),
58
+ });
59
+ if (!response.ok) {
60
+ throw new Error(`AI generateObject request failed: ${response.status} ${response.statusText}`);
61
+ }
62
+ const data = (await response.json());
63
+ if (data.error) {
64
+ throw new Error(`AI generateObject error: ${data.error}`);
65
+ }
66
+ return data.result;
67
+ });
68
+ });
69
+ }
70
+ /**
71
+ * Convenience method to extract structured data from text.
72
+ *
73
+ * @example
74
+ * const data = await ai.extract(
75
+ * "Apple Inc was founded in 1976 by Steve Jobs in Cupertino",
76
+ * { type: "object", properties: { company: { type: "string" }, year: { type: "number" } } },
77
+ * "Extract the company name and founding year"
78
+ * );
79
+ */
80
+ async function extract(text, schema, instructions) {
81
+ const prompt = instructions ? `${instructions}\n\nText:\n${text}` : `Extract structured data from the following text:\n\n${text}`;
82
+ return generateObject({ prompt, schema });
83
+ }
84
+ // Export as namespace
85
+ exports.ai = {
86
+ generateObject,
87
+ extract,
88
+ configure,
89
+ };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { b2b } from "./b2b";
2
- export { b2b };
2
+ import { ai } from "./ai";
3
+ export { b2b, ai };
3
4
  /**
4
- * orangeslice - B2B LinkedIn Database
5
+ * orangeslice - B2B LinkedIn Database + AI
5
6
  *
6
7
  * @example
7
8
  * import { orangeslice } from 'orangeslice';
@@ -9,15 +10,11 @@ export { b2b };
9
10
  * // Query 1B+ LinkedIn profiles
10
11
  * const companies = await orangeslice.b2b.sql("SELECT * FROM linkedin_company WHERE domain = 'stripe.com'");
11
12
  *
12
- * // Find people at a company
13
- * const people = await orangeslice.b2b.sql(`
14
- * SELECT p.first_name, p.last_name, pos.title
15
- * FROM linkedin_profile p
16
- * JOIN linkedin_profile_position3 pos ON pos.linkedin_profile_id = p.id
17
- * JOIN linkedin_company c ON c.id = pos.linkedin_company_id
18
- * WHERE c.domain = 'stripe.com' AND pos.end_date IS NULL
19
- * LIMIT 10
20
- * `);
13
+ * // Generate structured data with AI
14
+ * const extracted = await orangeslice.ai.generateObject({
15
+ * prompt: "Extract company info: Apple was founded in 1976",
16
+ * schema: { type: "object", properties: { name: { type: "string" }, year: { type: "number" } } }
17
+ * });
21
18
  */
22
19
  export declare const orangeslice: {
23
20
  b2b: {
@@ -25,5 +22,10 @@ export declare const orangeslice: {
25
22
  query: typeof import("./b2b").query;
26
23
  configure: typeof import("./b2b").configure;
27
24
  };
25
+ ai: {
26
+ generateObject: typeof import("./ai").generateObject;
27
+ extract: typeof import("./ai").extract;
28
+ configure: typeof import("./ai").configure;
29
+ };
28
30
  };
29
31
  export default orangeslice;
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.orangeslice = exports.b2b = void 0;
3
+ exports.orangeslice = exports.ai = exports.b2b = void 0;
4
4
  const b2b_1 = require("./b2b");
5
5
  Object.defineProperty(exports, "b2b", { enumerable: true, get: function () { return b2b_1.b2b; } });
6
+ const ai_1 = require("./ai");
7
+ Object.defineProperty(exports, "ai", { enumerable: true, get: function () { return ai_1.ai; } });
6
8
  /**
7
- * orangeslice - B2B LinkedIn Database
9
+ * orangeslice - B2B LinkedIn Database + AI
8
10
  *
9
11
  * @example
10
12
  * import { orangeslice } from 'orangeslice';
@@ -12,17 +14,14 @@ Object.defineProperty(exports, "b2b", { enumerable: true, get: function () { ret
12
14
  * // Query 1B+ LinkedIn profiles
13
15
  * const companies = await orangeslice.b2b.sql("SELECT * FROM linkedin_company WHERE domain = 'stripe.com'");
14
16
  *
15
- * // Find people at a company
16
- * const people = await orangeslice.b2b.sql(`
17
- * SELECT p.first_name, p.last_name, pos.title
18
- * FROM linkedin_profile p
19
- * JOIN linkedin_profile_position3 pos ON pos.linkedin_profile_id = p.id
20
- * JOIN linkedin_company c ON c.id = pos.linkedin_company_id
21
- * WHERE c.domain = 'stripe.com' AND pos.end_date IS NULL
22
- * LIMIT 10
23
- * `);
17
+ * // Generate structured data with AI
18
+ * const extracted = await orangeslice.ai.generateObject({
19
+ * prompt: "Extract company info: Apple was founded in 1976",
20
+ * schema: { type: "object", properties: { name: { type: "string" }, year: { type: "number" } } }
21
+ * });
24
22
  */
25
23
  exports.orangeslice = {
26
24
  b2b: b2b_1.b2b,
25
+ ai: ai_1.ai,
27
26
  };
28
27
  exports.default = exports.orangeslice;
package/docs/AGENTS.md CHANGED
@@ -46,6 +46,25 @@ const results = await Promise.all(
46
46
  - Work history, education, certifications, skills, funding data
47
47
  - Updated regularly
48
48
 
49
+ ## AI Structured Output
50
+
51
+ Use `orangeslice.ai.generateObject()` to extract structured data from text:
52
+
53
+ ```typescript
54
+ const result = await orangeslice.ai.generateObject({
55
+ prompt: "Extract company info: Stripe was founded in 2010 by Patrick Collison",
56
+ schema: {
57
+ type: "object",
58
+ properties: {
59
+ company: { type: "string" },
60
+ year: { type: "number" },
61
+ founder: { type: "string" }
62
+ }
63
+ }
64
+ });
65
+ // { company: "Stripe", year: 2010, founder: "Patrick Collison" }
66
+ ```
67
+
49
68
  ## Quick Start
50
69
 
51
70
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orangeslice",
3
- "version": "1.7.9",
3
+ "version": "1.7.10",
4
4
  "description": "B2B LinkedIn database prospector - 1.15B profiles, 85M companies",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",