praisonai 1.0.17 → 1.0.18
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/dist/agent/index.d.ts +2 -1
- package/dist/agent/proxy.d.ts +1 -0
- package/dist/agent/proxy.js +2 -1
- package/dist/agent/simple.d.ts +13 -0
- package/dist/agent/simple.js +72 -0
- package/package.json +2 -2
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function setTaskMode(enabled: boolean): void;
|
|
2
2
|
export { Agent, PraisonAIAgents, Task } from './proxy';
|
|
3
|
+
export type { ProxyAgentConfig } from './proxy';
|
|
3
4
|
export type { AgentConfig } from './types';
|
|
4
5
|
export type { TaskConfig } from './types';
|
|
5
|
-
export type { PraisonAIAgentsConfig } from './simple';
|
|
6
|
+
export type { PraisonAIAgentsConfig, SimpleAgentConfig } from './simple';
|
package/dist/agent/proxy.d.ts
CHANGED
package/dist/agent/proxy.js
CHANGED
package/dist/agent/simple.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface SimpleAgentConfig {
|
|
|
7
7
|
markdown?: boolean;
|
|
8
8
|
stream?: boolean;
|
|
9
9
|
tools?: any[];
|
|
10
|
+
toolFunctions?: Record<string, Function>;
|
|
10
11
|
}
|
|
11
12
|
export declare class Agent {
|
|
12
13
|
private instructions;
|
|
@@ -27,6 +28,18 @@ export declare class Agent {
|
|
|
27
28
|
* @param fn Function implementation
|
|
28
29
|
*/
|
|
29
30
|
registerToolFunction(name: string, fn: Function): void;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a tool definition exists for the given function name
|
|
33
|
+
* @param name Function name
|
|
34
|
+
* @returns True if a tool definition exists
|
|
35
|
+
*/
|
|
36
|
+
private hasToolDefinition;
|
|
37
|
+
/**
|
|
38
|
+
* Auto-generate a tool definition based on the function
|
|
39
|
+
* @param name Function name
|
|
40
|
+
* @param func Function implementation
|
|
41
|
+
*/
|
|
42
|
+
private addAutoGeneratedToolDefinition;
|
|
30
43
|
/**
|
|
31
44
|
* Process tool calls from the model
|
|
32
45
|
* @param toolCalls Tool calls from the model
|
package/dist/agent/simple.js
CHANGED
|
@@ -18,6 +18,16 @@ class Agent {
|
|
|
18
18
|
// Configure logging
|
|
19
19
|
logger_1.Logger.setVerbose(this.verbose);
|
|
20
20
|
logger_1.Logger.setPretty(this.pretty);
|
|
21
|
+
// Register directly provided tool functions if any
|
|
22
|
+
if (config.toolFunctions) {
|
|
23
|
+
for (const [name, func] of Object.entries(config.toolFunctions)) {
|
|
24
|
+
this.registerToolFunction(name, func);
|
|
25
|
+
// Auto-generate tool definition if not already provided
|
|
26
|
+
if (!this.hasToolDefinition(name)) {
|
|
27
|
+
this.addAutoGeneratedToolDefinition(name, func);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
21
31
|
}
|
|
22
32
|
createSystemPrompt() {
|
|
23
33
|
let prompt = this.instructions;
|
|
@@ -35,6 +45,68 @@ class Agent {
|
|
|
35
45
|
this.toolFunctions[name] = fn;
|
|
36
46
|
logger_1.Logger.debug(`Registered tool function: ${name}`);
|
|
37
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Check if a tool definition exists for the given function name
|
|
50
|
+
* @param name Function name
|
|
51
|
+
* @returns True if a tool definition exists
|
|
52
|
+
*/
|
|
53
|
+
hasToolDefinition(name) {
|
|
54
|
+
if (!this.tools)
|
|
55
|
+
return false;
|
|
56
|
+
return this.tools.some(tool => {
|
|
57
|
+
if (tool.type === 'function' && tool.function) {
|
|
58
|
+
return tool.function.name === name;
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Auto-generate a tool definition based on the function
|
|
65
|
+
* @param name Function name
|
|
66
|
+
* @param func Function implementation
|
|
67
|
+
*/
|
|
68
|
+
addAutoGeneratedToolDefinition(name, func) {
|
|
69
|
+
if (!this.tools) {
|
|
70
|
+
this.tools = [];
|
|
71
|
+
}
|
|
72
|
+
// Extract parameter names from function
|
|
73
|
+
const funcStr = func.toString();
|
|
74
|
+
const paramMatch = funcStr.match(/\(([^)]*)\)/);
|
|
75
|
+
const params = paramMatch ? paramMatch[1].split(',').map(p => p.trim()).filter(p => p) : [];
|
|
76
|
+
// Create a basic tool definition
|
|
77
|
+
const toolDef = {
|
|
78
|
+
type: "function",
|
|
79
|
+
function: {
|
|
80
|
+
name,
|
|
81
|
+
description: `Auto-generated function for ${name}`,
|
|
82
|
+
parameters: {
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: {},
|
|
85
|
+
required: []
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
// Add parameters to the definition
|
|
90
|
+
if (params.length > 0) {
|
|
91
|
+
const properties = {};
|
|
92
|
+
const required = [];
|
|
93
|
+
params.forEach(param => {
|
|
94
|
+
// Remove type annotations if present
|
|
95
|
+
const paramName = param.split(':')[0].trim();
|
|
96
|
+
if (paramName) {
|
|
97
|
+
properties[paramName] = {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: `Parameter ${paramName} for function ${name}`
|
|
100
|
+
};
|
|
101
|
+
required.push(paramName);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
toolDef.function.parameters.properties = properties;
|
|
105
|
+
toolDef.function.parameters.required = required;
|
|
106
|
+
}
|
|
107
|
+
this.tools.push(toolDef);
|
|
108
|
+
logger_1.Logger.debug(`Auto-generated tool definition for ${name}`);
|
|
109
|
+
}
|
|
38
110
|
/**
|
|
39
111
|
* Process tool calls from the model
|
|
40
112
|
* @param toolCalls Tool calls from the model
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praisonai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "PraisonAI TypeScript AI Agents Framework - Node.js, npm, and Javascript AI Agents Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"fast-xml-parser": "^4.5.1",
|
|
63
63
|
"node-fetch": "^2.6.9",
|
|
64
64
|
"openai": "^4.81.0",
|
|
65
|
-
"praisonai": "^1.0.
|
|
65
|
+
"praisonai": "^1.0.17"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"boxen": "^7.1.1",
|