2.0.1 • Published 5 months ago
@graphai/service_agents v2.0.1
@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"
}
}
}
}