@xuda.io/ai_module 1.1.3993 → 1.1.3994
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 +23 -24
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4809,31 +4809,30 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4809
4809
|
// }
|
|
4810
4810
|
|
|
4811
4811
|
case 'image_generate': {
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
numGenerations: z.number().int().describe('Number generations to image create.').default(3),
|
|
4819
|
-
}),
|
|
4820
|
-
async execute(e, RunContext) {
|
|
4821
|
-
const { prompt, numGenerations } = e;
|
|
4822
|
-
try {
|
|
4823
|
-
let imgTags = '';
|
|
4824
|
-
const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', prompt, numGenerations, uid, app_id, job_id, headers);
|
|
4825
|
-
for (const img_obj of images_arr) {
|
|
4826
|
-
imgTags += `<img src="${img_obj.file_url}" alt="${prompt}" style="max-width: 100%; border-radius: 8px;" />`;
|
|
4827
|
-
}
|
|
4828
|
-
|
|
4829
|
-
return imgTags;
|
|
4830
|
-
} catch (err) {
|
|
4831
|
-
console.error('Image Tool Error:', err);
|
|
4832
|
-
return `Error generating image: ${err.message}`;
|
|
4833
|
-
}
|
|
4834
|
-
},
|
|
4812
|
+
register_tool({
|
|
4813
|
+
name,
|
|
4814
|
+
description,
|
|
4815
|
+
parameters: z.object({
|
|
4816
|
+
prompt: z.string().describe('The prompt for the image.'),
|
|
4817
|
+
numGenerations: z.number().int().describe('Number generations to image create.').default(3),
|
|
4835
4818
|
}),
|
|
4836
|
-
|
|
4819
|
+
async execute(e, RunContext) {
|
|
4820
|
+
const { prompt, numGenerations } = e;
|
|
4821
|
+
try {
|
|
4822
|
+
let imgTags = '';
|
|
4823
|
+
const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', prompt, numGenerations, uid, app_id, job_id, headers);
|
|
4824
|
+
for (const img_obj of images_arr) {
|
|
4825
|
+
imgTags += `<img src="${img_obj.file_url}" alt="${prompt}" style="max-width: 100%; border-radius: 8px;" />`;
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4828
|
+
return imgTags;
|
|
4829
|
+
} catch (err) {
|
|
4830
|
+
console.error('Image Tool Error:', err);
|
|
4831
|
+
return `Error generating image: ${err.message}`;
|
|
4832
|
+
}
|
|
4833
|
+
},
|
|
4834
|
+
});
|
|
4835
|
+
|
|
4837
4836
|
break;
|
|
4838
4837
|
}
|
|
4839
4838
|
|