@betterlu/agentlu 1.2.1 → 1.3.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.
- package/dist/index.d.ts +16 -5
- package/dist/index.js +25 -3
- package/package.json +14 -4
package/dist/index.d.ts
CHANGED
|
@@ -42,10 +42,12 @@ export interface RunOptions {
|
|
|
42
42
|
model?: string;
|
|
43
43
|
input?: string;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
* Attachments previously uploaded via `upload()`. Prepended to the user
|
|
46
|
+
* turn using each file's `kind` (`input_image` / `input_video` / `input_file`).
|
|
47
|
+
*/
|
|
48
48
|
fileIds?: string[];
|
|
49
|
+
/** Optional kinds aligned with `fileIds` (from `upload()`). Defaults to image. */
|
|
50
|
+
fileKinds?: Array<"image" | "video" | "text" | "document">;
|
|
49
51
|
/** Structured input messages (OpenAI shape) - overrides `input`. */
|
|
50
52
|
inputMessages?: Array<{
|
|
51
53
|
role: string;
|
|
@@ -126,11 +128,12 @@ export declare class AgentLu {
|
|
|
126
128
|
defaults?: ClientDefaults;
|
|
127
129
|
}): Promise<string>;
|
|
128
130
|
/**
|
|
129
|
-
* Upload an image
|
|
130
|
-
*
|
|
131
|
+
* Upload an image, video, or document for use with `run({ fileIds })`.
|
|
132
|
+
* Returns the `file_id` and stored `kind`.
|
|
131
133
|
*/
|
|
132
134
|
upload(data: Uint8Array | Blob, filename: string, mime?: string): Promise<{
|
|
133
135
|
id: string;
|
|
136
|
+
kind?: string;
|
|
134
137
|
}>;
|
|
135
138
|
me(): Promise<unknown>;
|
|
136
139
|
/**
|
|
@@ -201,4 +204,12 @@ export declare class UseCaseRunner {
|
|
|
201
204
|
response: ResponseObject;
|
|
202
205
|
}>;
|
|
203
206
|
stream(body: Record<string, unknown>): Promise<AsyncGenerator<Record<string, unknown>, any, any>>;
|
|
207
|
+
/**
|
|
208
|
+
* Upload with this use-case's key, so the file is owned by the same
|
|
209
|
+
* service client that will reference it via `run({ fileIds })`.
|
|
210
|
+
*/
|
|
211
|
+
upload(data: Uint8Array | Blob, filename: string, mime?: string): Promise<{
|
|
212
|
+
id: string;
|
|
213
|
+
kind?: string;
|
|
214
|
+
}>;
|
|
204
215
|
}
|
package/dist/index.js
CHANGED
|
@@ -68,8 +68,8 @@ export class AgentLu {
|
|
|
68
68
|
return res.api_key;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Upload an image
|
|
72
|
-
*
|
|
71
|
+
* Upload an image, video, or document for use with `run({ fileIds })`.
|
|
72
|
+
* Returns the `file_id` and stored `kind`.
|
|
73
73
|
*/
|
|
74
74
|
async upload(data, filename, mime) {
|
|
75
75
|
const form = new FormData();
|
|
@@ -93,7 +93,14 @@ export class AgentLu {
|
|
|
93
93
|
{
|
|
94
94
|
role: "user",
|
|
95
95
|
content: [
|
|
96
|
-
...opts.fileIds.map((file_id) =>
|
|
96
|
+
...opts.fileIds.map((file_id, i) => {
|
|
97
|
+
const kind = opts.fileKinds?.[i];
|
|
98
|
+
if (kind === "video")
|
|
99
|
+
return { type: "input_video", file_id };
|
|
100
|
+
if (kind === "text" || kind === "document")
|
|
101
|
+
return { type: "input_file", file_id };
|
|
102
|
+
return { type: "input_image", file_id };
|
|
103
|
+
}),
|
|
97
104
|
{ type: "input_text", text: opts.input ?? "" },
|
|
98
105
|
],
|
|
99
106
|
},
|
|
@@ -326,6 +333,21 @@ export class UseCaseRunner {
|
|
|
326
333
|
this.parent.apiKey = parentKey;
|
|
327
334
|
}
|
|
328
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* Upload with this use-case's key, so the file is owned by the same
|
|
338
|
+
* service client that will reference it via `run({ fileIds })`.
|
|
339
|
+
*/
|
|
340
|
+
async upload(data, filename, mime) {
|
|
341
|
+
await this.ensure();
|
|
342
|
+
const parentKey = this.parent.apiKey;
|
|
343
|
+
this.parent.apiKey = this.apiKey ?? undefined;
|
|
344
|
+
try {
|
|
345
|
+
return await this.parent.upload(data, filename, mime);
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
this.parent.apiKey = parentKey;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
329
351
|
}
|
|
330
352
|
function parseRetryAfter(res) {
|
|
331
353
|
const header = res.headers.get("retry-after");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@betterlu/agentlu",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Client for the agentlu service API (/v1). Or just use the openai SDK pointed at http://localhost:8912/v1.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"files": [
|
|
15
|
-
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18"
|
|
19
|
+
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"build": "tsc -p tsconfig.json",
|
|
18
22
|
"prepublishOnly": "npm run build"
|
|
@@ -20,7 +24,13 @@
|
|
|
20
24
|
"publishConfig": {
|
|
21
25
|
"access": "public"
|
|
22
26
|
},
|
|
23
|
-
"keywords": [
|
|
27
|
+
"keywords": [
|
|
28
|
+
"agentlu",
|
|
29
|
+
"openai",
|
|
30
|
+
"responses",
|
|
31
|
+
"llm",
|
|
32
|
+
"agent"
|
|
33
|
+
],
|
|
24
34
|
"repository": {
|
|
25
35
|
"type": "git",
|
|
26
36
|
"url": "git+https://github.com/betterlu/agentlu.git",
|