@xuda.io/ai_module 1.1.3850 → 1.1.3852
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 +5 -4
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2018,7 +2018,7 @@ export const unarchive_ai_chat = async function (req) {
|
|
|
2018
2018
|
// }
|
|
2019
2019
|
// };
|
|
2020
2020
|
|
|
2021
|
-
const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256) {
|
|
2021
|
+
const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', size = '1024x1024', n = 1, width = 256, height = 256, metadata = {}) {
|
|
2022
2022
|
try {
|
|
2023
2023
|
const response = await client.images.generate({
|
|
2024
2024
|
model,
|
|
@@ -2062,7 +2062,7 @@ const create_image = async function (uid, prompt, model = 'gpt-image-1-mini', si
|
|
|
2062
2062
|
|
|
2063
2063
|
const thumbnailBase64 = resized.toString('base64');
|
|
2064
2064
|
|
|
2065
|
-
record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model);
|
|
2065
|
+
record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt, model, metadata);
|
|
2066
2066
|
|
|
2067
2067
|
return thumbnailBase64;
|
|
2068
2068
|
} catch (err) {
|
|
@@ -5462,7 +5462,7 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
|
|
|
5462
5462
|
const create_and_upload_image_to_drive = async function (drive_type, file_path, file_name, prompt, numGenerations, uid, app_id, job_id, headers, is_system, tags = [], width, height) {
|
|
5463
5463
|
try {
|
|
5464
5464
|
// 1. Generate the images
|
|
5465
|
-
let result = await create_image(uid, prompt, undefined, undefined, numGenerations);
|
|
5465
|
+
let result = await create_image(uid, prompt, undefined, undefined, numGenerations, undefined, undefined, { drive_type, file_path, file_name });
|
|
5466
5466
|
|
|
5467
5467
|
// Normalize to array
|
|
5468
5468
|
const images = Array.isArray(result) ? result : [result];
|
|
@@ -6251,7 +6251,7 @@ const create_ai_agent_image = async function (req, job_id, headers) {
|
|
|
6251
6251
|
}
|
|
6252
6252
|
};
|
|
6253
6253
|
|
|
6254
|
-
const record_chat_usage = async function (uid, input_tokens, output_tokens, source, prompt, metadata = {}) {
|
|
6254
|
+
const record_chat_usage = async function (uid, input_tokens, output_tokens, source, prompt, model, metadata = {}) {
|
|
6255
6255
|
try {
|
|
6256
6256
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
6257
6257
|
|
|
@@ -6267,6 +6267,7 @@ const record_chat_usage = async function (uid, input_tokens, output_tokens, sour
|
|
|
6267
6267
|
output_tokens,
|
|
6268
6268
|
stat: 3,
|
|
6269
6269
|
metadata,
|
|
6270
|
+
model,
|
|
6270
6271
|
};
|
|
6271
6272
|
const save_ret = await db_module.save_app_couch_doc(app_id, usage_doc);
|
|
6272
6273
|
// console.log(save_ret);
|