@xuda.io/ai_module 1.1.4821 → 1.1.4823
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/index.mjs +24 -12
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1461,13 +1461,19 @@ export const unarchive_ai_chat = async function (req) {
|
|
|
1461
1461
|
|
|
1462
1462
|
const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256, metadata = {}, account_profile_info) {
|
|
1463
1463
|
try {
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1464
|
+
let response;
|
|
1465
|
+
try {
|
|
1466
|
+
response = await client.images.generate({
|
|
1467
|
+
model,
|
|
1468
|
+
prompt,
|
|
1469
|
+
size,
|
|
1470
|
+
n,
|
|
1471
|
+
});
|
|
1472
|
+
report_ai_status('files');
|
|
1473
|
+
} catch (error) {
|
|
1474
|
+
report_ai_status('files', error);
|
|
1475
|
+
throw error;
|
|
1476
|
+
}
|
|
1471
1477
|
// Try to extract base64 directly
|
|
1472
1478
|
const imgObj = response.data?.[0];
|
|
1473
1479
|
if (!imgObj) throw new Error('No image returned from OpenAI');
|
|
@@ -2486,11 +2492,17 @@ const upload_agent_files = async function (uid, agent_doc) {
|
|
|
2486
2492
|
break;
|
|
2487
2493
|
}
|
|
2488
2494
|
if (file) {
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2495
|
+
try {
|
|
2496
|
+
const uploadedFile = await client.files.create({
|
|
2497
|
+
file,
|
|
2498
|
+
purpose: 'assistants',
|
|
2499
|
+
});
|
|
2500
|
+
tool.file.file_id = uploadedFile.id;
|
|
2501
|
+
report_ai_status('files');
|
|
2502
|
+
} catch (error) {
|
|
2503
|
+
report_ai_status('files', error);
|
|
2504
|
+
throw error;
|
|
2505
|
+
}
|
|
2494
2506
|
|
|
2495
2507
|
if (!tool.file.vector_file_id) {
|
|
2496
2508
|
try {
|