@xuda.io/ai_module 1.1.3836 → 1.1.3837
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 +6 -3
- 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 (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) {
|
|
2022
2022
|
try {
|
|
2023
2023
|
const response = await client.images.generate({
|
|
2024
2024
|
model,
|
|
@@ -2061,6 +2061,9 @@ const create_image = async function (prompt, model = 'gpt-image-1-mini', size =
|
|
|
2061
2061
|
const resized = await sharp(fullImgBuffer).resize(width, height).toFormat('png').toBuffer();
|
|
2062
2062
|
|
|
2063
2063
|
const thumbnailBase64 = resized.toString('base64');
|
|
2064
|
+
|
|
2065
|
+
record_chat_usage(uid, response.usage.input_tokens, response.usage.output_tokens, 'create image', prompt);
|
|
2066
|
+
|
|
2064
2067
|
return thumbnailBase64;
|
|
2065
2068
|
} catch (err) {
|
|
2066
2069
|
console.error('create_image error:', err);
|
|
@@ -5459,7 +5462,7 @@ const get_plugin_tool = async function (app_id, uid, plugin_name, method, prop_d
|
|
|
5459
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) {
|
|
5460
5463
|
try {
|
|
5461
5464
|
// 1. Generate the images
|
|
5462
|
-
let result = await create_image(prompt, undefined, undefined, numGenerations);
|
|
5465
|
+
let result = await create_image(uid, prompt, undefined, undefined, numGenerations);
|
|
5463
5466
|
|
|
5464
5467
|
// Normalize to array
|
|
5465
5468
|
const images = Array.isArray(result) ? result : [result];
|
|
@@ -5775,7 +5778,7 @@ export const convert_profile_image_to_avatar = async function (req, job_id, head
|
|
|
5775
5778
|
const prompt = `analyze the the person info : ${JSON.stringify({ first_name, last_name, bio, country, mainCategory, subCategory })}
|
|
5776
5779
|
and create realistic fictional profile picture transparent background ,person in the center of the picture return only a centered head-and-shoulders portrait facing the camera. include no labels or text add top margin the person should cover the whole picture`;
|
|
5777
5780
|
|
|
5778
|
-
imageBase64 = await create_image(prompt, undefined, undefined, 1);
|
|
5781
|
+
imageBase64 = await create_image(uid, prompt, undefined, undefined, 1);
|
|
5779
5782
|
avatar_source = 'fictional';
|
|
5780
5783
|
};
|
|
5781
5784
|
// personal account
|