-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
500 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"printWidth": 160 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
# @graphai/tools_agent for GraphAI | ||
|
||
General tools agents | ||
|
||
### Install | ||
|
||
```sh | ||
yarn add @graphai/tools_agent | ||
``` | ||
|
||
|
||
### Usage | ||
|
||
```typescript | ||
import { GraphAI } from "graphai"; | ||
import { toolsAgent } from "@graphai/tools_agent"; | ||
|
||
const agents = { toolsAgent }; | ||
|
||
const graph = new GraphAI(graph_data, agents); | ||
const result = await graph.run(); | ||
``` | ||
|
||
### Agents description | ||
- toolsAgent - | ||
|
||
### Input/Output/Params Schema & samples | ||
- [toolsAgent](https://github.com/receptron/graphai/blob/main/docs/agentDocs/undefined/toolsAgent.md) | ||
|
||
### Input/Params example | ||
- toolsAgent | ||
|
||
```typescript | ||
{ | ||
"inputs": { | ||
"llmAgent": "openAIAgent", | ||
"tools": [ | ||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "lightAgent--toggleLight", | ||
"description": "Switch of light", | ||
"parameters": { | ||
"type": "object", | ||
"properties": { | ||
"switch": { | ||
"type": "boolean", | ||
"description": "change light state" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"messages": [ | ||
{ | ||
"role": "system", | ||
"content": "You are a light switch. Please follow the user's instructions." | ||
} | ||
], | ||
"userInput": { | ||
"text": "turn on the light.", | ||
"message": { | ||
"role": "user", | ||
"content": "turn on the light." | ||
} | ||
} | ||
}, | ||
"params": {} | ||
} | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import eslintBase from "../../config/eslint.config.base.mjs"; | ||
|
||
export default [ | ||
{ | ||
files: ["{src,test,samles}/**/*.{js,ts,yaml,yml,json}"], | ||
}, | ||
{ | ||
ignores: ["lib/**/*", "*.ts", "apiDoc/**/*", "apiDoc/*"], | ||
}, | ||
...eslintBase, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import toolsAgent from "./tools_agent"; | ||
export { toolsAgent }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toolsAgent = void 0; | ||
const tools_agent_1 = __importDefault(require("./tools_agent")); | ||
exports.toolsAgent = tools_agent_1.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
declare const toolsAgentInfo: { | ||
name: string; | ||
agent: (context: import("graphai").AgentFunctionContext) => Promise<any>; | ||
mock: (context: import("graphai").AgentFunctionContext) => Promise<any>; | ||
samples: { | ||
inputs: { | ||
llmAgent: string; | ||
tools: { | ||
type: string; | ||
function: { | ||
name: string; | ||
description: string; | ||
parameters: { | ||
type: string; | ||
properties: { | ||
switch: { | ||
type: string; | ||
description: string; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}[]; | ||
messages: { | ||
role: string; | ||
content: string; | ||
}[]; | ||
userInput: { | ||
text: string; | ||
message: { | ||
role: string; | ||
content: string; | ||
}; | ||
}; | ||
}; | ||
params: {}; | ||
result: string; | ||
}[]; | ||
description: string; | ||
category: never[]; | ||
author: string; | ||
repository: string; | ||
tools: never[]; | ||
license: string; | ||
hasGraphData: boolean; | ||
}; | ||
export default toolsAgentInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const nested_agent_1 = require("@graphai/vanilla/lib/graph_agents/nested_agent"); | ||
const toolWorkFlowStep = { | ||
version: 0.5, | ||
nodes: { | ||
llm: { | ||
agent: ":llmAgent", | ||
isResult: true, | ||
params: { | ||
forWeb: true, | ||
stream: true, | ||
tools: ":tools", | ||
}, | ||
inputs: { messages: ":messages", prompt: ":userInput.text" }, | ||
}, | ||
textMessage: { | ||
unless: ":llm.tool.id", | ||
agent: "copyAgent", | ||
inputs: { | ||
messages: [":userInput.message", { role: "assistant", content: ":llm.message.content" }], | ||
}, | ||
}, | ||
tool_calls: { | ||
if: ":llm.tool_calls", | ||
agent: "mapAgent", | ||
inputs: { rows: ":llm.tool_calls" }, | ||
params: { | ||
compositeResult: true, | ||
}, | ||
graph: { | ||
version: 0.5, | ||
nodes: { | ||
tool: { | ||
agent: ":row.name.split(--).$0", | ||
inputs: { | ||
arg: ":row.arguments", | ||
func: ":row.name.split(--).$1", | ||
tool_call: ":row", | ||
}, | ||
}, | ||
message: { | ||
isResult: true, | ||
agent: "copyAgent", | ||
inputs: { | ||
role: "tool", | ||
tool_call_id: ":row.id", | ||
name: ":row.name", | ||
content: ":tool.result", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
toolsMessage: { | ||
agent: "pushAgent", | ||
inputs: { | ||
array: [":userInput.message", ":llm.message"], | ||
items: ":tool_calls.message", | ||
}, | ||
}, | ||
buffer: { | ||
agent: "copyAgent", | ||
anyInput: true, | ||
inputs: { array: [":textMessage.messages", ":toolsMessage.array"] }, | ||
}, | ||
reducer: { | ||
isResult: true, | ||
agent: "pushAgent", | ||
inputs: { array: ":messages", items: ":buffer.array.$0" }, | ||
}, | ||
}, | ||
}; | ||
const toolsAgent = (0, nested_agent_1.nestedAgentGenerator)(toolWorkFlowStep); | ||
const toolsAgentInfo = { | ||
name: "toolsAgent", | ||
agent: toolsAgent, | ||
mock: toolsAgent, | ||
samples: [ | ||
{ | ||
inputs: { | ||
llmAgent: "openAIAgent", | ||
tools: [ | ||
{ | ||
type: "function", | ||
function: { | ||
name: "lightAgent--toggleLight", | ||
description: "Switch of light", | ||
parameters: { | ||
type: "object", | ||
properties: { | ||
switch: { | ||
type: "boolean", | ||
description: "change light state", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
messages: [ | ||
{ | ||
role: "system", | ||
content: "You are a light switch. Please follow the user's instructions.", | ||
}, | ||
], | ||
userInput: { | ||
text: "turn on the light.", | ||
message: { | ||
role: "user", | ||
content: "turn on the light.", | ||
}, | ||
}, | ||
}, | ||
params: {}, | ||
result: "", | ||
}, | ||
], | ||
description: "", | ||
category: [], | ||
author: "", | ||
repository: "", | ||
tools: [], | ||
license: "", | ||
hasGraphData: true, | ||
}; | ||
exports.default = toolsAgentInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "@graphai/tools_agent", | ||
"version": "0.2.0", | ||
"description": "General tools agents", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"./lib" | ||
], | ||
"scripts": { | ||
"build": "rm -r lib/* && tsc && tsc-alias", | ||
"eslint": "eslint", | ||
"format": "prettier --write '{src,tests,samples}/**/*.ts'", | ||
"doc": "npx agentdoc", | ||
"examplesDoc": "npx ts-node -r tsconfig-paths/register tests/examples.ts", | ||
"test": "echo nothing", | ||
"test_run": "node --test -r tsconfig-paths/register --require ts-node/register ./tests/run_*.ts # just run locally", | ||
"chat": "node -r tsconfig-paths/register -r ts-node/register ./tests/chat_dispatch.ts", | ||
"b": "yarn run format && yarn run eslint && yarn run build" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/receptron/graphai" | ||
}, | ||
"author": "Satoshi Nakajima, Isamu Arimoto", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/receptron/graphai/issues" | ||
}, | ||
"homepage": "https://github.com/receptron/graphai/blob/main/llm_agents/tools_agent/README.md", | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"types": "./lib/index.d.ts", | ||
"directories": { | ||
"lib": "lib" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import toolsAgent from "./tools_agent"; | ||
|
||
export { toolsAgent }; |
Oops, something went wrong.