Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GraphAI - Full-Stack TypeScript Tool for AI App...
Search
Isamu Arimoto
November 23, 2024
Technology
470
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
GraphAI - Full-Stack TypeScript Tool for AI Applications
Isamu Arimoto
November 23, 2024
More Decks by Isamu Arimoto
See All by Isamu Arimoto
MulmoCast
isamu
0
7
GraphAI
isamu
0
400
Other Decks in Technology
See All in Technology
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
740
日本 Fintech 未来予測レポート 2027〜2028年(手動編集版)
8maki
0
1.6k
機械学習を「社会実装」するということ 2026年夏版 / Social Implementation of Machine Learning June 2026 Version
moepy_stats
4
1.3k
自律型AIエージェントは何を破壊するのか
kojira
0
150
Dario Amodi『Policy on the AI Exponential』を理解する
nagatsu
0
210
JSAI2026 オーガナイズドセッションOS-27「不動産とAI」趣旨説明 / JSAI2026 Organized Session OS-27 “Real Estate and AI”: Statement of Purpose
ykiyota
0
230
やさしいA2A入門
minorun365
PRO
11
1.7k
DevOps Agentで始めるAWS運用 〜フロンティアエージェントが変える運用の現場〜
nyankotaro
1
380
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
9
650
2026TECHFRESH畢業分享會 - Lightning Talk - 資料也要 CI/CD? 用 Airbyte 自動化資料同步
line_developers_tw
PRO
0
740
[モダンアプリ勉強会]今更聞けないGit/GitHub入門
tsukuboshi
0
360
非定型業務をAI slackbotで自動化する ~ 社内要望を自動壁打ちするbotを作った ~/automating-ad-hoc-work-with-ai-slackbot
shibayu36
0
590
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
270
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
580
RailsConf 2023
tenderlove
30
1.5k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Designing for Performance
lara
611
70k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
540
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Paper Plane (Part 1)
katiecoart
PRO
0
8.8k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Transcript
GraphAI Full-Stack TypeScript Tool for AI Applications Isamu Arimoto by
Receptron team
自己紹介 Isamu Arimoto Software engineer Server/Web Singularity Society Fully-On-Chain SVG
2 NFT https://opensea.io/collection/lai dback-lu おもちかえり.com bus2.0 SlashGPT/GraphAI GraphAI by Receptron team 2
Contents 内容 GraphAI 特徴 as Full-Stack TypeScript AI GraphAI を試す方法
ツールや各種情報 GraphAI の未来 発表しないこと Agent の作り方 GraphData の作り方 マルチエージェントの作り方 GraphAI by Receptron team 3
GraphAI 特徴 背景 非同期処理 ML,LLM はPython に任せてAPI 経由で! 全部TypeScript で書きたい
FullStack TypeScript AI!! TypeScript Write once run anywhere ブラウザ、サーバ、バッチ、cli GraphAI by Receptron team 4
GraphAI とAgent Graph Graph とAgent GraphAI 本体はシンプル Graph の制御のみ Agent
- LLM/WebAPI/ データ処理/IO Agent Filter - 各Agent を実行する前後に処理を挟む GraphAI by Receptron team 5
GraphAI 特徴 GraphAI からAgent の呼び出し js のAPI で呼び出す http でサーバのAPI
を呼び出す GraphData, Agent はサーバ/ クライアントで同じコ ード 環境依存なもの 秘匿API key の必要な処理/CORS DB / Python の処理 ユーザからの入力 どのAgent/Node をどのサーバで動かすか設定可能 変更もすぐにできる express + middleware(@receptron/graphai_express) GraphAI by Receptron team 6
GraphAI を動かす構成 * Server / Batch / Browser Server Client
Agent の呼び出しはjs のapi Agent をhttp で呼び出す GraphAI by Receptron team 7
GraphAI を動かす構成 Server 分散 Server Local 混在 GraphAI by Receptron
team 8
GraphAI を動かす構成 内外Server サブグラフ GraphAI by Receptron team 9
GraphAI 特徴 Agent はjs のapi でもhttp でもOK 渡すデータは共通 http であればAgent
はTypeScript でなくても良い。 サーバでPython/Go/Rust/Ruby のAgent js でmock agent を作っておくと便利 Streaming もサポート どの構成でも、ほとんど同じように動く cli/ ブラウザ 環境に合わせて柔軟な組み合わせが可能 開発、ブラウザで動作、サーバクライアントで動作をシームレス GraphAI by Receptron team 10
GraphAI 特徴 JS API export const arrayJoinAgent = async ({
namedInputs, params }) => { const { separator } = params; return { text :namedInputs.array.join(separator ?? "") }; }; HTTP Request body { namedInput: {array: ["1", "2", "3"]}, params: { separator: "-" }} Response { text: "1-2-3" } GraphAI by Receptron team 11
さて、どうやって試す? codePen/html 11/14 から対応中。ちょっと動く。jsdelivr でumd 配布 https://codepen.io/isamua/pen/YzmgRYg html https://github.com/receptron/graphai/tree/main/packages/samples/htmlSample openAIFetchAgent
cli npm package + sample graph file web Vue.js での実装サンプル TypeScript GraphAI レポジトリのtest/sample zenn の記事 GraphAI by Receptron team 12
Agent * npm で提供 llmAgent openaiAgent / groqAgent / anthropicAgent
/ geminiAgent arrayAgent pop / push / shift / join / flat dataAgent copy / merge / sum / propertyFilter / total graphAgent nestedAgent mapAgent GraphAI by Receptron team 13
CLI で動かす CLI でコマンドとして Agent は全部入り GraphData はYAML/JSON のファイルを渡す install
npm install -g @receptron/graphai_cli GraphData のサンプル(yaml, json) をダウンロード https://github.com/receptron/graphai/tree/main/packages/samples/graph_data .env OPENAI_API_KEY=sk-xxx run graphai ${file.yaml/json} GraphAI by Receptron team 14
CLI で動かす graphai <yaml_or_json_file> run GraphAI with GraphAI file. Positionals:
--yaml_or_json_file yaml or json file [文字列] オプション: --help ヘルプを表示 [真偽] --version バージョンを表示 [真偽] -l, --list agents list -s, --sample agent sample data [文字列] -d, --detail agent detail [文字列] -v, --verbose verbose log [真偽] [必須] [デフォルト: false] -a, --all all result [真偽] [必須] [デフォルト: false] -m, --mermaid mermaid [真偽] [必須] [デフォルト: false] --yaml dump yaml [真偽] [必須] [デフォルト: false] --json dump json [真偽] [必須] [デフォルト: false] --log output log [文字列] GraphAI by Receptron team 15
Sample の紹介 https://github.com/receptron/graphai/tree/main/packages/samples/graph_data/openai business_idea_jp.yaml 事業アイデアを出して評価(map) chat.yaml シンプルなAI とのチャット(loop) interview.yaml 指定した有名人にインタビュー(history)
reception.yaml 氏名、生年月日、性別を尋ねる(tools) metachat.yaml reception.yaml を元にGraphData 生成(interpreter) weather.yaml API を使って天気を調べる(nested graph) GraphAI by Receptron team 16
TypeScript での動かし方 * 必要なパッケージのインストール yarn add graphai yarn add @graphai/agents
コード import { GraphAI } from "graphai"; import * as agent from "@graphai/agents"; const graphData = {...}; const main = async () => { const graphai = new GraphAI(graphData, agents); const ret = await graphai.run(); console.log(ret); }; main(); GraphAI by Receptron team 17
Web(vue) で動かす https://github.com/receptron/graphai-demo-web/ (vue) ほとんどのサンプルがvue のフロントだけで動く https://github.com/receptron/graphai-agent-server (express) サンプルサーバ GraphAI
by Receptron team 18
Streaming の実装方法 Agent for await (const message of chatStream) {
const token = message.choices[0].delta.content; if (filterParams && filterParams.streamTokenCallback && token) { filterParams.streamTokenCallback(token); } } Clent const outSideFunciton = (context: AgentFunctionContext, data: string) => { const nodeId = context.debugInfo.nodeId; streamData[nodeId] = (streamData[nodeId] || "") + data; }; const agentFilters = [{ name: "streamAgentFilter", agent: streamAgentFilterGenerator<string>(outSideFunciton), }]; GraphAI by Receptron team 19
npm * graphai 本体 @graphai/*_agents 単機能のごとに1つのnpm=agent / 依存関係を減らす目的 @graphai/vanilla -
npm の依存のないagent @graphai/llm_agents - openAIAgent, groqAgent などのメタパッケージ @graphai/agents - 全部入りメタパッケージ @graphai/agent_filters @receptron/* ツール郡 graphai_cli, graphai_express, GraphAI by Receptron team 20
npm * 目的 パッケージ cli 利用 @receptron/graphai_cli TypeScript で動かす*1 graphai,
@graphai/agents TypeScript でstreaming *1 + @graphai/agent_filters AgentServer(streaming) @receptron/graphai_express, @graphai/agents @graphai/agents は個別のagent でもOK AgentServer はGraphAI 不要 Server はAPI が一致していれば言語不問 inputs/params/result GraphAI by Receptron team 21
git の構成 本家レポジトリはモノレポ https://github.com/receptron/graphai packages GraphAI 本体/ サンプル/ 各種ツール/document generator/
agent filter agent 各種Agent llm_agents llm のagents yaml の純粋なサンプル https://github.com/receptron/graphai_samples express/cytoscape receptron/graphai-utils GraphAI by Receptron team 22
git の構成 Vue のデモ https://github.com/receptron/graphai-demo-web Python のAgent サーバサンプル https://github.com/receptron/graphai-python-server Agent
Server(sample) https://github.com/receptron/graphai-agent-server agents + express の実装例 GraphAI by Receptron team 23
Document 公式レポジトリのTOP からリンク zenn でGraphAI https://zenn.dev/topics/graphai?order=latest GraphAI by Receptron team
24
Express Server(API) AgentFunctionInfo を元に、サーバが提 供できるAPI 一覧 将来的に、これらの情報を使って、動的 にAgent を利用できる仕組みを提供 メタAPI
Info Server Agent 分散 + AI によるGraphData の自動 生成 GraphAI by Receptron team 25
Future 世界中のAgent を使ったDynamic multi-agent 要素技術 metachat.html - 動的にGraphData を作る agent
server agent のmetainfo + agent api 世界中のAgent のAPI List Agent を検索する仕組み Agent を探すAgent Web3 ?? Agent に対する報酬( 課金)/ 信頼性の評価 GraphAI by Receptron team 26
まとめ GraphAI は、サーバ、クライアントの構成自由自在 いろいろな方法で試せる 試して、フィードバックください GraphAI by Receptron team 27
Thank you!! GraphAI by Receptron team 28
Agent * 一覧 https://github.com/receptron/graphai/t ree/main/docs/agentDocs llmAgent openaiAgent / groqAgent /
anthropicAgent / geminiAgent arrayAgent pop / push/shift / join / flat dataAgent copy / merge / sum /propertyFilter / total graphAgent GraphAI by Receptron team 29
graphAgent nestedAgent Agent 内でGraphAI を実行 loop と組み合わせることで多様な処理 loop - Graph
全体を繰り返す(n 回 or 条件を満たすまで) Chat でユーザからの入力が条件を満たすまで Funciton calling の結果がとれるまで Code を実行するAgent と組み合わせて、正しい処理が終わるまで mapAgent 同じ処理に別々のデータを渡して並列。 アイデアを10 個出す それぞれのアイデアを評価 GraphAI by Receptron team 30
GraphData の作り方 * 必要なAgent を探す inputs でつなげる 走らせる 最初は全てnode の結果を受け取る
graphai.run(true) const main = async () => { const graphai = new GraphAI(graphData, agents); const logger = (log, __isUpdate) => { console.log(log)}; graphai.onLogCallback = logger; const ret = await graphai.run(true); console.log(ret); }; main(); GraphAI by Receptron team 31
inputs * 前のNode の結果を受け取る 依存/Agent に渡す値 Graph を作るときに一番ハマるポイ ント inputs:
Record<string, unknown> :nodeId.props.props.function().function() 前のNode の結果&Node の入力の形式 結果: nodeA: { array: ["foo", "bar"]} inputs: { text: ":nodeA.array.join() } array には array.$0 array.$1 graph_agent には見えないStaticNode が ある mapAgent rows -> row nested inputs がstatic node に GraphAI by Receptron team 32
props function inputs で使える関数 :node.array_data.length() T.B.D. GraphAI by Receptron team
33
Agent の作り方 agent/agentFunction/Sample & UnitTest 関数を作る AgentFunctionInfo でwrap (ts の場合、agent
に即時関数を渡す裏技もある) agent: (namedInputs) => { console.log(namedInputs); return true;} AgentFunctionInfo のsample でunit test Repositories Sample のAgent を作る https://github.com/isamu/graphai_agent_template Sample のAgent を作る( モノレポ) https://github.com/isamu/graphai-agents/tree/main/packages テストランナー https://github.com/isamu/graphai_agent_test_runner GraphAI by Receptron team 34
AgentFunctionInfo // Params, result, input(array), namedInput(record) export const dataSumTemplateAgent: AgentFunction<Record<never,
never>, number, number> = async ({ inputs }) => { return inputs.reduce((tmp, input) => { return tmp + input; }, 0); }; const dataSumTemplateAgentInfo: AgentFunctionInfo = { name: "dataSumTemplateAgent", agent: dataSumTemplateAgent, samples: [ { inputs: [1, 2], params: {}, result: 3, }, ], description: "Returns the sum of input values", category: ["data"], author: "Satoshi Nakajima", repository: "https://github.com/receptron/graphai", license: "MIT", }; export default dataSumTemplateAgentInfo; agent の本体と、agent に関する情報 UnitTest の自動化/Document の自動化/http でのAPI Info GraphAI by Receptron team 35
ユーティリティ Agent テスト AgentFunctionInfo を使ってUnit Test TDD Agent のdoc document
の自動生成 express server のmiddleware すぐにサーバ、クライアント構成ができる GraphAI by Receptron team 36
AgentFilter 各Agent を実行する前後に処理を挟む express のmiddleware, Rails のaround filter agentId, nodeId
単位で動作の有無を定義 例 サーバへ処理をバイパス キャッシュ ログ streaming GraphAI by Receptron team 37
GraphData/Agent の説明 * Graph Graph = Graph theory のグラフ Node
とEdge(inputs) で構成/ 有向非巡回グラフ Graph の定義では非巡回だがLoop 処理は可能( 全体を繰り替えす) NestedGraph で、局所的にLoop も可能 JSON/YAML/TypeScript の構造化データ(GraphData と呼びます) 最初に入力がないNode が実行される そのNode の動作が完了したら、そのNode の結果を受け取る次のNode が実行される GraphAI by Receptron team 38
GraphData * llm/template がNode inputs の:llm がEdge(Source がllm でTarget がtemplate)
{ "version": 0.5, "nodes": { "userInputs": { "agent": "textInputAgent", "params": { "message": "You:" } }, "llm": { "agent": "openAIAgent", "params": {"system": "You are a cat. Your name is Neko."}, "inputs": { "prompt": ":userInputs"} }, "template": { "agent": "stringTemplateAgent", "params": {"template": "${message}"}, "inputs": {"message": ":llm.text"}, "isResult": true } } } GraphAI by Receptron team 39
GraphAI って? * GraphAI 本体はNode とInputs の管理とタスクの管理のみ GraphAI 本体自体はAgent は持っていない
コンストラクタにGraphData と共に、agents や、agent filter を渡す GraphAI 本体とは別にAgent を配布している 単体パッケージ多数 Agent は必要なものだけ渡せる 自作Agent と配布されているAgent を一緒に使える GraphAI by Receptron team 40
TypeScript での動かし方( サンプル) * yarn のscript - https://github.com/receptron/graphai/tree/main/packages/samples yarn run
sample src/llm/interview_jp.ts Web(vue) - https://github.com/receptron/graphai-demo-web/ yarn install yarn serve ai-scientist-ts - https://github.com/isamu/ai-scientist GraphAI by Receptron team 41