🤖
GraphAI abortの機能を追加
GraphAI 0.6.20 リリースノート
GraphAI 0.6.20がリリースされました。大きな変更点として、abort()が追加されました。
グラフフローの実行中に、このAPIを呼ぶと、処理を途中で止めることが出来ます。
const graphAI = new GraphAI(graphData, agents, graphOptions);
const runGraphAI = async () => {
try {
const result = graphAI.run();
...
} catch (e) {
...
}
};
const stopGraphAI = () => {
graphAI.abort();
...
}
- abort()を呼ぶと、run()はすぐにrejectを返す。
- 実行中のagentは、最後まで実行される。
- その後のagentは実行されない。
以下、関連パッケージを最新にすると有効になります。
- nestedAgent/mapAgentなどのsubGraphを実行するagentも同じようにabortされる (@graphai/vanilla@0.2.12)
- streamingの処理もabortしたときに、データを返さなくなる。 (@graphai/agent_filters@0.2.0)
開発者向け情報
- subGraphを実行するagentを作るときは、そのagent内で親agentにsubGraphを登録/削除する必要があります
debugInfo.subGraphs.set(graphAI.graphId, graphAI);
const results = await graphAI.run(false);
debugInfo.subGraphs.delete(graphAI.graphId);
- streamingのようなagent実行中に、ユーザやgraphaiの外にデータを渡す処理をするagent/agent filterを作るときは、agentのstatusがExecutingかどうか確認して処理をする必要があります。
context.filterParams.streamTokenCallback = (data: T) => {
if (context.debugInfo.state === NodeState.Executing) {
callback(context, data);
}
};

人工知能を活用したアプリケーションやサービスを活用し、内発的動機付けで行動するエンジニア、起業家、社会起業家をサポートするコミュニティーです。 singularitysociety.org
Discussion