Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
GraphAI - Full-Stack TypeScript Tool for AI App...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Isamu Arimoto
November 23, 2024
Technology
520
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
14
GraphAI
isamu
0
440
Other Decks in Technology
See All in Technology
.NET WebAssemblyで実現するクライアントサイドAI推論:NuGetからViteまで、2つのエコシステムを繋ぐビルド戦略
yamachu
0
260
データ_AIの事業の勝敗をわけるもの
nek0128
1
460
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
5
650
AI 時代のスタートアップエコシステ厶から考究する技術的負債との向き合い方
m3m0r7
PRO
3
2.3k
`t*(42&t>>10)`だけで音楽が鳴る、Swiftで実装するBytebeat / iOSDC Japan 2026
yutailang0119
0
120
安心して変更できるWebフロントエンドの作り方
pirosikick
5
2.8k
時うどん〜Socket.getifaddrsで学ぶネットワーク編 / Tokiudon: The Socket.getifaddrs Edition
coe401_
3
160
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
180
バイブコーディング時代のWebアプリ開発入門~Cloud Runで学ぶセキュアなビルドとデプロイ
waiwai2111
1
140
HHKBエバンジェリストになる方法
941
0
110
SREへの勘違いに気づいた後の話
tomodakengo
0
110
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
3
930
Featured
See All Featured
So, you think you're a good person
axbom
PRO
2
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
How to build a perfect <img>
jonoalderson
1
6k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
530
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
240
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Building the Perfect Custom Keyboard
takai
2
880
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How to make the Groovebox
asonas
2
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