orangeslice 1.7.3 → 1.7.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/dist/generateObject.js +17 -20
- package/docs/AGENTS.md +1 -1
- package/package.json +1 -1
package/dist/generateObject.js
CHANGED
|
@@ -7,9 +7,8 @@ const queue_1 = require("./queue");
|
|
|
7
7
|
const API_URL = process.env.ORANGESLICE_API_URL
|
|
8
8
|
? process.env.ORANGESLICE_API_URL.replace(/\?.*/, "") + "?functionId=generateObject"
|
|
9
9
|
: "https://orangeslice.ai/api/function?functionId=generateObject";
|
|
10
|
-
// Rate limit:
|
|
11
|
-
const
|
|
12
|
-
const rateLimiter = (0, queue_1.createRateLimiter)(200);
|
|
10
|
+
// Rate limit: unlimited concurrency, 100/second throttle (10ms between requests)
|
|
11
|
+
const rateLimiter = (0, queue_1.createRateLimiter)(10);
|
|
13
12
|
/**
|
|
14
13
|
* Helper to make POST request, handling redirects manually
|
|
15
14
|
*/
|
|
@@ -50,24 +49,22 @@ async function fetchWithRedirect(url, body) {
|
|
|
50
49
|
* // { company: "Apple Inc", year: 1976 }
|
|
51
50
|
*/
|
|
52
51
|
async function generate(options) {
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
model: options.model,
|
|
59
|
-
});
|
|
60
|
-
const response = await fetchWithRedirect(API_URL, body);
|
|
61
|
-
if (!response.ok) {
|
|
62
|
-
const text = await response.text();
|
|
63
|
-
throw new Error(`generateObject request failed: ${response.status} ${text}`);
|
|
64
|
-
}
|
|
65
|
-
const data = (await response.json());
|
|
66
|
-
if (data.error) {
|
|
67
|
-
throw new Error(`generateObject error: ${data.error}`);
|
|
68
|
-
}
|
|
69
|
-
return data;
|
|
52
|
+
return rateLimiter(async () => {
|
|
53
|
+
const body = JSON.stringify({
|
|
54
|
+
prompt: options.prompt,
|
|
55
|
+
schema: options.schema,
|
|
56
|
+
model: options.model,
|
|
70
57
|
});
|
|
58
|
+
const response = await fetchWithRedirect(API_URL, body);
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const text = await response.text();
|
|
61
|
+
throw new Error(`generateObject request failed: ${response.status} ${text}`);
|
|
62
|
+
}
|
|
63
|
+
const data = (await response.json());
|
|
64
|
+
if (data.error) {
|
|
65
|
+
throw new Error(`generateObject error: ${data.error}`);
|
|
66
|
+
}
|
|
67
|
+
return data;
|
|
71
68
|
});
|
|
72
69
|
}
|
|
73
70
|
/**
|
package/docs/AGENTS.md
CHANGED
|
@@ -123,7 +123,7 @@ const { city, state } = await orangeslice.geo.getCityState("123 Main St, Boston,
|
|
|
123
123
|
| `serp` | 2 | 200ms |
|
|
124
124
|
| `firecrawl` | 2 | 500ms |
|
|
125
125
|
| `browser` | 2 | 500ms |
|
|
126
|
-
| `generateObject` |
|
|
126
|
+
| `generateObject` | unlimited | 10ms (100/sec) |
|
|
127
127
|
| `apify` | 2 | 500ms |
|
|
128
128
|
| `geo` | 2 | 100ms |
|
|
129
129
|
|
package/package.json
CHANGED