@fractal-solutions/qflow 1.0.59 → 1.0.60
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/README.md +77 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -557,9 +557,85 @@ anotherNode.setParams({
|
|
|
557
557
|
|
|
558
558
|
## Agents
|
|
559
559
|
|
|
560
|
-
|
|
561
560
|
For a detailed explanation of the agents, see the [Agents documentation](documentation/agents.md). The tools available to agents are documented in the [Tools documentation](documentation/integrated_nodes.md).
|
|
562
561
|
|
|
562
|
+
### Extending Agents with Custom Tools
|
|
563
|
+
|
|
564
|
+
`qflow` agents can be extended with custom tools by defining your own Node classes and making them discoverable. This allows agents to leverage any custom logic or external integrations you build.
|
|
565
|
+
|
|
566
|
+
#### 1. Creating a Custom Tool Node
|
|
567
|
+
|
|
568
|
+
To create a custom node that can be used as a tool by an agent, your node class must:
|
|
569
|
+
* Extend `AsyncNode`.
|
|
570
|
+
* Implement a `static getToolDefinition()` method that returns a JSON Schema object describing the tool's name, description, and parameters.
|
|
571
|
+
|
|
572
|
+
Here's an example of a simple custom node that an agent could use as a tool:
|
|
573
|
+
|
|
574
|
+
```javascript
|
|
575
|
+
// my_nodes/MyCustomToolNode.js
|
|
576
|
+
import { AsyncNode } from '@fractal-solutions/qflow';
|
|
577
|
+
|
|
578
|
+
export class MyCustomToolNode extends AsyncNode {
|
|
579
|
+
static getToolDefinition() {
|
|
580
|
+
return {
|
|
581
|
+
name: "my_custom_tool",
|
|
582
|
+
description: "A custom tool that greets the user with a personalized message.",
|
|
583
|
+
parameters: {
|
|
584
|
+
type: "object",
|
|
585
|
+
properties: {
|
|
586
|
+
name: {
|
|
587
|
+
type: "string",
|
|
588
|
+
description: "The name of the person to greet."
|
|
589
|
+
},
|
|
590
|
+
greeting: {
|
|
591
|
+
type: "string",
|
|
592
|
+
description: "Optional. The greeting message. Defaults to 'Hello'."
|
|
593
|
+
}
|
|
594
|
+
},
|
|
595
|
+
required: ["name"]
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
async execAsync() {
|
|
601
|
+
const { name, greeting = 'Hello' } = this.params;
|
|
602
|
+
const message = `${greeting}, ${name}! Welcome to your custom tool.`;
|
|
603
|
+
console.log(message);
|
|
604
|
+
return { message: message };
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
async postAsync(shared, prepRes, execRes) {
|
|
608
|
+
shared.customToolOutput = execRes.message;
|
|
609
|
+
return 'default';
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
#### 2. Making Custom Tools Discoverable
|
|
615
|
+
|
|
616
|
+
To make your custom tool nodes available to `qflow` agents, you need to specify their paths in a `qflow.config.js` file in your project's root directory.
|
|
617
|
+
|
|
618
|
+
First, create a `qflow.config.js` file if you don't have one:
|
|
619
|
+
|
|
620
|
+
```javascript
|
|
621
|
+
// qflow.config.js
|
|
622
|
+
/**
|
|
623
|
+
* @type {import('./src/types').QFlowConfig}
|
|
624
|
+
*/
|
|
625
|
+
const qflowConfig = {
|
|
626
|
+
customNodePaths: [
|
|
627
|
+
'./my_nodes/MyCustomToolNode.js', // Path to your custom node file
|
|
628
|
+
// Add more paths for other custom nodes
|
|
629
|
+
],
|
|
630
|
+
};
|
|
631
|
+
|
|
632
|
+
export default qflowConfig;
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
The `customNodePaths` array should contain paths to your custom node files, relative to your project's root directory. `qflow` will automatically load these files, discover any `AsyncNode` classes with a `static getToolDefinition()` method, and register them as available tools for your agents.
|
|
636
|
+
|
|
637
|
+
Once configured, your agents will be able to "see" and utilize `my_custom_tool` just like any built-in tool, allowing for powerful and flexible agentic workflows tailored to your specific needs.
|
|
638
|
+
|
|
563
639
|
## Integrated Nodes and their Examples
|
|
564
640
|
|
|
565
641
|
Here's a comprehensive list of integrated nodes available in qflow, along with a brief description and a link to their detailed documentation.
|
package/package.json
CHANGED