2.0.1 • Published 5 months ago

@graphai/vanilla_node_agents v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@graphai/vanilla_node_agents for GraphAI

Vanilla node agents for GraphAI.

Install

yarn add @graphai/vanilla_node_agents

Usage

import { GraphAI } from "graphai";
import { fileReadAgent, fileWriteAgent, pathUtilsAgent } from "@graphai/vanilla_node_agents";

const agents = { fileReadAgent, fileWriteAgent, pathUtilsAgent };

const graph = new GraphAI(graph_data, agents);
const result = await graph.run();

Agents description

  • fileReadAgent - Read data from file system and returns data
  • fileWriteAgent - Write data to file system
  • pathUtilsAgent - Path utils

Input/Output/Params Schema & samples

Input/Params example

  • fileReadAgent

inputs.file specifies a single file name to read.

inputs.array specifies multiple file names to read.

params.baseDir is required and defines the root directory where files are located.

params.outputType optionally controls the output format: 'text' for UTF-8 string, 'base64' for Base64-encoded string, 'stream' for readable stream, or omit for Buffer output.

{
  "inputs": {
    "array": [
      "test.txt"
    ]
  },
  "params": {
    "baseDir": "/home/runner/work/graphai/graphai/agents/vanilla_node_agents/lib/node_file_agents/../../tests/files/"
  }
}
{
  "inputs": {
    "array": [
      "test.txt"
    ]
  },
  "params": {
    "baseDir": "/home/runner/work/graphai/graphai/agents/vanilla_node_agents/lib/node_file_agents/../../tests/files/",
    "outputType": "base64"
  }
}
{
  "inputs": {
    "array": [
      "test.txt"
    ]
  },
  "params": {
    "baseDir": "/home/runner/work/graphai/graphai/agents/vanilla_node_agents/lib/node_file_agents/../../tests/files/",
    "outputType": "text"
  }
}
// Reads a single file named 'test.txt' from the given base directory and returns its contents as a UTF-8 string.
{
  "inputs": {
    "file": "test.txt"
  },
  "params": {
    "baseDir": "/home/runner/work/graphai/graphai/agents/vanilla_node_agents/lib/node_file_agents/../../tests/files/",
    "outputType": "text"
  }
}
  • fileWriteAgent
{
  "inputs": {
    "file": "write.txt",
    "text": "hello"
  },
  "params": {
    "baseDir": "/home/runner/work/graphai/graphai/agents/vanilla_node_agents/lib/node_file_agents/../../tests/files/"
  }
}
  • pathUtilsAgent
{
  "inputs": {
    "dirs": [
      "/base/",
      "tmp/",
      "test.txt"
    ]
  },
  "params": {
    "method": "resolve"
  }
}
{
  "inputs": {
    "dirs": [
      "base/",
      "tmp/",
      "test.txt"
    ]
  },
  "params": {
    "method": "join"
  }
}
{
  "inputs": {
    "path": "base///tmp//test.txt"
  },
  "params": {
    "method": "normalize"
  }
}
2.0.1

5 months ago

2.0.0

6 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.2.7

10 months ago

0.2.6

11 months ago

0.2.5

11 months ago

0.2.4

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago