2.0.1 • Published 5 months ago

@graphai/service_agents v2.0.1

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

@graphai/service_agents for GraphAI

Service agents for GraphAI.

Install

yarn add @graphai/service_agents

The fetchAgent included in this package is not well-maintained. Use this fetch agent only when XML parsing is required. For fetching JSON or text, use vanillaFetchAgent instead, as it is better maintained.

https://www.npmjs.com/package/@graphai/vanilla

Usage

import { GraphAI } from "graphai";
import { fetchAgent, wikipediaAgent } from "@graphai/service_agents";

const agents = { fetchAgent, wikipediaAgent };

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

Agents description

  • fetchAgent - Retrieves JSON data from the specified URL
  • wikipediaAgent - Retrieves data from wikipedia

Input/Output/Params Schema & samples

Input/Params example

  • fetchAgent
{
  "inputs": {
    "url": "https://www.google.com",
    "queryParams": {
      "foo": "bar"
    },
    "headers": {
      "x-myHeader": "secret"
    }
  },
  "params": {
    "debug": true
  }
}
{
  "inputs": {
    "url": "https://www.google.com",
    "queryParams": {
      "foo": "bar"
    },
    "headers": {
      "x-myHeader": "secret"
    },
    "method": "GET"
  },
  "params": {
    "debug": true
  }
}
{
  "inputs": {
    "url": "https://www.google.com",
    "body": {
      "foo": "bar"
    }
  },
  "params": {
    "debug": true
  }
}
  • wikipediaAgent
{
  "inputs": {
    "query": "steve jobs"
  },
  "params": {
    "lang": "ja"
  }
}

GraphData Example

graphDataFetch

{
  "version": 0.5,
  "nodes": {
    "url": {
      "value": "https://www.google.com/search?q=hello"
    },
    "fetch": {
      "agent": "fetchAgent",
      "params": {
        "type": "text"
      },
      "inputs": {
        "url": ":url"
      }
    },
    "success": {
      "agent": "copyAgent",
      "isResult": true,
      "unless": ":fetch.onError",
      "inputs": {
        "result": true
      }
    },
    "error": {
      "agent": "copyAgent",
      "isResult": true,
      "if": ":fetch.onError",
      "inputs": {
        "error": ":fetch.onError"
      }
    }
  }
}

graphDataPost

{
  "version": 0.5,
  "nodes": {
    "url": {
      "value": "https://www.google.com/search?q=hello"
    },
    "fetch": {
      "agent": "fetchAgent",
      "params": {
        "type": "text"
      },
      "inputs": {
        "url": ":url",
        "body": "Posting data"
      }
    },
    "success": {
      "agent": "copyAgent",
      "isResult": true,
      "unless": ":fetch.onError",
      "inputs": {
        "result": true
      }
    },
    "error": {
      "agent": "propertyFilterAgent",
      "params": {
        "include": [
          "message",
          "status"
        ]
      },
      "isResult": true,
      "if": ":fetch.onError",
      "inputs": {
        "item": ":fetch.onError"
      }
    }
  }
}
1.0.1

7 months ago

1.0.0

7 months ago

0.2.0

10 months ago

2.0.1

5 months ago

2.0.0

5 months ago

0.1.0

11 months ago

0.0.5

11 months ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago