@xuda.io/ai_module 1.1.3992 → 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.
Files changed (2) hide show
  1. package/index.mjs +47 -51
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -4716,33 +4716,30 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4716
4716
  }
4717
4717
  }
4718
4718
  try {
4719
- register_tool();
4720
- tools.push(
4721
- tool({
4722
- name: method_name.replace(/_/g, ' ').replace(/\b(\w)/g, (_, char) => char.toUpperCase()),
4723
- description: method_prop.description,
4724
- parameters: z.object(inputSchema),
4725
- async execute(e, RunContext) {
4726
- const params = e;
4727
- try {
4728
- const response = await fetch(`http://localhost:3007/cpi/${method_name}`, {
4729
- method: 'POST',
4730
- headers: {
4731
- Accept: 'application/json',
4732
- 'Content-Type': 'application/json',
4733
- },
4734
- body: JSON.stringify({ ...params, ...{ gtp_token } }),
4735
- });
4736
- const ret = await response.json();
4737
- return {
4738
- content: [{ type: 'text', text: JSON.stringify(ret || '', null, 2) }],
4739
- };
4740
- } catch (err) {
4741
- return 'unknown';
4742
- }
4743
- },
4744
- }),
4745
- );
4719
+ register_tool({
4720
+ name: method_name.replace(/_/g, ' ').replace(/\b(\w)/g, (_, char) => char.toUpperCase()),
4721
+ description: method_prop.description,
4722
+ parameters: z.object(inputSchema),
4723
+ async execute(e, RunContext) {
4724
+ const params = e;
4725
+ try {
4726
+ const response = await fetch(`http://localhost:3007/cpi/${method_name}`, {
4727
+ method: 'POST',
4728
+ headers: {
4729
+ Accept: 'application/json',
4730
+ 'Content-Type': 'application/json',
4731
+ },
4732
+ body: JSON.stringify({ ...params, ...{ gtp_token } }),
4733
+ });
4734
+ const ret = await response.json();
4735
+ return {
4736
+ content: [{ type: 'text', text: JSON.stringify(ret || '', null, 2) }],
4737
+ };
4738
+ } catch (err) {
4739
+ return 'unknown';
4740
+ }
4741
+ },
4742
+ });
4746
4743
  } catch (error) {
4747
4744
  debugger;
4748
4745
  }
@@ -4812,31 +4809,30 @@ const ai_chat_conversation = async function (req, job_id, headers) {
4812
4809
  // }
4813
4810
 
4814
4811
  case 'image_generate': {
4815
- tools.push(
4816
- tool({
4817
- name,
4818
- description,
4819
- parameters: z.object({
4820
- prompt: z.string().describe('The prompt for the image.'),
4821
- numGenerations: z.number().int().describe('Number generations to image create.').default(3),
4822
- }),
4823
- async execute(e, RunContext) {
4824
- const { prompt, numGenerations } = e;
4825
- try {
4826
- let imgTags = '';
4827
- const images_arr = await create_and_upload_image_to_drive('workspace', 'Chat Images', prompt, numGenerations, uid, app_id, job_id, headers);
4828
- for (const img_obj of images_arr) {
4829
- imgTags += `<img src="${img_obj.file_url}" alt="${prompt}" style="max-width: 100%; border-radius: 8px;" />`;
4830
- }
4831
-
4832
- return imgTags;
4833
- } catch (err) {
4834
- console.error('Image Tool Error:', err);
4835
- return `Error generating image: ${err.message}`;
4836
- }
4837
- },
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),
4838
4818
  }),
4839
- );
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
+
4840
4836
  break;
4841
4837
  }
4842
4838
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3992",
3
+ "version": "1.1.3994",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",