@xuda.io/ai_module 1.1.3993 → 1.1.3995
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 +27 -28
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -4627,10 +4627,6 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4627
4627
|
let tools = [];
|
|
4628
4628
|
let tool_resources = {};
|
|
4629
4629
|
|
|
4630
|
-
const register_tool = function (opt) {
|
|
4631
|
-
tools.push(tool(opt));
|
|
4632
|
-
};
|
|
4633
|
-
|
|
4634
4630
|
for (const [key, val] of Object.entries(ai_agent_doc?.agentConfig?.agent_tools || [])) {
|
|
4635
4631
|
const { name, description } = val;
|
|
4636
4632
|
switch (val.type) {
|
|
@@ -4716,30 +4712,33 @@ const ai_chat_conversation = async function (req, job_id, headers) {
|
|
|
4716
4712
|
}
|
|
4717
4713
|
}
|
|
4718
4714
|
try {
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
const
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4715
|
+
const tool_name = method_name.replace(/_/g, ' ').replace(/\b(\w)/g, (_, char) => char.toUpperCase());
|
|
4716
|
+
tools.push(
|
|
4717
|
+
tool({
|
|
4718
|
+
name: tool_name.substring(0, 60),
|
|
4719
|
+
description: method_prop.description,
|
|
4720
|
+
parameters: z.object(inputSchema),
|
|
4721
|
+
async execute(e, RunContext) {
|
|
4722
|
+
const params = e;
|
|
4723
|
+
try {
|
|
4724
|
+
const response = await fetch(`http://localhost:3007/cpi/${method_name}`, {
|
|
4725
|
+
method: 'POST',
|
|
4726
|
+
headers: {
|
|
4727
|
+
Accept: 'application/json',
|
|
4728
|
+
'Content-Type': 'application/json',
|
|
4729
|
+
},
|
|
4730
|
+
body: JSON.stringify({ ...params, ...{ gtp_token } }),
|
|
4731
|
+
});
|
|
4732
|
+
const ret = await response.json();
|
|
4733
|
+
return {
|
|
4734
|
+
content: [{ type: 'text', text: JSON.stringify(ret || '', null, 2) }],
|
|
4735
|
+
};
|
|
4736
|
+
} catch (err) {
|
|
4737
|
+
return 'unknown';
|
|
4738
|
+
}
|
|
4739
|
+
},
|
|
4740
|
+
}),
|
|
4741
|
+
);
|
|
4743
4742
|
} catch (error) {
|
|
4744
4743
|
debugger;
|
|
4745
4744
|
}
|