diff --git a/Makefile b/Makefile index d08bf04..9e639a5 100644 --- a/Makefile +++ b/Makefile @@ -132,3 +132,82 @@ fastapi: ## run FastAPI in production mode streamlit: ## run Streamlit uv run streamlit run \ template_langgraph/services/streamlits/main.py + +# --- +# Project / Create indices +# --- + +.PHONY: create-cosmosdb-index +create-cosmosdb-index: ## create Cosmos DB index + uv run python scripts/cosmosdb_operator.py --help + uv run python scripts/cosmosdb_operator.py add-documents --verbose + uv run python scripts/cosmosdb_operator.py similarity-search --query "禅モード" --k 3 --verbose + +.PHONY: create-ai-search-index +create-ai-search-index: ## create Azure AI Search index + uv run python scripts/ai_search_operator.py --help + uv run python scripts/ai_search_operator.py add-documents --verbose + uv run python scripts/ai_search_operator.py similarity-search --query "禅モード" --k 3 --verbose + +COLLECTION_NAME ?= qa_kabuto +.PHONY: create-qdrant-index +create-qdrant-index: ## create Qdrant index + uv run python scripts/qdrant_operator.py --help + uv run python scripts/qdrant_operator.py delete-collection --collection-name $(COLLECTION_NAME) --verbose + uv run python scripts/qdrant_operator.py add-documents --collection-name $(COLLECTION_NAME) --verbose + uv run python scripts/qdrant_operator.py search-documents --collection-name $(COLLECTION_NAME) --verbose --question "「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。" + +INDEX_NAME ?= docs_kabuto +.PHONY: create-elasticsearch-index +create-elasticsearch-index: ## create Elasticsearch index + uv run python scripts/elasticsearch_operator.py --help + uv run python scripts/elasticsearch_operator.py delete-index --index-name $(INDEX_NAME) --verbose + uv run python scripts/elasticsearch_operator.py create-index --index-name $(INDEX_NAME) --verbose + uv run python scripts/elasticsearch_operator.py add-documents --index-name $(INDEX_NAME) --verbose + uv run python scripts/elasticsearch_operator.py search-documents --index-name $(INDEX_NAME) --verbose --query "禅モード" + +# --- +# Project / Run agents +# --- +QUESTION ?= "KABUTOの起動時に、画面全体が紫色に点滅し、システムがフリーズします。KABUTO のマニュアルから、関連する情報を取得したり過去のシステムのトラブルシュート事例が蓄積されたデータベースから、関連する情報を取得して質問に答えてください" +.PHONY: run-chat-with-tools-agent +run-chat-with-tools-agent: ## run chat with tools agent + uv run python scripts/agent_operator.py run \ + --name chat_with_tools_agent \ + --question $(QUESTION) \ + --verbose + +.PHONY: run-image-classifier-agent +run-image-classifier-agent: ## run image classifier agent + uv run python scripts/agent_operator.py image-classifier-agent \ + --prompt "この画像の中身を 3 行で日本語で説明してください" \ + --file-paths "docs/images/fastapi.png,docs/images/streamlit.png" \ + --verbose + +.PHONY: run-issue-formatter-agent +run-issue-formatter-agent: ## run issue formatter agent + uv run python scripts/agent_operator.py run \ + --name issue_formatter_agent \ + --question "KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" \ + --verbose + +.PHONY: run-kabuto-helpdesk-agent +run-kabuto-helpdesk-agent: ## run kabuto helpdesk agent + uv run python scripts/agent_operator.py run \ + --name kabuto_helpdesk_agent \ + --question $(QUESTION) \ + --verbose + +.PHONY: run-news-summarizer-agent +run-news-summarizer-agent: ## run news summarizer agent + uv run python scripts/agent_operator.py news-summarizer-agent \ + --prompt "こちらの文章を 3 行で日本語で要約してください。" \ + --urls "https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md,https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md" \ + --verbose + +.PHONY: run-task-decomposer-agent +run-task-decomposer-agent: ## run task decomposer agent + uv run python scripts/agent_operator.py run \ + --name task_decomposer_agent \ + --question "KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" \ + --verbose diff --git a/docs/deployment.ja.md b/docs/deployment.ja.md deleted file mode 100644 index 036ebe6..0000000 --- a/docs/deployment.ja.md +++ /dev/null @@ -1,39 +0,0 @@ -# デプロイメント手順 - -## Azure リソース - -Azure リソースをこのプロジェクトにデプロイするには、提供された [Bicep テンプレート](https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep/tree/main/infra/scenarios/template-langgraph) を使用できます。このテンプレートは、LangGraph アプリケーションを実行するために必要なリソースをセットアップします。 - -アプリケーションを迅速にデプロイするために、[Deploy to Azure ボタン](https://learn.microsoft.com/azure/azure-resource-manager/templates/deploy-to-azure-button) が利用可能です。以下のボタンをクリックすることで、Azure ポータルから直接リソースをデプロイできます: - -[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fks6088ts-labs%2Fbaseline-environment-on-azure-bicep%2Frefs%2Fheads%2Fmain%2Finfra%2Fscenarios%2Ftemplate-langgraph%2Fazuredeploy.json) - -## Docker Hub - -Docker Hub に Docker イメージを公開するには、[アクセストークンを作成](https://app.docker.com/settings/personal-access-tokens/create)し、リポジトリ設定で以下のシークレットを設定する必要があります。 - -```shell -gh secret set DOCKERHUB_USERNAME --body $DOCKERHUB_USERNAME -gh secret set DOCKERHUB_TOKEN --body $DOCKERHUB_TOKEN -``` - -## Azure Static Web Apps - -```shell -RESOURCE_GROUP_NAME=your-resource-group-name -SWA_NAME=your-static-web-app-name - -# 静的アプリを作成する -az staticwebapp create --name $SWA_NAME --resource-group $RESOURCE_GROUP_NAME - -# APIキーを取得する -AZURE_STATIC_WEB_APPS_API_TOKEN=$(az staticwebapp secrets list --name $SWA_NAME --query "properties.apiKey" -o tsv) - -# APIキーをGitHubシークレットとして設定する -gh secret set AZURE_STATIC_WEB_APPS_API_TOKEN --body $AZURE_STATIC_WEB_APPS_API_TOKEN -``` - -詳細については、以下のリンクを参照してください: - -- [Azure Static Web App へのデプロイ](https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-azure-static-web-app) -- [静的 Web アプリの作成: `az staticwebapp create`](https://learn.microsoft.com/en-us/cli/azure/staticwebapp?view=azure-cli-latest#az-staticwebapp-create) diff --git a/docs/deployment.md b/docs/deployment.md index 26ccffd..2210bee 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -8,6 +8,70 @@ To quickly deploy the application, [Deploy to Azure button](https://learn.micros [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fks6088ts-labs%2Fbaseline-environment-on-azure-bicep%2Frefs%2Fheads%2Fmain%2Finfra%2Fscenarios%2Ftemplate-langgraph%2Fazuredeploy.json) +### Create index + +#### On Azure + +```shell +# Cosmos DB +make create-cosmosdb-index + +# Azure AI Search +make create-ai-search-index +``` + +#### On Docker + +```shell +rm -rf assets/ + +# Launch Docker containers +docker compose up -d --wait + +# Qdrant +make create-qdrant-index + +# Elasticsearch +make create-elasticsearch-index +``` + +### Agents + +#### Create agent graph in png format + +```shell +## Draw agent graph +mkdir -p generated +AGENT_NAMES=( + "chat_with_tools_agent" + "image_classifier_agent" + "issue_formatter_agent" + "kabuto_helpdesk_agent" + "news_summarizer_agent" + "task_decomposer_agent" +) +for AGENT_NAME in "${AGENT_NAMES[@]}"; do + uv run python scripts/agent_operator.py png --name "$AGENT_NAME" --verbose --output "generated/${AGENT_NAME}.png" & +done +wait +``` + +#### Run agents + +```shell +NAME_QUESTION_ARRAY=( + "chat_with_tools_agent:KABUTOの起動時に、画面全体が紫色に点滅し、システムがフリーズします。KABUTO のマニュアルから、関連する情報を取得したり過去のシステムのトラブルシュート事例が蓄積されたデータベースから、関連する情報を取得して質問に答えてください" + "issue_formatter_agent:KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" + "kabuto_helpdesk_agent:天狗のいたずら という現象について KABUTO のマニュアルから、関連する情報を取得したり過去のシステムのトラブルシュート事例が蓄積されたデータベースから、関連する情報を取得して質問に答えてください" + "task_decomposer_agent:KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" +) +for NAME_QUESTION in "${NAME_QUESTION_ARRAY[@]}"; do + IFS=':' read -r AGENT_NAME QUESTION <<< "$NAME_QUESTION" + echo "Running agent: $AGENT_NAME with question: $QUESTION" + uv run python scripts/agent_operator.py run --name "$AGENT_NAME" --verbose --question "$QUESTION" +done +``` + ### Docker Hub To publish the docker image to Docker Hub, you need to [create access token](https://app.docker.com/settings/personal-access-tokens/create) and set the following secrets in the repository settings. diff --git a/notebooks/chat_with_tools.ipynb b/notebooks/chat_with_tools.ipynb deleted file mode 100644 index 8dde646..0000000 --- a/notebooks/chat_with_tools.ipynb +++ /dev/null @@ -1,135 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "1f4d669f", - "metadata": {}, - "outputs": [], - "source": [ - "from dotenv import load_dotenv\n", - "\n", - "_ = load_dotenv(\n", - " override=True,\n", - " verbose=True,\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "1e7aea7c-3965-4c2c-b2d5-da9b01598d47", - "metadata": {}, - "outputs": [], - "source": [ - "from template_langgraph.agents.chat_with_tools_agent.agent import ChatWithToolsAgent\n", - "\n", - "# Create an instance of the agent\n", - "agent = ChatWithToolsAgent().create_graph()" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "21bd80ab", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--------------------\n", - "Event: {'chat_with_tools': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_nHBbATIpo8KOiVnP1BnQ3k9h', 'function': {'arguments': '{\"keywords\": \"鬼灯 KABUTO 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_YKc0ttX8N9HRMMB0pxhXcCgU', 'function': {'arguments': '{\"keywords\": \"鬼灯 KABUTO 停止 原因 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-11-20', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--dbe68e96-2aaa-49b8-a191-125d6ab3cb86-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 KABUTO 停止 原因 対策'}, 'id': 'call_nHBbATIpo8KOiVnP1BnQ3k9h', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 KABUTO 停止 原因 対策'}, 'id': 'call_YKc0ttX8N9HRMMB0pxhXcCgU', 'type': 'tool_call'}])]}}\n", - "--------------------\n", - "Event: {'tools': {'messages': [ToolMessage(content='\"[QdrantOutput(file_name=\\'./data/qa_kabuto.csv\\', content=\\'q: 特定のアプリケーション「鬼灯」を実行すると、KABUTOのファンが急に停止し、無音になります。 a: 「鬼灯」は、その特殊な演算処理において、KABUTOの冷却システム「風魔の術」を一時的に停止させ、内部エネルギーの流れを最適化する機能を持っています。これは異常ではありません。ただし、無音状態が15分以上続く場合は、過熱の可能性があるため、アプリケーションを強制終了し、KABUTO本体の電源を一度切ってから再起動してください。\\'), QdrantOutput(file_name=\\'./data/qa_kabuto.csv\\', content=\\'q: KABUTOの電源ランプが、赤と青の交互点滅ではなく、緑色で点滅しています。 a: 通常、電源ランプは赤(待機中)と青(稼働中)の点滅を繰り返します。緑色の点滅は、KABUTOが「禅モード」に入っており、パフォーマンスを最小限に抑え、バックグラウンドでシステム自己修復を行っている状態を示します。この状態では、ユーザー操作はほとんど受け付けられません。このモードから強制的に脱出するには、KABUTO本体の「龍玉」ボタンを5秒以上長押ししてください。\\'), QdrantOutput(file_name=\\'./data/qa_kabuto.csv\\', content=\\'q: KABUTOの画面の隅に、時々「狐火」のような光の点が、不規則に現れては消えます。 a: 「狐火」は、KABUTOの演算コア「稲荷」が、膨大な量のタスクを処理しきれずに、一部の計算結果が視覚的なノイズとして現れている現象です。これは、システム負荷が高いことを示しています。この現象が頻繁に発生する場合は、バックグラウンドで動作している不要なアプリケーションを終了させるか、KABUTOを再起動してください。\\')]\"', name='search_qdrant', id='ceeb6a9a-f0e9-4d18-8645-40146eda7705', tool_call_id='call_nHBbATIpo8KOiVnP1BnQ3k9h'), ToolMessage(content='\"[ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'docs_kabuto.md 2025-08-01\\\\\\\\n2 / 3\\\\\\\\nた場合、「虚無」エラーが表⽰され、ログインは拒否される。これは疲労やストレスによる精神状態の変化が原因で\\\\\\\\nある可能性があり、深呼吸による精神状態の安定化が解決策となる。\\\\\\\\n3.3 ネットワーク・通信\\\\\\\\nネットワークモジュール「隠れ蓑」は、外部からの不必要なスキャンを回避するため、デフォルトでステルスモード\\\\\\\\nで動作する。これにより、ネットワーク上の他のデバイスから認識されない状態となる。 KABUTO をネットワーク上\\\\\\\\nで可視化させるには、ネットワーク設定画⾯から「忍びの道」オプションを有効にする必要がある。\\\\\\\\n3.4 演算コア\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\\\\\n4.2 ⼊⼒・ AI アシスタント\\\\\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\\\\\n4.3 スクリーンショット機能\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\\\\\n第 3 章 ソフトウェア・オペレーション\\\\\\\\n3.1 起動プロトコル\\\\\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが\\')]\"', name='search_elasticsearch', id='071645ce-1c0c-48b7-80e2-d583e1dc2ba4', tool_call_id='call_YKc0ttX8N9HRMMB0pxhXcCgU')]}}\n", - "--------------------\n", - "Event: {'chat_with_tools': {'messages': [AIMessage(content='「鬼灯」を実行するとKABUTOが急に停止する問題について、以下の情報を基に原因と対策を説明します。\\n\\n### 原因\\n1. **「鬼灯」の特性**:\\n - 「鬼灯」はKABUTOの冷却システム「風魔の術」を一時的に停止させ、内部エネルギーの流れを最適化する機能を持っています。これは異常ではなく、設計上の仕様です。\\n - ただし、この状態が15分以上続く場合、過熱の可能性があり、システムが停止することがあります。\\n\\n2. **過熱のリスク**:\\n - 冷却システムが停止している間に、内部エネルギーの流れが適切に管理されない場合、過熱が発生し、システムが安全のために停止することがあります。\\n\\n### 対策\\n1. **短時間での操作**:\\n - 「鬼灯」を実行する際は、無音状態が15分以上続かないように注意してください。\\n\\n2. **強制終了と再起動**:\\n - 無音状態が15分以上続いた場合は、以下の手順を実行してください:\\n - アプリケーションを強制終了する。\\n - KABUTO本体の電源を一度切り、再起動する。\\n\\n3. **冷却システムの確認**:\\n - 冷却システム「風魔の術」が正常に動作しているか確認してください。\\n - 必要に応じて、冷却システムのメンテナンスを行うことを推奨します。\\n\\n4. **システムログの確認**:\\n - システムログを確認し、過熱やエラーの兆候がないかチェックしてください。\\n\\nこれらの対策を講じることで、「鬼灯」を安全に使用できるようになります。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-11-20', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--d55f49c2-e903-4caf-af0c-70ef835cebc4-0')]}}\n" - ] - } - ], - "source": [ - "question = \"「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。\"\n", - "\n", - "# Stream the agent's response to the question\n", - "for event in agent.stream(\n", - " input={\n", - " \"messages\": [\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": question,\n", - " }\n", - " ],\n", - " }\n", - "):\n", - " print(\"-\" * 20)\n", - " print(f\"Event: {event}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "53219c94", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--------------------\n", - "Event: {'chat_with_tools': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_arqSQa1h6zPE6AXrGmTeWTg2', 'function': {'arguments': '{\"requirements\":\"京都から東京への旅行プランを作成してください。\"}', 'name': 'run_dify_workflow'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-11-20', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--4087394a-1b1c-4ace-813c-5f0fc8a2b140-0', tool_calls=[{'name': 'run_dify_workflow', 'args': {'requirements': '京都から東京への旅行プランを作成してください。'}, 'id': 'call_arqSQa1h6zPE6AXrGmTeWTg2', 'type': 'tool_call'}])]}}\n", - "--------------------\n", - "Event: {'tools': {'messages': [ToolMessage(content='\"response={\\'task_id\\': \\'feb2d050-5476-47b8-888b-ea5fa4f24fd9\\', \\'workflow_run_id\\': \\'9aacd8c9-d0a1-4614-97ba-b0bfc90e682c\\', \\'data\\': {\\'id\\': \\'9aacd8c9-d0a1-4614-97ba-b0bfc90e682c\\', \\'workflow_id\\': \\'2d97261d-6f0e-4c1e-9223-993a96e676b8\\', \\'status\\': \\'succeeded\\', \\'outputs\\': {\\'text\\': \\'ほな、京都から東京への旅行プラン作るで!関西人らしく楽しくいこか!\\\\\\\\n\\\\\\\\n---\\\\\\\\n\\\\\\\\n### 1日目:京都出発! \\\\\\\\n**朝** \\\\\\\\n・JR京都駅から新幹線「のぞみ」に乗って東京へ。約2時間半で着くさかい、朝早めに出発するのがええで! \\\\\\\\n・新幹線の中では駅弁でも食べて旅気分を盛り上げたらええやん!「鯖寿司」なんか京都らしくてええな~。 \\\\\\\\n\\\\\\\\n**昼** \\\\\\\\n・東京駅に到着!駅構内でちょっと寄り道して、「東京ばな奈」でも買うてみて。お土産にもええしな! \\\\\\\\n・その後、浅草へ向かい「浅草寺」でお参り。仲見世通りで食べ歩きするのも楽しいで~。天ぷらまんじゅうとかええで! \\\\\\\\n\\\\\\\\n**夕方** \\\\\\\\n・スカイツリーに行って展望台から東京の街並みを眺めてみたらええで!夜はライトアップがキレイやし、ええ写真撮れるで~。 \\\\\\\\n\\\\\\\\n**夜** \\\\\\\\n・東京の居酒屋で関東ならではの料理を食べてみて。「もんじゃ焼き」とか関西人にはちょっと珍しいかもしれんけど、美味しいで! \\\\\\\\n\\\\\\\\n---\\\\\\\\n\\\\\\\\n### 2日目:東京観光満喫! \\\\\\\\n**朝** \\\\\\\\n・ホテルで朝ごはん食べた後、原宿の「竹下通り」に行ってみようか!若者文化がぎょうさん詰まっとるし、インスタ映えスポットも多いで~。 \\\\\\\\n\\\\\\\\n**昼** \\\\\\\\n・渋谷で「スクランブル交差点」を体験してみて!人の多さにビックリするけど楽しいで~。ランチは渋谷で流行りのおしゃれカフェでパンケーキとか食べたらええんちゃう? \\\\\\\\n\\\\\\\\n**午後** \\\\\\\\n・午後は新宿の「都庁展望台」に行ってみたらどうや?無料やし、東京の景色を高いところから眺めれるで! \\\\\\\\n・その後は「新宿御苑」でちょっとのんびり散歩するのもオススメやで~。 \\\\\\\\n\\\\\\\\n**夜** \\\\\\\\n・最後の夜やし、東京のナイトスポットで楽しもう!六本木とかおしゃれなお店も多いし、夜景もキレイやで! \\\\\\\\n\\\\\\\\n---\\\\\\\\n\\\\\\\\n### 3日目:東京から京都へ帰る \\\\\\\\n**朝** \\\\\\\\n・朝はゆっくりして、新幹線に乗る前に東京駅でお土産チェック!「雷おこし」とか「人形焼き」もええし、綺麗な和菓子もあるで~。 \\\\\\\\n\\\\\\\\n**昼** \\\\\\\\n・新幹線で京都に帰る途中、駅弁をまた楽しんだらええやん!東京の味を最後まで堪能しようや~。 \\\\\\\\n\\\\\\\\n**夕方** \\\\\\\\n・京都に無事到着!おかえりやで~!楽しい旅行になったんちゃう? \\\\\\\\n\\\\\\\\n---\\\\\\\\n\\\\\\\\nこんな感じでどうや?無理なく楽しめるプランやと思うで!気ぃつけて行ってきーや~!\\'}, \\'error\\': \\'\\', \\'elapsed_time\\': 9.116945, \\'total_tokens\\': 837, \\'total_steps\\': 3, \\'created_at\\': 1754360073, \\'finished_at\\': 1754360082}}\"', name='run_dify_workflow', id='f9b76e2f-4403-4759-9ae6-10c51a9773ed', tool_call_id='call_arqSQa1h6zPE6AXrGmTeWTg2')]}}\n", - "--------------------\n", - "Event: {'chat_with_tools': {'messages': [AIMessage(content='以下は京都から東京への旅行プランです。関西人らしい楽しい旅をお楽しみください!\\n\\n---\\n\\n### 1日目:京都出発!\\n**朝** \\n- JR京都駅から新幹線「のぞみ」に乗って東京へ。約2時間半で到着します。朝早めに出発するのがおすすめです! \\n- 新幹線の中では駅弁を楽しみましょう。「鯖寿司」など京都らしいものが良いですね。\\n\\n**昼** \\n- 東京駅に到着!駅構内で「東京ばな奈」を購入してみてください。お土産にもぴったりです。 \\n- 浅草へ向かい「浅草寺」でお参り。仲見世通りで食べ歩きも楽しいですよ。天ぷらまんじゅうなどがおすすめです。\\n\\n**夕方** \\n- スカイツリーに行き、展望台から東京の街並みを眺めましょう。夜のライトアップも美しく、写真映えします。\\n\\n**夜** \\n- 東京の居酒屋で関東ならではの料理を楽しみましょう。「もんじゃ焼き」など関西人には珍しい料理も美味しいですよ!\\n\\n---\\n\\n### 2日目:東京観光満喫!\\n**朝** \\n- ホテルで朝食を済ませた後、原宿の「竹下通り」に行きましょう。若者文化が詰まっていて、インスタ映えスポットも多いです。\\n\\n**昼** \\n- 渋谷で「スクランブル交差点」を体験!人の多さに驚きつつ楽しめます。ランチは渋谷の流行りのおしゃれカフェでパンケーキなどをどうぞ。\\n\\n**午後** \\n- 新宿の「都庁展望台」に行きましょう。無料で東京の景色を高いところから眺められます。 \\n- その後は「新宿御苑」でのんびり散歩するのもおすすめです。\\n\\n**夜** \\n- 最後の夜は東京のナイトスポットで楽しみましょう。六本木などおしゃれなお店が多く、夜景もきれいです。\\n\\n---\\n\\n### 3日目:東京から京都へ帰る\\n**朝** \\n- 朝はゆっくりして、新幹線に乗る前に東京駅でお土産チェック!「雷おこし」や「人形焼き」、美しい和菓子などがおすすめです。\\n\\n**昼** \\n- 新幹線で京都に帰る途中、駅弁を楽しみましょう。東京の味を最後まで堪能してください。\\n\\n**夕方** \\n- 京都に無事到着!楽しい旅行になったことでしょう。\\n\\n---\\n\\n無理なく楽しめるプランです。気をつけて行ってきてくださいね!', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-11-20', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--c05f75f8-5450-43e6-9305-afc26291238e-0')]}}\n" - ] - } - ], - "source": [ - "question = \"Dify のワークフローで京都から東京への旅行プランを作成してください。\"\n", - "\n", - "# Stream the agent's response to the question\n", - "for event in agent.stream(\n", - " input={\n", - " \"messages\": [\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": question,\n", - " }\n", - " ],\n", - " }\n", - "):\n", - " print(\"-\" * 20)\n", - " print(f\"Event: {event}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d38858e3", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.8" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/notebooks/chat_with_tools_agent.ipynb b/notebooks/chat_with_tools_agent.ipynb new file mode 100644 index 0000000..e644139 --- /dev/null +++ b/notebooks/chat_with_tools_agent.ipynb @@ -0,0 +1,175 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "1f4d669f", + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import load_dotenv\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1e7aea7c-3965-4c2c-b2d5-da9b01598d47", + "metadata": {}, + "outputs": [], + "source": [ + "from template_langgraph.agents.chat_with_tools_agent.agent import ChatWithToolsAgent\n", + "\n", + "# Create an instance of the agent\n", + "agent = ChatWithToolsAgent().create_graph()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "21bd80ab", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:29:17,902 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='8189c1d8-316e-4643-860a-aa4b508fbe77')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'chat_with_tools': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_RSy3cfaGhAVHjA1MyOpWp6Su', 'function': {'arguments': '{\"keywords\": \"鬼灯停止原因\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_mxsjnHG0QQsGOD4YHa4hTeLO', 'function': {'arguments': '{\"keywords\": \"鬼灯停止対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--0444b956-e16f-42fc-bd23-28b2c4950ad8-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯停止原因'}, 'id': 'call_RSy3cfaGhAVHjA1MyOpWp6Su', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯停止対策'}, 'id': 'call_mxsjnHG0QQsGOD4YHa4hTeLO', 'type': 'tool_call'}])]}}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:29:21,890 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='8189c1d8-316e-4643-860a-aa4b508fbe77'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_RSy3cfaGhAVHjA1MyOpWp6Su', 'function': {'arguments': '{\"keywords\": \"鬼灯停止原因\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_mxsjnHG0QQsGOD4YHa4hTeLO', 'function': {'arguments': '{\"keywords\": \"鬼灯停止対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--0444b956-e16f-42fc-bd23-28b2c4950ad8-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯停止原因'}, 'id': 'call_RSy3cfaGhAVHjA1MyOpWp6Su', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯停止対策'}, 'id': 'call_mxsjnHG0QQsGOD4YHa4hTeLO', 'type': 'tool_call'}]), ToolMessage(content='\"[QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。\\')]\"', name='search_qdrant', id='221830b2-e3f6-44fc-9b21-aa91da187758', tool_call_id='call_RSy3cfaGhAVHjA1MyOpWp6Su'), ToolMessage(content='\"[ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\\\\\n第 3 章 ソフトウェア・オペレーション\\\\\\\\n3.1 起動プロトコル\\\\\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\\\\\n4.2 ⼊⼒・ AI アシスタント\\\\\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\\\\\n4.3 スクリーンショット機能\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\\\\\n4.5 システム・パーソナライゼーション\\\\\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\\\\\n第 5 章 バグ・特殊現象\\')]\"', name='search_elasticsearch', id='1e42e013-4b18-4a96-a54a-34efdba52c14', tool_call_id='call_mxsjnHG0QQsGOD4YHa4hTeLO')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'tools': {'messages': [ToolMessage(content='\"[QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。\\')]\"', name='search_qdrant', id='221830b2-e3f6-44fc-9b21-aa91da187758', tool_call_id='call_RSy3cfaGhAVHjA1MyOpWp6Su'), ToolMessage(content='\"[ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\\\\\n第 3 章 ソフトウェア・オペレーション\\\\\\\\n3.1 起動プロトコル\\\\\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\\\\\n4.2 ⼊⼒・ AI アシスタント\\\\\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\\\\\n4.3 スクリーンショット機能\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\\\\\n4.5 システム・パーソナライゼーション\\\\\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\\\\\n第 5 章 バグ・特殊現象\\')]\"', name='search_elasticsearch', id='1e42e013-4b18-4a96-a54a-34efdba52c14', tool_call_id='call_mxsjnHG0QQsGOD4YHa4hTeLO')]}}\n", + "--------------------\n", + "Event: {'chat_with_tools': {'messages': [AIMessage(content='「鬼灯」を実行するとKABUTOが停止する原因として、以下のトラブル事例が報告されています:\\n\\n1. **過熱警告が表示され強制終了した**: 鬼灯を実行中に過熱を検知し、安全措置としてシステムが強制的に終了した可能性があります。(エラーコード: KABUTO-0127)\\n\\n2. **無音状態が続き過熱が不安**: 鬼灯の実行中にシステムが無音状態になり、過熱が発生する可能性がある。(エラーコード: KABUTO-0116)\\n\\n3. **ファンが停止し無音のまま**: アプリ鬼灯を起動した際にシステムの冷却ファンが停止し、無音状態が続いた不具合があります。(エラーコード: KABUTO-0102)\\n\\n対策としては以下の方法が提案されています:\\n\\n- **アプリケーションの強制終了とシステムの再起動の推奨**: 15分以上無音状態が続いた場合は、過熱の可能性があるため、アプリケーションの強制終了およびシステムの再起動を行うことが推奨されています。\\n\\n- **システム設定の調整**: 「読み優先モード」を一時的に無効化することで、この問題が発生する頻度を低減できる可能性があります。\\n\\n具体的な手順については、KABUTOのシステムマニュアルを参照しながら行うことをお勧めします。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, id='run--8d04ccd4-6865-4787-8920-736c13905695-0')]}}\n" + ] + } + ], + "source": [ + "question = \"「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。\"\n", + "\n", + "# Stream the agent's response to the question\n", + "for event in agent.stream(\n", + " input={\n", + " \"messages\": [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": question,\n", + " }\n", + " ],\n", + " }\n", + "):\n", + " print(\"-\" * 20)\n", + " print(f\"Event: {event}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "53219c94", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:29:25,905 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='Dify のワークフローで京都から東京への旅行プランを作成してください。', additional_kwargs={}, response_metadata={}, id='385a1bc9-c62d-46a8-86b9-ff9b09a811e2')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'chat_with_tools': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_PwU0rzjLmbNwt30t6grzKCzx', 'function': {'arguments': '{\"requirements\":\"京都から東京への旅行プランを作成してください。日本語でお願いします\"}', 'name': 'run_dify_workflow'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--c6c1fd8c-7319-4b04-8173-c29bfd0dd889-0', tool_calls=[{'name': 'run_dify_workflow', 'args': {'requirements': '京都から東京への旅行プランを作成してください。日本語でお願いします'}, 'id': 'call_PwU0rzjLmbNwt30t6grzKCzx', 'type': 'tool_call'}])]}}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:29:38,490 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='Dify のワークフローで京都から東京への旅行プランを作成してください。', additional_kwargs={}, response_metadata={}, id='385a1bc9-c62d-46a8-86b9-ff9b09a811e2'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_PwU0rzjLmbNwt30t6grzKCzx', 'function': {'arguments': '{\"requirements\":\"京都から東京への旅行プランを作成してください。日本語でお願いします\"}', 'name': 'run_dify_workflow'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--c6c1fd8c-7319-4b04-8173-c29bfd0dd889-0', tool_calls=[{'name': 'run_dify_workflow', 'args': {'requirements': '京都から東京への旅行プランを作成してください。日本語でお願いします'}, 'id': 'call_PwU0rzjLmbNwt30t6grzKCzx', 'type': 'tool_call'}]), ToolMessage(content='\"response={\\'task_id\\': \\'d419751d-edf1-44cd-8527-b1dfbef9a72a\\', \\'workflow_run_id\\': \\'98411725-0e23-4178-9653-5531b523eee6\\', \\'data\\': {\\'id\\': \\'98411725-0e23-4178-9653-5531b523eee6\\', \\'workflow_id\\': \\'2d97261d-6f0e-4c1e-9223-993a96e676b8\\', \\'status\\': \\'succeeded\\', \\'outputs\\': {\\'text\\': \\'ほいほい!ほんなら京都から東京への旅行プラン、関西弁で作ったるわな!\\\\\\\\n\\\\\\\\n### 1日目: 京都を出発!\\\\\\\\n- **朝** \\\\\\\\nせやな、まずは京都駅から新幹線で出発や!「のぞみ」に乗ったら東京まで約2時間半やし、楽ちんやで~。新幹線の中でお弁当でも食べながら景色を楽しむのもええな。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\n東京駅に到着したら、まずはランチや!東京駅近くにはおしゃれなカフェやレストランがいっぱいあるから、そこで腹ごしらえや。もしくは東京駅構内で売ってる駅弁を食べるのもええな。\\\\\\\\n\\\\\\\\n- **午後** \\\\\\\\n東京観光スタートや!初日は定番スポット巡りがおすすめやで。 \\\\\\\\n① **浅草寺** \\\\\\\\nスカイツリーも近いし、仲見世通りでお土産買ったり食べ歩きしたりするのも楽しいで~。 \\\\\\\\n② **上野公園** \\\\\\\\n博物館や動物園を見て回るんもええわ。秋なら紅葉がきれいやし、春なら桜も最高や! \\\\\\\\n\\\\\\\\n- **夜** \\\\\\\\n夜になったら東京タワーのライトアップを見に行くんもロマンチックやな。お腹が減ったら六本木や新宿で居酒屋巡りしてみるのもええで!\\\\\\\\n\\\\\\\\n### 2日目: オシャレな東京を満喫!\\\\\\\\n- **朝** \\\\\\\\nせっかく東京に来たんやから、モーニングはちょっとオシャレなカフェでいただこう。表参道とか代官山辺りはカフェの宝庫やで~。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\n午後からはショッピング!原宿の竹下通りで流行りのアイテム探したり、渋谷でギャル文化を体感したりするのもおもろいで。あと銀座でちょっと贅沢してブランド店巡りするんもええな。\\\\\\\\n\\\\\\\\n- **夜** \\\\\\\\n夕方からはお台場に行ってみるのもおすすめや。夜景がきれいで、観覧車乗ったり、海の近くを散歩したりしてまったり過ごせるで。お台場のレストランでディナー食べるんもええやん!\\\\\\\\n\\\\\\\\n### 3日目: 東京をエンジョイして帰阪\\\\\\\\n- **朝** \\\\\\\\n旅行の最終日はちょっとリラックスして、皇居周辺を散歩するんもええな。自然が多いし、東京の都会感と昔ながらの雰囲気がええ感じで混ざっとるで。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\nランチは東京駅構内で美味しいラーメン食べたり、蕎麦食べたりして、最後の東京グルメを満喫しとこな!\\\\\\\\n\\\\\\\\n- **午後** \\\\\\\\n新幹線で京都へ帰ろか~。帰りの新幹線では東京土産をつまみながら、旅行の思い出話で盛り上がるんが最高やで。\\\\\\\\n\\\\\\\\nほんな感じで、ええ旅になること間違いなしや!楽しんできてや~!\\'}, \\'error\\': \\'\\', \\'elapsed_time\\': 10.881441, \\'total_tokens\\': 831, \\'total_steps\\': 3, \\'created_at\\': 1755138567, \\'finished_at\\': 1755138578}}\"', name='run_dify_workflow', id='a18595f3-480a-4938-a76b-b012c3cb3f3a', tool_call_id='call_PwU0rzjLmbNwt30t6grzKCzx')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'tools': {'messages': [ToolMessage(content='\"response={\\'task_id\\': \\'d419751d-edf1-44cd-8527-b1dfbef9a72a\\', \\'workflow_run_id\\': \\'98411725-0e23-4178-9653-5531b523eee6\\', \\'data\\': {\\'id\\': \\'98411725-0e23-4178-9653-5531b523eee6\\', \\'workflow_id\\': \\'2d97261d-6f0e-4c1e-9223-993a96e676b8\\', \\'status\\': \\'succeeded\\', \\'outputs\\': {\\'text\\': \\'ほいほい!ほんなら京都から東京への旅行プラン、関西弁で作ったるわな!\\\\\\\\n\\\\\\\\n### 1日目: 京都を出発!\\\\\\\\n- **朝** \\\\\\\\nせやな、まずは京都駅から新幹線で出発や!「のぞみ」に乗ったら東京まで約2時間半やし、楽ちんやで~。新幹線の中でお弁当でも食べながら景色を楽しむのもええな。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\n東京駅に到着したら、まずはランチや!東京駅近くにはおしゃれなカフェやレストランがいっぱいあるから、そこで腹ごしらえや。もしくは東京駅構内で売ってる駅弁を食べるのもええな。\\\\\\\\n\\\\\\\\n- **午後** \\\\\\\\n東京観光スタートや!初日は定番スポット巡りがおすすめやで。 \\\\\\\\n① **浅草寺** \\\\\\\\nスカイツリーも近いし、仲見世通りでお土産買ったり食べ歩きしたりするのも楽しいで~。 \\\\\\\\n② **上野公園** \\\\\\\\n博物館や動物園を見て回るんもええわ。秋なら紅葉がきれいやし、春なら桜も最高や! \\\\\\\\n\\\\\\\\n- **夜** \\\\\\\\n夜になったら東京タワーのライトアップを見に行くんもロマンチックやな。お腹が減ったら六本木や新宿で居酒屋巡りしてみるのもええで!\\\\\\\\n\\\\\\\\n### 2日目: オシャレな東京を満喫!\\\\\\\\n- **朝** \\\\\\\\nせっかく東京に来たんやから、モーニングはちょっとオシャレなカフェでいただこう。表参道とか代官山辺りはカフェの宝庫やで~。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\n午後からはショッピング!原宿の竹下通りで流行りのアイテム探したり、渋谷でギャル文化を体感したりするのもおもろいで。あと銀座でちょっと贅沢してブランド店巡りするんもええな。\\\\\\\\n\\\\\\\\n- **夜** \\\\\\\\n夕方からはお台場に行ってみるのもおすすめや。夜景がきれいで、観覧車乗ったり、海の近くを散歩したりしてまったり過ごせるで。お台場のレストランでディナー食べるんもええやん!\\\\\\\\n\\\\\\\\n### 3日目: 東京をエンジョイして帰阪\\\\\\\\n- **朝** \\\\\\\\n旅行の最終日はちょっとリラックスして、皇居周辺を散歩するんもええな。自然が多いし、東京の都会感と昔ながらの雰囲気がええ感じで混ざっとるで。\\\\\\\\n\\\\\\\\n- **昼** \\\\\\\\nランチは東京駅構内で美味しいラーメン食べたり、蕎麦食べたりして、最後の東京グルメを満喫しとこな!\\\\\\\\n\\\\\\\\n- **午後** \\\\\\\\n新幹線で京都へ帰ろか~。帰りの新幹線では東京土産をつまみながら、旅行の思い出話で盛り上がるんが最高やで。\\\\\\\\n\\\\\\\\nほんな感じで、ええ旅になること間違いなしや!楽しんできてや~!\\'}, \\'error\\': \\'\\', \\'elapsed_time\\': 10.881441, \\'total_tokens\\': 831, \\'total_steps\\': 3, \\'created_at\\': 1755138567, \\'finished_at\\': 1755138578}}\"', name='run_dify_workflow', id='a18595f3-480a-4938-a76b-b012c3cb3f3a', tool_call_id='call_PwU0rzjLmbNwt30t6grzKCzx')]}}\n", + "--------------------\n", + "Event: {'chat_with_tools': {'messages': [AIMessage(content='Difyワークフローによって作成された京都から東京への旅行プランは以下の通りです:\\n\\n### 1日目: 京都を出発!\\n- **朝** \\n京都駅から新幹線「のぞみ」で出発。約2時間半で東京に到着します。新幹線内でお弁当を食べながら景色を楽しむのも良いですね。\\n\\n- **昼** \\n東京駅に到着したらランチタイムです。駅近くのカフェやレストランで腹ごしらえ、または駅弁を楽しむこともできます。\\n\\n- **午後** \\n東京観光スタート!定番スポット巡りがおすすめです。\\n - **浅草寺** \\n仲見世通りでお土産を買ったり食べ歩きを楽しみましょう。\\n - **上野公園** \\n博物館や動物園を見学するのも良いです。秋なら紅葉、春なら桜が最高です。\\n\\n- **夜** \\n東京タワーのライトアップを見に行くこともロマンチックです。居酒屋巡りも楽しいでしょう。\\n\\n### 2日目: オシャレな東京を満喫!\\n- **朝** \\nオシャレなカフェでモーニングを。表参道や代官山がおすすめです。\\n\\n- **昼** \\nショッピングタイム!原宿の竹下通りで流行アイテムを探したり、渋谷のギャル文化を体感したり、銀座で贅沢なブランド店巡りも良いですね。\\n\\n- **夜** \\nお台場で夜景を楽しみながら観覧車に乗ったり、海の近くを散歩したりしてリラックスできます。お台場のレストランでディナーも。\\n\\n### 3日目: 東京をエンジョイして帰阪\\n- **朝** \\n皇居周辺を散歩し、都会と自然が交わる雰囲気を楽しみましょう。\\n\\n- **昼** \\n東京駅で美味しいラーメンや蕎麦を楽しみ、最後の東京グルメを満喫。\\n\\n- **午後** \\n帰りの新幹線では東京土産をつまみながら旅行の思い出を語り合いましょう。\\n\\nこのプランで素晴らしい旅になること間違いなしです!楽しんでくださいね。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--ea195188-ff2e-4336-9ba6-bc8b582e9c52-0')]}}\n" + ] + } + ], + "source": [ + "question = \"Dify のワークフローで京都から東京への旅行プランを作成してください。\"\n", + "\n", + "# Stream the agent's response to the question\n", + "for event in agent.stream(\n", + " input={\n", + " \"messages\": [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": question,\n", + " }\n", + " ],\n", + " }\n", + "):\n", + " print(\"-\" * 20)\n", + " print(f\"Event: {event}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d38858e3", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/image_classifier_agent.ipynb b/notebooks/image_classifier_agent.ipynb new file mode 100644 index 0000000..d2f00f5 --- /dev/null +++ b/notebooks/image_classifier_agent.ipynb @@ -0,0 +1,180 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "0e39a91d", + "metadata": {}, + "outputs": [], + "source": [ + "import logging\n", + "\n", + "from dotenv import load_dotenv\n", + "\n", + "from template_langgraph.loggers import get_logger\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")\n", + "\n", + "logger = get_logger(__name__)\n", + "logger.setLevel(logging.DEBUG)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1e620cca", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:37:25,079 [ INFO] Initializing state: input=AgentInputState(prompt='この画像の中身を 3 行で日本語で説明してください', id='e5d93fde-3176-48dd-b361-359a1cc4b8ea', file_paths=['../docs/images/fastapi.png', '../docs/images/streamlit.png']) results=[] (agent.py:73)\n", + "2025-08-14 11:37:25,079 [ INFO] Running subtasks with state: input=AgentInputState(prompt='この画像の中身を 3 行で日本語で説明してください', id='e5d93fde-3176-48dd-b361-359a1cc4b8ea', file_paths=['../docs/images/fastapi.png', '../docs/images/streamlit.png']) results=[] (agent.py:79)\n", + "2025-08-14 11:37:25,079 [ INFO] -------------------- (1383596555.py:27)\n", + "2025-08-14 11:37:25,080 [ INFO] Event: {'initialize': {'input': AgentInputState(prompt='この画像の中身を 3 行で日本語で説明してください', id='e5d93fde-3176-48dd-b361-359a1cc4b8ea', file_paths=['../docs/images/fastapi.png', '../docs/images/streamlit.png']), 'results': []}} (1383596555.py:28)\n", + "2025-08-14 11:37:25,080 [ INFO] Classify file: ../docs/images/streamlit.png (agent.py:92)\n", + "2025-08-14 11:37:25,080 [ INFO] Classify file: ../docs/images/fastapi.png (agent.py:92)\n", + "2025-08-14 11:37:25,080 [ INFO] Loading file: ../docs/images/streamlit.png (agent.py:95)\n", + "2025-08-14 11:37:25,081 [ INFO] Loading file: ../docs/images/fastapi.png (agent.py:95)\n", + "2025-08-14 11:37:25,084 [ INFO] Classifying file: ../docs/images/streamlit.png (agent.py:98)\n", + "2025-08-14 11:37:25,084 [ INFO] Classifying image with LLM: この画像の中身を 3 行で日本語で説明してください (classifiers.py:64)\n", + "2025-08-14 11:37:25,087 [ INFO] Classifying file: ../docs/images/fastapi.png (agent.py:98)\n", + "2025-08-14 11:37:25,087 [ INFO] Classifying image with LLM: この画像の中身を 3 行で日本語で説明してください (classifiers.py:64)\n", + "2025-08-14 11:37:35,738 [ INFO] Classification result: {\n", + " \"title\": \"KABUTOシステム起動時の問題\",\n", + " \"summary\": \"KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。\",\n", + " \"labels\": [\n", + " \"KABUTO\",\n", + " \"システムフリーズ\",\n", + " \"初期化失敗\",\n", + " \"トラブルシューティング\",\n", + " \"周辺機器解除\"\n", + " ],\n", + " \"reliability\": 0.94\n", + "} (agent.py:105)\n", + "2025-08-14 11:37:35,740 [ INFO] -------------------- (1383596555.py:27)\n", + "2025-08-14 11:37:35,740 [ INFO] Event: {'classify_image': {'results': [Results(file_path='../docs/images/fastapi.png', result=Result(title='KABUTOシステム起動時の問題', summary='KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。', labels=['KABUTO', 'システムフリーズ', '初期化失敗', 'トラブルシューティング', '周辺機器解除'], reliability=0.94))]}} (1383596555.py:28)\n", + "2025-08-14 11:37:37,267 [ INFO] Classification result: {\n", + " \"title\": \"ツールエージェント画面\",\n", + " \"summary\": \"この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。\",\n", + " \"labels\": [\n", + " \"AI チャット\",\n", + " \"ツール選択\",\n", + " \"インターフェース\"\n", + " ],\n", + " \"reliability\": 0.9\n", + "} (agent.py:105)\n", + "2025-08-14 11:37:37,268 [ INFO] -------------------- (1383596555.py:27)\n", + "2025-08-14 11:37:37,268 [ INFO] Event: {'classify_image': {'results': [Results(file_path='../docs/images/streamlit.png', result=Result(title='ツールエージェント画面', summary='この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。', labels=['AI チャット', 'ツール選択', 'インターフェース'], reliability=0.9))]}} (1383596555.py:28)\n", + "2025-08-14 11:37:37,270 [ INFO] Sending notifications with state: input=AgentInputState(prompt='この画像の中身を 3 行で日本語で説明してください', id='e5d93fde-3176-48dd-b361-359a1cc4b8ea', file_paths=['../docs/images/fastapi.png', '../docs/images/streamlit.png']) results=[Results(file_path='../docs/images/fastapi.png', result=Result(title='KABUTOシステム起動時の問題', summary='KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。', labels=['KABUTO', 'システムフリーズ', '初期化失敗', 'トラブルシューティング', '周辺機器解除'], reliability=0.94)), Results(file_path='../docs/images/streamlit.png', result=Result(title='ツールエージェント画面', summary='この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。', labels=['AI チャット', 'ツール選択', 'インターフェース'], reliability=0.9))] (agent.py:119)\n", + "2025-08-14 11:37:37,270 [ INFO] Notification sent for request e5d93fde-3176-48dd-b361-359a1cc4b8ea: {0: {'file_path': '../docs/images/fastapi.png', 'result': {'title': 'KABUTOシステム起動時の問題', 'summary': 'KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。', 'labels': ['KABUTO', 'システムフリーズ', '初期化失敗', 'トラブルシューティング', '周辺機器解除'], 'reliability': 0.94}}, 1: {'file_path': '../docs/images/streamlit.png', 'result': {'title': 'ツールエージェント画面', 'summary': 'この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。', 'labels': ['AI チャット', 'ツール選択', 'インターフェース'], 'reliability': 0.9}}} (agent.py:32)\n", + "2025-08-14 11:37:37,271 [ INFO] -------------------- (1383596555.py:27)\n", + "2025-08-14 11:37:37,272 [ INFO] Event: {'notify': {'input': AgentInputState(prompt='この画像の中身を 3 行で日本語で説明してください', id='e5d93fde-3176-48dd-b361-359a1cc4b8ea', file_paths=['../docs/images/fastapi.png', '../docs/images/streamlit.png']), 'results': [Results(file_path='../docs/images/fastapi.png', result=Result(title='KABUTOシステム起動時の問題', summary='KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。', labels=['KABUTO', 'システムフリーズ', '初期化失敗', 'トラブルシューティング', '周辺機器解除'], reliability=0.94)), Results(file_path='../docs/images/streamlit.png', result=Result(title='ツールエージェント画面', summary='この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。', labels=['AI チャット', 'ツール選択', 'インターフェース'], reliability=0.9))]}} (1383596555.py:28)\n" + ] + } + ], + "source": [ + "from uuid import uuid4\n", + "\n", + "from template_langgraph.agents.image_classifier_agent.agent import ImageClassifierAgent\n", + "from template_langgraph.agents.image_classifier_agent.classifiers import (\n", + " LlmClassifier,\n", + ")\n", + "from template_langgraph.agents.image_classifier_agent.models import (\n", + " AgentInputState,\n", + " AgentState,\n", + " Results,\n", + ")\n", + "\n", + "# Create an instance of the agent\n", + "graph = ImageClassifierAgent(\n", + " classifier=LlmClassifier(),\n", + ").create_graph()\n", + "for event in graph.stream(\n", + " input=AgentState(\n", + " input=AgentInputState(\n", + " prompt=\"この画像の中身を 3 行で日本語で説明してください\",\n", + " id=str(uuid4()),\n", + " file_paths=\"../docs/images/fastapi.png,../docs/images/streamlit.png\".split(\",\"),\n", + " ),\n", + " results=[],\n", + " )\n", + "):\n", + " logger.info(\"-\" * 20)\n", + " logger.info(f\"Event: {event}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c6c68866", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"file_path\": \"../docs/images/fastapi.png\",\n", + " \"result\": {\n", + " \"title\": \"KABUTOシステム起動時の問題\",\n", + " \"summary\": \"KABUTOシステムの起動時にスクリーンが紫色にフラッシュし、システムがフリーズする問題について言及しています。この問題は、内部時計と外部時計の同期が失敗することに関連しており、「シノビプロトコル」初期化失敗が原因とされています。トラブルシューティングの手順として、全ての周辺機器を外してシステムを再起動することが推奨されています。\",\n", + " \"labels\": [\n", + " \"KABUTO\",\n", + " \"システムフリーズ\",\n", + " \"初期化失敗\",\n", + " \"トラブルシューティング\",\n", + " \"周辺機器解除\"\n", + " ],\n", + " \"reliability\": 0.94\n", + " }\n", + "}\n", + "{\n", + " \"file_path\": \"../docs/images/streamlit.png\",\n", + " \"result\": {\n", + " \"title\": \"ツールエージェント画面\",\n", + " \"summary\": \"この画像は利用可能なツールを選択し、AIと対話を行うインターフェースの表示です。\",\n", + " \"labels\": [\n", + " \"AI チャット\",\n", + " \"ツール選択\",\n", + " \"インターフェース\"\n", + " ],\n", + " \"reliability\": 0.9\n", + " }\n", + "}\n" + ] + } + ], + "source": [ + "results: list[Results] = event[\"notify\"][\"results\"]\n", + "for result in results:\n", + " print(f\"{result.model_dump_json(indent=2)}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/issue_formatter_agent.ipynb b/notebooks/issue_formatter_agent.ipynb index fccf0e6..1249daa 100644 --- a/notebooks/issue_formatter_agent.ipynb +++ b/notebooks/issue_formatter_agent.ipynb @@ -34,12 +34,19 @@ "id": "c23a49b7-a3e9-4685-899e-3e7c02278360", "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:34:02,418 [ INFO] Analyzing issue with state: {'messages': [HumanMessage(content='KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='5da5e35e-b768-48e3-93ee-1ba8a9bf5d62')]} (agent.py:33)\n" + ] + }, { "name": "stdout", "output_type": "stream", "text": [ "--------------------\n", - "Event: {'analyze': {'messages': [HumanMessage(content='KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='6acb805e-d012-4a58-89ac-8e5c1bb58eac')], 'issue': Issue(title='KABUTOログイン問題', description='若手社員の山田太郎さんが、Windows 11環境で業務システムKABUTOにログインしようとした際、ログイン画面に「虚無」という文字が表示され、ログインできない問題が発生しました。', labels=[, ], assignee='岡本太郎', milestone=None, system_info=SystemInfo(os='Windows 11', version=None), steps_to_reproduce=['Windows 11を起動する', 'KABUTOのログイン画面を開く'], current_behavior='ログイン画面に「虚無」という文字が表示される', expected_behavior='正常にログインできる')}}\n" + "Event: {'analyze': {'messages': [HumanMessage(content='KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='5da5e35e-b768-48e3-93ee-1ba8a9bf5d62')], 'issue': Issue(title='KABUTO Login Issue - \"虚無\" Error', description=\"Young employee Tarou Yamada faces a login issue with the company's system, KABUTO. Despite entering what he believes to be the correct password, he is met with the lone, enigmatic word '虚無' ('nothingness') on the login screen. We seek to understand the cause and find a resolution. \", labels=[, ], assignee='岡本太郎', milestone=None, system_info=SystemInfo(os='Windows 11', version=None), steps_to_reproduce=['Start Windows 11.', 'Open the KABUTO login page.', 'Enter the password and attempt to log in.'], current_behavior=\"The login screen displays '虚無' after entering the password.\", expected_behavior='Successful login into the KABUTO system without any error message.')}}\n" ] } ], @@ -72,8 +79,8 @@ "output_type": "stream", "text": [ "{\n", - " \"title\": \"KABUTOログイン問題\",\n", - " \"description\": \"若手社員の山田太郎さんが、Windows 11環境で業務システムKABUTOにログインしようとした際、ログイン画面に「虚無」という文字が表示され、ログインできない問題が発生しました。\",\n", + " \"title\": \"KABUTO Login Issue - \\\"虚無\\\" Error\",\n", + " \"description\": \"Young employee Tarou Yamada faces a login issue with the company's system, KABUTO. Despite entering what he believes to be the correct password, he is met with the lone, enigmatic word '虚無' ('nothingness') on the login screen. We seek to understand the cause and find a resolution. \",\n", " \"labels\": [\n", " \"bug\",\n", " \"question\"\n", @@ -85,11 +92,12 @@ " \"version\": null\n", " },\n", " \"steps_to_reproduce\": [\n", - " \"Windows 11を起動する\",\n", - " \"KABUTOのログイン画面を開く\"\n", + " \"Start Windows 11.\",\n", + " \"Open the KABUTO login page.\",\n", + " \"Enter the password and attempt to log in.\"\n", " ],\n", - " \"current_behavior\": \"ログイン画面に「虚無」という文字が表示される\",\n", - " \"expected_behavior\": \"正常にログインできる\"\n", + " \"current_behavior\": \"The login screen displays '虚無' after entering the password.\",\n", + " \"expected_behavior\": \"Successful login into the KABUTO system without any error message.\"\n", "}\n" ] } diff --git a/notebooks/kabuto_helpdesk_agent.ipynb b/notebooks/kabuto_helpdesk_agent.ipynb new file mode 100644 index 0000000..69b1800 --- /dev/null +++ b/notebooks/kabuto_helpdesk_agent.ipynb @@ -0,0 +1,100 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "1f4d669f", + "metadata": {}, + "outputs": [], + "source": [ + "from dotenv import load_dotenv\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1e7aea7c-3965-4c2c-b2d5-da9b01598d47", + "metadata": {}, + "outputs": [], + "source": [ + "from template_langgraph.agents.kabuto_helpdesk_agent.agent import KabutoHelpdeskAgent\n", + "\n", + "# Create an instance of the agent\n", + "agent = KabutoHelpdeskAgent().agent" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "21bd80ab", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\u001b[1m[values]\u001b[0m {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='be57dbbb-781a-4f5f-b842-3535c0e1e116')]}\n", + "\u001b[1m[updates]\u001b[0m {'agent': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--bf40a9ad-6545-49f8-ab79-4d7cafb0dd7d-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 停止 原因 対策'}, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 停止 対策'}, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'type': 'tool_call'}])]}}\n", + "--------------------\n", + "Event: {'agent': {'messages': [AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--bf40a9ad-6545-49f8-ab79-4d7cafb0dd7d-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 停止 原因 対策'}, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 停止 対策'}, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'type': 'tool_call'}])]}}\n", + "\u001b[1m[values]\u001b[0m {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='be57dbbb-781a-4f5f-b842-3535c0e1e116'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--bf40a9ad-6545-49f8-ab79-4d7cafb0dd7d-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 停止 原因 対策'}, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 停止 対策'}, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'type': 'tool_call'}])]}\n", + "\u001b[1m[updates]\u001b[0m {'tools': {'messages': [ToolMessage(content=\"[ElasticsearchOutput(file_name='docs_kabuto.pdf', content='「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\n第 3 章 ソフトウェア・オペレーション\\\\n3.1 起動プロトコル\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\n4.2 ⼊⼒・ AI アシスタント\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\n4.3 スクリーンショット機能'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\n4.5 システム・パーソナライゼーション\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\n第 5 章 バグ・特殊現象')]\", name='search_elasticsearch', tool_call_id='call_xmLNx80e6cgjH707LRGCsMbv')]}}\n", + "--------------------\n", + "Event: {'tools': {'messages': [ToolMessage(content=\"[ElasticsearchOutput(file_name='docs_kabuto.pdf', content='「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\n第 3 章 ソフトウェア・オペレーション\\\\n3.1 起動プロトコル\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\n4.2 ⼊⼒・ AI アシスタント\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\n4.3 スクリーンショット機能'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\n4.5 システム・パーソナライゼーション\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\n第 5 章 バグ・特殊現象')]\", name='search_elasticsearch', tool_call_id='call_xmLNx80e6cgjH707LRGCsMbv')]}}\n", + "\u001b[1m[updates]\u001b[0m {'tools': {'messages': [ToolMessage(content=\"[QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。')]\", name='search_qdrant', tool_call_id='call_BQH8AbHrPJpWnVJUgHXQxMae')]}}\n", + "--------------------\n", + "Event: {'tools': {'messages': [ToolMessage(content=\"[QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。')]\", name='search_qdrant', tool_call_id='call_BQH8AbHrPJpWnVJUgHXQxMae')]}}\n", + "\u001b[1m[values]\u001b[0m {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='be57dbbb-781a-4f5f-b842-3535c0e1e116'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--bf40a9ad-6545-49f8-ab79-4d7cafb0dd7d-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 停止 原因 対策'}, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 停止 対策'}, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'type': 'tool_call'}]), ToolMessage(content=\"[QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。')]\", name='search_qdrant', id='5ff36728-93e6-49d8-a97c-a080284c5a4a', tool_call_id='call_BQH8AbHrPJpWnVJUgHXQxMae'), ToolMessage(content=\"[ElasticsearchOutput(file_name='docs_kabuto.pdf', content='「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\n第 3 章 ソフトウェア・オペレーション\\\\n3.1 起動プロトコル\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\n4.2 ⼊⼒・ AI アシスタント\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\n4.3 スクリーンショット機能'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\n4.5 システム・パーソナライゼーション\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\n第 5 章 バグ・特殊現象')]\", name='search_elasticsearch', id='613bcd47-fb94-49f7-ac19-8c9493623e24', tool_call_id='call_xmLNx80e6cgjH707LRGCsMbv')]}\n", + "\u001b[1m[updates]\u001b[0m {'agent': {'messages': [AIMessage(content='KABUTOシステムが「鬼灯」を実行した際に急停止する原因と対策について収集した情報を以下に示します。\\n\\n### 原因:\\n1. **過熱警告:** 「鬼灯」実行中に過熱警告が表示され、システムが強制終了される事例があります。特に無音状態が15分以上続くことが過熱を引き起こす可能性があるため、この状態が続かないようにする必要があります。\\n \\n2. **システム同期失敗:** 内部クロックと接続された外部周辺機器との同期失敗が起こる場合があり、これによりシステムが停止することがあります。\\n\\n### 対策:\\n1. **無音状態を短くする:** 無音状態が15分以上続かないように定期的に確認し、過熱の可能性を防ぎます。\\n\\n2. **システムの再起動:** 過熱の警告が表示された場合は、アプリケーションを強制終了し、システムを再起動することが推奨されます。\\n\\n3. **システム設定の調整:** 特定のフォルダ名読み取り優先モードを一時的に無効化したり、AI機能「ヤタガラス」や「天照の予知夢オプション」を無効化することで、システムのパフォーマンスを改善し、問題を回避することができます。\\n\\nこれらの対策を試みることで「鬼灯」実行時の急停止問題を防ぐことができる可能性があります。システムの設定を定期的に見直し、問題が続く場合は技術担当者による詳細な診断を依頼することが望ましいです。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--efb19b12-fd39-4f04-8f26-0233142c049f-0')]}}\n", + "--------------------\n", + "Event: {'agent': {'messages': [AIMessage(content='KABUTOシステムが「鬼灯」を実行した際に急停止する原因と対策について収集した情報を以下に示します。\\n\\n### 原因:\\n1. **過熱警告:** 「鬼灯」実行中に過熱警告が表示され、システムが強制終了される事例があります。特に無音状態が15分以上続くことが過熱を引き起こす可能性があるため、この状態が続かないようにする必要があります。\\n \\n2. **システム同期失敗:** 内部クロックと接続された外部周辺機器との同期失敗が起こる場合があり、これによりシステムが停止することがあります。\\n\\n### 対策:\\n1. **無音状態を短くする:** 無音状態が15分以上続かないように定期的に確認し、過熱の可能性を防ぎます。\\n\\n2. **システムの再起動:** 過熱の警告が表示された場合は、アプリケーションを強制終了し、システムを再起動することが推奨されます。\\n\\n3. **システム設定の調整:** 特定のフォルダ名読み取り優先モードを一時的に無効化したり、AI機能「ヤタガラス」や「天照の予知夢オプション」を無効化することで、システムのパフォーマンスを改善し、問題を回避することができます。\\n\\nこれらの対策を試みることで「鬼灯」実行時の急停止問題を防ぐことができる可能性があります。システムの設定を定期的に見直し、問題が続く場合は技術担当者による詳細な診断を依頼することが望ましいです。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--efb19b12-fd39-4f04-8f26-0233142c049f-0')]}}\n", + "\u001b[1m[values]\u001b[0m {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='be57dbbb-781a-4f5f-b842-3535c0e1e116'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'function': {'arguments': '{\"keywords\": \"鬼灯 停止 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--bf40a9ad-6545-49f8-ab79-4d7cafb0dd7d-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 停止 原因 対策'}, 'id': 'call_BQH8AbHrPJpWnVJUgHXQxMae', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 停止 対策'}, 'id': 'call_xmLNx80e6cgjH707LRGCsMbv', 'type': 'tool_call'}]), ToolMessage(content=\"[QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。'), QdrantOutput(file_name='./data/reports_kabuto.csv', content='error_code: KABUTO-0102 timestamp: 2025-07-20T10:03:45+09:00 user_message: アプリ鬼灯を起動するとファンが停止し無音のまま。10分で復帰せず不安。')]\", name='search_qdrant', id='5ff36728-93e6-49d8-a97c-a080284c5a4a', tool_call_id='call_BQH8AbHrPJpWnVJUgHXQxMae'), ToolMessage(content=\"[ElasticsearchOutput(file_name='docs_kabuto.pdf', content='「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\n第 3 章 ソフトウェア・オペレーション\\\\n3.1 起動プロトコル\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\n4.2 ⼊⼒・ AI アシスタント\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\n4.3 スクリーンショット機能'), ElasticsearchOutput(file_name='docs_kabuto.pdf', content='を無効にするには、動画再⽣中に右クリックメニューから「葛飾北斎」オプションをオフにする。\\\\n4.5 システム・パーソナライゼーション\\\\n⾼度な AI 機能「天照」は、ユーザーの無意識下での情報を収集し、デスクトップの背景画像をユーザーの最後に⾒た\\\\n「夢」の内容に変更する機能を持つ。この機能を停⽌するには、システム設定内の「天照の予知夢」オプションを無\\\\n効化する。ただし、この設定の無効化は、 KABUTO の全体的なパフォーマンスの⼀部低下を招く可能性がある。\\\\n第 5 章 バグ・特殊現象')]\", name='search_elasticsearch', id='613bcd47-fb94-49f7-ac19-8c9493623e24', tool_call_id='call_xmLNx80e6cgjH707LRGCsMbv'), AIMessage(content='KABUTOシステムが「鬼灯」を実行した際に急停止する原因と対策について収集した情報を以下に示します。\\n\\n### 原因:\\n1. **過熱警告:** 「鬼灯」実行中に過熱警告が表示され、システムが強制終了される事例があります。特に無音状態が15分以上続くことが過熱を引き起こす可能性があるため、この状態が続かないようにする必要があります。\\n \\n2. **システム同期失敗:** 内部クロックと接続された外部周辺機器との同期失敗が起こる場合があり、これによりシステムが停止することがあります。\\n\\n### 対策:\\n1. **無音状態を短くする:** 無音状態が15分以上続かないように定期的に確認し、過熱の可能性を防ぎます。\\n\\n2. **システムの再起動:** 過熱の警告が表示された場合は、アプリケーションを強制終了し、システムを再起動することが推奨されます。\\n\\n3. **システム設定の調整:** 特定のフォルダ名読み取り優先モードを一時的に無効化したり、AI機能「ヤタガラス」や「天照の予知夢オプション」を無効化することで、システムのパフォーマンスを改善し、問題を回避することができます。\\n\\nこれらの対策を試みることで「鬼灯」実行時の急停止問題を防ぐことができる可能性があります。システムの設定を定期的に見直し、問題が続く場合は技術担当者による詳細な診断を依頼することが望ましいです。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--efb19b12-fd39-4f04-8f26-0233142c049f-0')]}\n" + ] + } + ], + "source": [ + "question = \"「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。\"\n", + "\n", + "# Stream the agent's response to the question\n", + "for event in agent.stream(\n", + " input={\n", + " \"messages\": [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": question,\n", + " }\n", + " ],\n", + " }\n", + "):\n", + " print(\"-\" * 20)\n", + " print(f\"Event: {event}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/news_summarizer_agent.ipynb b/notebooks/news_summarizer_agent.ipynb new file mode 100644 index 0000000..91ca8e7 --- /dev/null +++ b/notebooks/news_summarizer_agent.ipynb @@ -0,0 +1,145 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "1f4d669f", + "metadata": {}, + "outputs": [], + "source": [ + "import logging\n", + "\n", + "from dotenv import load_dotenv\n", + "\n", + "from template_langgraph.loggers import get_logger\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")\n", + "\n", + "logger = get_logger(__name__)\n", + "logger.setLevel(logging.DEBUG)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "21bd80ab", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:34:54,402 [ INFO] Initializing state: input=AgentInputState(prompt='Please summarize the articles in Japanese briefly in 3 sentences.', id='8d053e30-be0c-41b4-bd15-bad270c16528', urls=['https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md']) articles=[] (agent.py:60)\n", + "2025-08-14 11:34:54,403 [ INFO] Running subtasks with state: input=AgentInputState(prompt='Please summarize the articles in Japanese briefly in 3 sentences.', id='8d053e30-be0c-41b4-bd15-bad270c16528', urls=['https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md']) articles=[] (agent.py:66)\n", + "2025-08-14 11:34:54,403 [ INFO] -------------------- (2710366794.py:23)\n", + "2025-08-14 11:34:54,403 [ INFO] Event: {'initialize': {'input': AgentInputState(prompt='Please summarize the articles in Japanese briefly in 3 sentences.', id='8d053e30-be0c-41b4-bd15-bad270c16528', urls=['https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md']), 'articles': []}} (2710366794.py:24)\n", + "2025-08-14 11:34:54,404 [ INFO] Scraping URL: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md (agent.py:90)\n", + "2025-08-14 11:34:54,404 [ INFO] Fetching URL via httpx: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md (scrapers.py:77)\n", + "2025-08-14 11:34:54,404 [ INFO] Scraping URL: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md (agent.py:90)\n", + "2025-08-14 11:34:54,404 [ INFO] Fetching URL via httpx: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md (scrapers.py:77)\n", + "2025-08-14 11:34:54,696 [ INFO] Summarizing content with LLM: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md (agent.py:97)\n", + "2025-08-14 11:34:54,697 [ INFO] Summarizing input with LLM: Please summarize the articles in Japanese briefly in 3 sentences. (summarizers.py:72)\n", + "2025-08-14 11:34:54,703 [ INFO] Summarizing content with LLM: https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md (agent.py:97)\n", + "2025-08-14 11:34:54,704 [ INFO] Summarizing input with LLM: Please summarize the articles in Japanese briefly in 3 sentences. (summarizers.py:72)\n", + "2025-08-14 11:34:58,175 [ INFO] -------------------- (2710366794.py:23)\n", + "2025-08-14 11:34:58,176 [ INFO] Event: {'summarize_web_content': {'articles': [Article(is_valid_url=True, is_valid_content=True, content='## Deployment instructions\\n\\n### Azure resources\\n\\nTo deploy Azure resources for this project, you can use the provided [Bicep template](https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep/tree/main/infra/scenarios/template-langgraph). This template sets up the necessary resources for running the LangGraph application.\\n\\nTo quickly deploy the application, [Deploy to Azure button](https://learn.microsoft.com/azure/azure-resource-manager/templates/deploy-to-azure-button) is available. By clicking the following button, you can deploy the resources directly from the Azure portal:\\n\\n[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fks6088ts-labs%2Fbaseline-environment-on-azure-bicep%2Frefs%2Fheads%2Fmain%2Finfra%2Fscenarios%2Ftemplate-langgraph%2Fazuredeploy.json)\\n\\n### Docker Hub\\n\\nTo publish the docker image to Docker Hub, you need to [create access token](https://app.docker.com/settings/personal-access-tokens/create) and set the following secrets in the repository settings.\\n\\n```shell\\ngh secret set DOCKERHUB_USERNAME --body $DOCKERHUB_USERNAME\\ngh secret set DOCKERHUB_TOKEN --body $DOCKERHUB_TOKEN\\n```\\n\\n### Azure Static Web Apps\\n\\n```shell\\nRESOURCE_GROUP_NAME=your-resource-group-name\\nSWA_NAME=your-static-web-app-name\\n\\n# Create a static app\\naz staticwebapp create --name $SWA_NAME --resource-group $RESOURCE_GROUP_NAME\\n\\n# Retrieve the API key\\nAZURE_STATIC_WEB_APPS_API_TOKEN=$(az staticwebapp secrets list --name $SWA_NAME --query \"properties.apiKey\" -o tsv)\\n\\n# Set the API key as a GitHub secret\\ngh secret set AZURE_STATIC_WEB_APPS_API_TOKEN --body $AZURE_STATIC_WEB_APPS_API_TOKEN\\n```\\n\\nRefer to the following links for more information:\\n\\n- [Deploying to Azure Static Web App](https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-azure-static-web-app)\\n- [Create a static web app: `az staticwebapp create`](https://learn.microsoft.com/en-us/cli/azure/staticwebapp?view=azure-cli-latest#az-staticwebapp-create)\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md', structured_article=StructuredArticle(title='AzureリソースとDocker Hubのデプロイ手順', date='2023-10-01', summary='この記事では、AzureリソースのデプロイとDocker Hubへのコンテナイメージの公開手順を解説しています。Azure上でLangGraphアプリケーションを動作させるためのリソースは、Bicepテンプレートを使用して簡単に設定できます。また、Docker Hubには、個人アクセストークンを使ってリポジトリの設定で必要なシークレットを入力することで、コンテナを公開できます。', keywords=['Azure', 'Bicepテンプレート', 'Docker Hub', 'LangGraph', '静的ウェブアプリ'], score=85))]}} (2710366794.py:24)\n", + "2025-08-14 11:34:58,805 [ INFO] -------------------- (2710366794.py:23)\n", + "2025-08-14 11:34:58,806 [ INFO] Event: {'summarize_web_content': {'articles': [Article(is_valid_url=True, is_valid_content=True, content='# LangGraph AI Agent Template\\n\\nA comprehensive template project for building AI agents using [LangGraph](https://langchain-ai.github.io/langgraph/), demonstrating various agent patterns, tool integration, and real-world use cases.\\n\\n## What is LangGraph?\\n\\n[LangGraph](https://langchain-ai.github.io/langgraph/) is a framework built on top of [LangChain](https://python.langchain.com/) that enables you to create stateful, multi-agent workflows. Unlike traditional chatbots that handle single interactions, LangGraph allows you to build complex AI systems that can:\\n\\n- Maintain conversation state across multiple turns\\n- Use tools and external APIs\\n- Implement complex reasoning patterns\\n- Coordinate multiple AI agents\\n- Handle cyclical workflows and conditional logic\\n\\nThis template demonstrates these capabilities through practical examples using a fictional system called \"KABUTO\" for troubleshooting scenarios.\\n\\n## Project Overview\\n\\nThis project showcases different AI agent patterns and architectures, from simple tool-calling agents to complex multi-agent systems. The examples use a fictional technical support scenario to demonstrate how agents can retrieve information from multiple data sources and provide structured responses.\\n\\n### Why This Template Exists\\n\\nMost AI applications need to:\\n\\n1. **Access external information** - LLMs don\\'t have access to your specific data\\n2. **Use tools** - Perform actions beyond text generation\\n3. **Maintain context** - Remember previous interactions\\n4. **Handle complex workflows** - Break down tasks into manageable steps\\n\\nThis template provides working examples of all these patterns using LangGraph.\\n\\n## Prerequisites\\n\\n- [Python 3.10+](https://www.python.org/downloads/)\\n- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Modern Python package manager\\n- [GNU Make](https://www.gnu.org/software/make/) - For running common tasks\\n- [Docker](https://www.docker.com/) - For running vector databases (optional)\\n- Azure\\n - [Azure OpenAI](https://learn.microsoft.com/ja-jp/azure/ai-foundry/openai/overview) - LLM API\\n - [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/) - Data storage (optional)\\n\\n## Quick Start\\n\\n### 1. Environment Setup\\n\\n```shell\\n# Clone the repository\\ngit clone https://github.com/ks6088ts-labs/template-langgraph.git\\ncd template-langgraph\\n\\n# Install Python dependencies\\nuv sync --all-extras\\n\\n# Create environment configuration\\ncp .env.template .env\\n# Edit .env with your API keys (Azure OpenAI, etc.)\\n```\\n\\n### 2. Start Supporting Services (Optional)\\n\\nFor full functionality, start the vector databases:\\n\\n```shell\\n# Start Qdrant and Elasticsearch using Docker\\ndocker compose up -d\\n```\\n\\n### 3. Initialize Data Sources\\n\\n**Set up Qdrant vector database:**\\n\\n```shell\\nuv run python scripts/qdrant_operator.py add-documents \\\\\\n --collection-name qa_kabuto \\\\\\n --verbose\\n```\\n\\n**Set up Elasticsearch search index:**\\n\\n```shell\\nuv run python scripts/elasticsearch_operator.py create-index \\\\\\n --index-name docs_kabuto \\\\\\n --verbose\\n```\\n\\n## Project Structure\\n\\n### Core Components\\n\\n- **`data/`** - Sample data for the fictional KABUTO system (PDFs, FAQs, troubleshooting guides)\\n- **`template_langgraph/`** - Main Python package containing all agent implementations\\n- **`notebooks/`** - Jupyter notebooks with interactive examples and explanations\\n- **`scripts/`** - Command-line tools for running agents\\n\\n### Agent Examples (`template_langgraph/agents/`)\\n\\nThis project includes several agent implementations, each demonstrating different LangGraph patterns:\\n\\n#### 1. `kabuto_helpdesk_agent/` - **Start Here!**\\n\\nA simple agent using LangGraph\\'s prebuilt `create_react_agent` function. This is the best starting point for understanding the basics.\\n\\n**Key concepts:** ReAct pattern, tool calling, prebuilt agents\\n\\n#### 2. `chat_with_tools_agent/` - **Core Implementation**\\n\\nA manual implementation of the same logic as the helpdesk agent, showing how LangGraph workflows are built from scratch.\\n\\n**Key concepts:** Graph construction, state management, node functions, edges\\n\\n#### 3. `issue_formatter_agent/` - **Structured Output**\\n\\nDemonstrates how to get structured data from AI responses using Pydantic models.\\n\\n**Key concepts:** Structured output, data validation, response formatting\\n\\n#### 4. `task_decomposer_agent/` - **Planning & Decomposition**\\n\\nShows how to break down complex tasks into smaller, manageable steps.\\n\\n**Key concepts:** Task planning, multi-step reasoning, conditional workflows\\n\\n#### 5. `supervisor_agent/` - **Multi-Agent Coordination**\\n\\nImplements the supervisor pattern where one agent coordinates multiple specialized agents.\\n\\n**Key concepts:** Multi-agent systems, agent coordination, supervisor patterns\\n\\n### Supporting Modules\\n\\n- **`template_langgraph/llms/`** - LLM API wrappers (Azure OpenAI, etc.)\\n- **`template_langgraph/tools/`** - Tool implementations for search, data retrieval\\n- **`template_langgraph/internals/`** - Internal utilities and helper functions (CSV/PDF loaders, Otel wrappers, etc.)\\n\\n## Running the Examples\\n\\n### Option 1: LangGraph Studio (Recommended for Development)\\n\\n[LangGraph Studio](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/) provides a visual interface for developing and debugging agents:\\n\\n```shell\\nuv run langgraph dev\\n```\\n\\nThis opens a web interface where you can:\\n\\n- Visualize agent workflows\\n- Step through executions\\n- Debug state transitions\\n- Test different inputs\\n\\n![langgraph-studio.png](./images/langgraph-studio.png)\\n\\n### Option 2: Jupyter Notebooks (Best for Learning)\\n\\nInteractive notebooks with explanations and examples:\\n\\n```shell\\nuv run jupyter lab\\n# Navigate to http://localhost:8888 and open notebooks/*.ipynb\\n```\\n\\n![jupyterlab.png](./images/jupyterlab.png)\\n\\n### Option 3: Command Line (Quick development)\\n\\nRun agents from the terminal:\\n\\n```shell\\nuv run python scripts/agent_operator.py run \\\\\\n --name \"chat_with_tools_agent\" \\\\\\n --question \"KABUTO startup issue: screen flashes purple and system freezes\" \\\\\\n --verbose\\n```\\n\\nExample output showing the agent\\'s reasoning process:\\n\\n```text\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\', tool_calls=[\\n {\\'name\\': \\'search_elasticsearch\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}},\\n {\\'name\\': \\'search_qdrant\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}}\\n])]}}\\n\\nEvent: {\\'tools\\': {\\'messages\\': [ToolMessage(content=\\'Found documentation about startup protocol...\\')]}}\\n\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\n### Problem Analysis\\nThe purple screen flashing during KABUTO startup indicates a \"Shinobi Protocol\" initialization failure...\\n\\n### Solution\\n1. **Disconnect peripheral devices**: Unplug all connected devices for 5+ seconds\\n2. **Clear external clock cache**: This resolves clock synchronization issues\\n3. **Restart KABUTO**: Use the \"Dragon Ball\" button for 5+ seconds if needed\\n\\')]}}\\n```\\n\\n### Option 4: FastAPI (Production-ready)\\n\\nRun the FastAPI server to expose the agent as an API:\\n\\n```shell\\nuv run fastapi run \\\\\\n --host \"0.0.0.0\" \\\\\\n --port 8000 \\\\\\n --workers 4 \\\\\\n template_langgraph/services/fastapis/main.py\\n# Access the API at http://localhost:8000/docs via Swagger UI\\n```\\n\\nThis allows you to interact with the agent programmatically via HTTP requests.\\n\\n![fastapi.png](./images/fastapi.png)\\n\\n### Option 5: Streamlit (PoC demo)\\n\\nRun the Streamlit app to expose the agent as a web interface:\\n\\n```shell\\nuv run streamlit run \\\\\\n template_langgraph/services/streamlits/main.py\\n```\\n\\nDemonstration of the Streamlit app:\\n\\n[![streamlit.png](./images/streamlit.png)](https://youtu.be/undxBwyJ3Sc)\\n\\n## Key Concepts Demonstrated\\n\\n### 1. **ReAct Pattern** (Reasoning + Acting)\\n\\nThe foundation of modern AI agents - the ability to reason about what to do, take actions, and reason about the results.\\n\\n### 2. **Tool Calling**\\n\\nHow agents can use external functions to:\\n\\n- Search databases (Elasticsearch, Qdrant)\\n- Call APIs\\n- Process files\\n- Execute calculations\\n\\n### 3. **State Management**\\n\\nHow LangGraph maintains context across multiple interaction steps, enabling complex multi-turn conversations.\\n\\n### 4. **Conditional Workflows**\\n\\nUsing graph structures to create branching logic based on agent decisions or external conditions.\\n\\n### 5. **Multi-Agent Systems**\\n\\nCoordinating multiple specialized agents to handle complex tasks that require different expertise.\\n\\n## Data Sources Explained\\n\\nThe project uses fictional data about a system called \"KABUTO\" to demonstrate real-world scenarios:\\n\\n- **`data/docs_kabuto.pdf`** - Technical documentation (simulates user manuals)\\n- **`data/qa_kabuto.csv`** - FAQ database (simulates past support tickets)\\n- **`data/docs_kabuto.md`** - Additional documentation\\n\\nThis fictional data serves a purpose: it proves that the AI agents can work with information that isn\\'t in the LLM\\'s training data, demonstrating the value of retrieval-augmented generation (RAG).\\n\\n## Next Steps\\n\\n1. **Start with the basics**: Run the `kabuto_helpdesk_agent` example\\n2. **Understand the implementation**: Compare it with `chat_with_tools_agent`\\n3. **Explore advanced patterns**: Try the task decomposer and supervisor agents\\n4. **Build your own**: Use this template as a starting point for your use case\\n\\n## Learning Resources\\n\\n- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)\\n- [LangChain Documentation](https://python.langchain.com/)\\n\\n## Architecture Examples\\n\\nThis template demonstrates several proven agent architectures:\\n\\n1. **Single Agent with Tools** - Basic tool-calling pattern\\n2. **ReAct Agent** - Reasoning and acting in loops\\n3. **Structured Output Agent** - Returning formatted data\\n4. **Planning Agent** - Breaking down complex tasks\\n5. **Supervisor Agent** - Coordinating multiple agents\\n\\nEach pattern is implemented with clear examples and documentation to help you understand when and how to use them.\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', structured_article=StructuredArticle(title='LangGraph AI Agent Template', date='Not provided', summary='LangGraphは、複数のAIエージェントをコーディネートし、会話状態を保持しながら高度なワークフローを作成できるフレームワークです。このテンプレートプロジェクトでは、LangGraphを使用して様々なエージェントパターンとツール統合、および実際のユースケースを例示します。プロジェクトには、簡単なツール呼び出しエージェントから多エージェントシステムまでの実装例が含まれており、実世界のシナリオで情報を取得し構造化された応答を提供できるエージェントの構築方法を示します。', keywords=['LangGraph', 'AIエージェント', 'テンプレート', 'ツール統合', 'ワークフロー'], score=80))]}} (2710366794.py:24)\n", + "2025-08-14 11:34:58,807 [ INFO] Sending notifications with state: input=AgentInputState(prompt='Please summarize the articles in Japanese briefly in 3 sentences.', id='8d053e30-be0c-41b4-bd15-bad270c16528', urls=['https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md']) articles=[Article(is_valid_url=True, is_valid_content=True, content='# LangGraph AI Agent Template\\n\\nA comprehensive template project for building AI agents using [LangGraph](https://langchain-ai.github.io/langgraph/), demonstrating various agent patterns, tool integration, and real-world use cases.\\n\\n## What is LangGraph?\\n\\n[LangGraph](https://langchain-ai.github.io/langgraph/) is a framework built on top of [LangChain](https://python.langchain.com/) that enables you to create stateful, multi-agent workflows. Unlike traditional chatbots that handle single interactions, LangGraph allows you to build complex AI systems that can:\\n\\n- Maintain conversation state across multiple turns\\n- Use tools and external APIs\\n- Implement complex reasoning patterns\\n- Coordinate multiple AI agents\\n- Handle cyclical workflows and conditional logic\\n\\nThis template demonstrates these capabilities through practical examples using a fictional system called \"KABUTO\" for troubleshooting scenarios.\\n\\n## Project Overview\\n\\nThis project showcases different AI agent patterns and architectures, from simple tool-calling agents to complex multi-agent systems. The examples use a fictional technical support scenario to demonstrate how agents can retrieve information from multiple data sources and provide structured responses.\\n\\n### Why This Template Exists\\n\\nMost AI applications need to:\\n\\n1. **Access external information** - LLMs don\\'t have access to your specific data\\n2. **Use tools** - Perform actions beyond text generation\\n3. **Maintain context** - Remember previous interactions\\n4. **Handle complex workflows** - Break down tasks into manageable steps\\n\\nThis template provides working examples of all these patterns using LangGraph.\\n\\n## Prerequisites\\n\\n- [Python 3.10+](https://www.python.org/downloads/)\\n- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Modern Python package manager\\n- [GNU Make](https://www.gnu.org/software/make/) - For running common tasks\\n- [Docker](https://www.docker.com/) - For running vector databases (optional)\\n- Azure\\n - [Azure OpenAI](https://learn.microsoft.com/ja-jp/azure/ai-foundry/openai/overview) - LLM API\\n - [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/) - Data storage (optional)\\n\\n## Quick Start\\n\\n### 1. Environment Setup\\n\\n```shell\\n# Clone the repository\\ngit clone https://github.com/ks6088ts-labs/template-langgraph.git\\ncd template-langgraph\\n\\n# Install Python dependencies\\nuv sync --all-extras\\n\\n# Create environment configuration\\ncp .env.template .env\\n# Edit .env with your API keys (Azure OpenAI, etc.)\\n```\\n\\n### 2. Start Supporting Services (Optional)\\n\\nFor full functionality, start the vector databases:\\n\\n```shell\\n# Start Qdrant and Elasticsearch using Docker\\ndocker compose up -d\\n```\\n\\n### 3. Initialize Data Sources\\n\\n**Set up Qdrant vector database:**\\n\\n```shell\\nuv run python scripts/qdrant_operator.py add-documents \\\\\\n --collection-name qa_kabuto \\\\\\n --verbose\\n```\\n\\n**Set up Elasticsearch search index:**\\n\\n```shell\\nuv run python scripts/elasticsearch_operator.py create-index \\\\\\n --index-name docs_kabuto \\\\\\n --verbose\\n```\\n\\n## Project Structure\\n\\n### Core Components\\n\\n- **`data/`** - Sample data for the fictional KABUTO system (PDFs, FAQs, troubleshooting guides)\\n- **`template_langgraph/`** - Main Python package containing all agent implementations\\n- **`notebooks/`** - Jupyter notebooks with interactive examples and explanations\\n- **`scripts/`** - Command-line tools for running agents\\n\\n### Agent Examples (`template_langgraph/agents/`)\\n\\nThis project includes several agent implementations, each demonstrating different LangGraph patterns:\\n\\n#### 1. `kabuto_helpdesk_agent/` - **Start Here!**\\n\\nA simple agent using LangGraph\\'s prebuilt `create_react_agent` function. This is the best starting point for understanding the basics.\\n\\n**Key concepts:** ReAct pattern, tool calling, prebuilt agents\\n\\n#### 2. `chat_with_tools_agent/` - **Core Implementation**\\n\\nA manual implementation of the same logic as the helpdesk agent, showing how LangGraph workflows are built from scratch.\\n\\n**Key concepts:** Graph construction, state management, node functions, edges\\n\\n#### 3. `issue_formatter_agent/` - **Structured Output**\\n\\nDemonstrates how to get structured data from AI responses using Pydantic models.\\n\\n**Key concepts:** Structured output, data validation, response formatting\\n\\n#### 4. `task_decomposer_agent/` - **Planning & Decomposition**\\n\\nShows how to break down complex tasks into smaller, manageable steps.\\n\\n**Key concepts:** Task planning, multi-step reasoning, conditional workflows\\n\\n#### 5. `supervisor_agent/` - **Multi-Agent Coordination**\\n\\nImplements the supervisor pattern where one agent coordinates multiple specialized agents.\\n\\n**Key concepts:** Multi-agent systems, agent coordination, supervisor patterns\\n\\n### Supporting Modules\\n\\n- **`template_langgraph/llms/`** - LLM API wrappers (Azure OpenAI, etc.)\\n- **`template_langgraph/tools/`** - Tool implementations for search, data retrieval\\n- **`template_langgraph/internals/`** - Internal utilities and helper functions (CSV/PDF loaders, Otel wrappers, etc.)\\n\\n## Running the Examples\\n\\n### Option 1: LangGraph Studio (Recommended for Development)\\n\\n[LangGraph Studio](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/) provides a visual interface for developing and debugging agents:\\n\\n```shell\\nuv run langgraph dev\\n```\\n\\nThis opens a web interface where you can:\\n\\n- Visualize agent workflows\\n- Step through executions\\n- Debug state transitions\\n- Test different inputs\\n\\n![langgraph-studio.png](./images/langgraph-studio.png)\\n\\n### Option 2: Jupyter Notebooks (Best for Learning)\\n\\nInteractive notebooks with explanations and examples:\\n\\n```shell\\nuv run jupyter lab\\n# Navigate to http://localhost:8888 and open notebooks/*.ipynb\\n```\\n\\n![jupyterlab.png](./images/jupyterlab.png)\\n\\n### Option 3: Command Line (Quick development)\\n\\nRun agents from the terminal:\\n\\n```shell\\nuv run python scripts/agent_operator.py run \\\\\\n --name \"chat_with_tools_agent\" \\\\\\n --question \"KABUTO startup issue: screen flashes purple and system freezes\" \\\\\\n --verbose\\n```\\n\\nExample output showing the agent\\'s reasoning process:\\n\\n```text\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\', tool_calls=[\\n {\\'name\\': \\'search_elasticsearch\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}},\\n {\\'name\\': \\'search_qdrant\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}}\\n])]}}\\n\\nEvent: {\\'tools\\': {\\'messages\\': [ToolMessage(content=\\'Found documentation about startup protocol...\\')]}}\\n\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\n### Problem Analysis\\nThe purple screen flashing during KABUTO startup indicates a \"Shinobi Protocol\" initialization failure...\\n\\n### Solution\\n1. **Disconnect peripheral devices**: Unplug all connected devices for 5+ seconds\\n2. **Clear external clock cache**: This resolves clock synchronization issues\\n3. **Restart KABUTO**: Use the \"Dragon Ball\" button for 5+ seconds if needed\\n\\')]}}\\n```\\n\\n### Option 4: FastAPI (Production-ready)\\n\\nRun the FastAPI server to expose the agent as an API:\\n\\n```shell\\nuv run fastapi run \\\\\\n --host \"0.0.0.0\" \\\\\\n --port 8000 \\\\\\n --workers 4 \\\\\\n template_langgraph/services/fastapis/main.py\\n# Access the API at http://localhost:8000/docs via Swagger UI\\n```\\n\\nThis allows you to interact with the agent programmatically via HTTP requests.\\n\\n![fastapi.png](./images/fastapi.png)\\n\\n### Option 5: Streamlit (PoC demo)\\n\\nRun the Streamlit app to expose the agent as a web interface:\\n\\n```shell\\nuv run streamlit run \\\\\\n template_langgraph/services/streamlits/main.py\\n```\\n\\nDemonstration of the Streamlit app:\\n\\n[![streamlit.png](./images/streamlit.png)](https://youtu.be/undxBwyJ3Sc)\\n\\n## Key Concepts Demonstrated\\n\\n### 1. **ReAct Pattern** (Reasoning + Acting)\\n\\nThe foundation of modern AI agents - the ability to reason about what to do, take actions, and reason about the results.\\n\\n### 2. **Tool Calling**\\n\\nHow agents can use external functions to:\\n\\n- Search databases (Elasticsearch, Qdrant)\\n- Call APIs\\n- Process files\\n- Execute calculations\\n\\n### 3. **State Management**\\n\\nHow LangGraph maintains context across multiple interaction steps, enabling complex multi-turn conversations.\\n\\n### 4. **Conditional Workflows**\\n\\nUsing graph structures to create branching logic based on agent decisions or external conditions.\\n\\n### 5. **Multi-Agent Systems**\\n\\nCoordinating multiple specialized agents to handle complex tasks that require different expertise.\\n\\n## Data Sources Explained\\n\\nThe project uses fictional data about a system called \"KABUTO\" to demonstrate real-world scenarios:\\n\\n- **`data/docs_kabuto.pdf`** - Technical documentation (simulates user manuals)\\n- **`data/qa_kabuto.csv`** - FAQ database (simulates past support tickets)\\n- **`data/docs_kabuto.md`** - Additional documentation\\n\\nThis fictional data serves a purpose: it proves that the AI agents can work with information that isn\\'t in the LLM\\'s training data, demonstrating the value of retrieval-augmented generation (RAG).\\n\\n## Next Steps\\n\\n1. **Start with the basics**: Run the `kabuto_helpdesk_agent` example\\n2. **Understand the implementation**: Compare it with `chat_with_tools_agent`\\n3. **Explore advanced patterns**: Try the task decomposer and supervisor agents\\n4. **Build your own**: Use this template as a starting point for your use case\\n\\n## Learning Resources\\n\\n- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)\\n- [LangChain Documentation](https://python.langchain.com/)\\n\\n## Architecture Examples\\n\\nThis template demonstrates several proven agent architectures:\\n\\n1. **Single Agent with Tools** - Basic tool-calling pattern\\n2. **ReAct Agent** - Reasoning and acting in loops\\n3. **Structured Output Agent** - Returning formatted data\\n4. **Planning Agent** - Breaking down complex tasks\\n5. **Supervisor Agent** - Coordinating multiple agents\\n\\nEach pattern is implemented with clear examples and documentation to help you understand when and how to use them.\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', structured_article=StructuredArticle(title='LangGraph AI Agent Template', date='Not provided', summary='LangGraphは、複数のAIエージェントをコーディネートし、会話状態を保持しながら高度なワークフローを作成できるフレームワークです。このテンプレートプロジェクトでは、LangGraphを使用して様々なエージェントパターンとツール統合、および実際のユースケースを例示します。プロジェクトには、簡単なツール呼び出しエージェントから多エージェントシステムまでの実装例が含まれており、実世界のシナリオで情報を取得し構造化された応答を提供できるエージェントの構築方法を示します。', keywords=['LangGraph', 'AIエージェント', 'テンプレート', 'ツール統合', 'ワークフロー'], score=80)), Article(is_valid_url=True, is_valid_content=True, content='## Deployment instructions\\n\\n### Azure resources\\n\\nTo deploy Azure resources for this project, you can use the provided [Bicep template](https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep/tree/main/infra/scenarios/template-langgraph). This template sets up the necessary resources for running the LangGraph application.\\n\\nTo quickly deploy the application, [Deploy to Azure button](https://learn.microsoft.com/azure/azure-resource-manager/templates/deploy-to-azure-button) is available. By clicking the following button, you can deploy the resources directly from the Azure portal:\\n\\n[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fks6088ts-labs%2Fbaseline-environment-on-azure-bicep%2Frefs%2Fheads%2Fmain%2Finfra%2Fscenarios%2Ftemplate-langgraph%2Fazuredeploy.json)\\n\\n### Docker Hub\\n\\nTo publish the docker image to Docker Hub, you need to [create access token](https://app.docker.com/settings/personal-access-tokens/create) and set the following secrets in the repository settings.\\n\\n```shell\\ngh secret set DOCKERHUB_USERNAME --body $DOCKERHUB_USERNAME\\ngh secret set DOCKERHUB_TOKEN --body $DOCKERHUB_TOKEN\\n```\\n\\n### Azure Static Web Apps\\n\\n```shell\\nRESOURCE_GROUP_NAME=your-resource-group-name\\nSWA_NAME=your-static-web-app-name\\n\\n# Create a static app\\naz staticwebapp create --name $SWA_NAME --resource-group $RESOURCE_GROUP_NAME\\n\\n# Retrieve the API key\\nAZURE_STATIC_WEB_APPS_API_TOKEN=$(az staticwebapp secrets list --name $SWA_NAME --query \"properties.apiKey\" -o tsv)\\n\\n# Set the API key as a GitHub secret\\ngh secret set AZURE_STATIC_WEB_APPS_API_TOKEN --body $AZURE_STATIC_WEB_APPS_API_TOKEN\\n```\\n\\nRefer to the following links for more information:\\n\\n- [Deploying to Azure Static Web App](https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-azure-static-web-app)\\n- [Create a static web app: `az staticwebapp create`](https://learn.microsoft.com/en-us/cli/azure/staticwebapp?view=azure-cli-latest#az-staticwebapp-create)\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md', structured_article=StructuredArticle(title='AzureリソースとDocker Hubのデプロイ手順', date='2023-10-01', summary='この記事では、AzureリソースのデプロイとDocker Hubへのコンテナイメージの公開手順を解説しています。Azure上でLangGraphアプリケーションを動作させるためのリソースは、Bicepテンプレートを使用して簡単に設定できます。また、Docker Hubには、個人アクセストークンを使ってリポジトリの設定で必要なシークレットを入力することで、コンテナを公開できます。', keywords=['Azure', 'Bicepテンプレート', 'Docker Hub', 'LangGraph', '静的ウェブアプリ'], score=85))] (agent.py:116)\n", + "2025-08-14 11:34:58,808 [ INFO] Mock notify with text: {0: {'url': 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'structured_article': {'title': 'LangGraph AI Agent Template', 'date': 'Not provided', 'summary': 'LangGraphは、複数のAIエージェントをコーディネートし、会話状態を保持しながら高度なワークフローを作成できるフレームワークです。このテンプレートプロジェクトでは、LangGraphを使用して様々なエージェントパターンとツール統合、および実際のユースケースを例示します。プロジェクトには、簡単なツール呼び出しエージェントから多エージェントシステムまでの実装例が含まれており、実世界のシナリオで情報を取得し構造化された応答を提供できるエージェントの構築方法を示します。', 'keywords': ['LangGraph', 'AIエージェント', 'テンプレート', 'ツール統合', 'ワークフロー'], 'score': 80}}, 1: {'url': 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md', 'structured_article': {'title': 'AzureリソースとDocker Hubのデプロイ手順', 'date': '2023-10-01', 'summary': 'この記事では、AzureリソースのデプロイとDocker Hubへのコンテナイメージの公開手順を解説しています。Azure上でLangGraphアプリケーションを動作させるためのリソースは、Bicepテンプレートを使用して簡単に設定できます。また、Docker Hubには、個人アクセストークンを使ってリポジトリの設定で必要なシークレットを入力することで、コンテナを公開できます。', 'keywords': ['Azure', 'Bicepテンプレート', 'Docker Hub', 'LangGraph', '静的ウェブアプリ'], 'score': 85}}} (notifiers.py:62)\n", + "2025-08-14 11:34:58,810 [ INFO] -------------------- (2710366794.py:23)\n", + "2025-08-14 11:34:58,810 [ INFO] Event: {'notify': {'input': AgentInputState(prompt='Please summarize the articles in Japanese briefly in 3 sentences.', id='8d053e30-be0c-41b4-bd15-bad270c16528', urls=['https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', 'https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md']), 'articles': [Article(is_valid_url=True, is_valid_content=True, content='# LangGraph AI Agent Template\\n\\nA comprehensive template project for building AI agents using [LangGraph](https://langchain-ai.github.io/langgraph/), demonstrating various agent patterns, tool integration, and real-world use cases.\\n\\n## What is LangGraph?\\n\\n[LangGraph](https://langchain-ai.github.io/langgraph/) is a framework built on top of [LangChain](https://python.langchain.com/) that enables you to create stateful, multi-agent workflows. Unlike traditional chatbots that handle single interactions, LangGraph allows you to build complex AI systems that can:\\n\\n- Maintain conversation state across multiple turns\\n- Use tools and external APIs\\n- Implement complex reasoning patterns\\n- Coordinate multiple AI agents\\n- Handle cyclical workflows and conditional logic\\n\\nThis template demonstrates these capabilities through practical examples using a fictional system called \"KABUTO\" for troubleshooting scenarios.\\n\\n## Project Overview\\n\\nThis project showcases different AI agent patterns and architectures, from simple tool-calling agents to complex multi-agent systems. The examples use a fictional technical support scenario to demonstrate how agents can retrieve information from multiple data sources and provide structured responses.\\n\\n### Why This Template Exists\\n\\nMost AI applications need to:\\n\\n1. **Access external information** - LLMs don\\'t have access to your specific data\\n2. **Use tools** - Perform actions beyond text generation\\n3. **Maintain context** - Remember previous interactions\\n4. **Handle complex workflows** - Break down tasks into manageable steps\\n\\nThis template provides working examples of all these patterns using LangGraph.\\n\\n## Prerequisites\\n\\n- [Python 3.10+](https://www.python.org/downloads/)\\n- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Modern Python package manager\\n- [GNU Make](https://www.gnu.org/software/make/) - For running common tasks\\n- [Docker](https://www.docker.com/) - For running vector databases (optional)\\n- Azure\\n - [Azure OpenAI](https://learn.microsoft.com/ja-jp/azure/ai-foundry/openai/overview) - LLM API\\n - [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/) - Data storage (optional)\\n\\n## Quick Start\\n\\n### 1. Environment Setup\\n\\n```shell\\n# Clone the repository\\ngit clone https://github.com/ks6088ts-labs/template-langgraph.git\\ncd template-langgraph\\n\\n# Install Python dependencies\\nuv sync --all-extras\\n\\n# Create environment configuration\\ncp .env.template .env\\n# Edit .env with your API keys (Azure OpenAI, etc.)\\n```\\n\\n### 2. Start Supporting Services (Optional)\\n\\nFor full functionality, start the vector databases:\\n\\n```shell\\n# Start Qdrant and Elasticsearch using Docker\\ndocker compose up -d\\n```\\n\\n### 3. Initialize Data Sources\\n\\n**Set up Qdrant vector database:**\\n\\n```shell\\nuv run python scripts/qdrant_operator.py add-documents \\\\\\n --collection-name qa_kabuto \\\\\\n --verbose\\n```\\n\\n**Set up Elasticsearch search index:**\\n\\n```shell\\nuv run python scripts/elasticsearch_operator.py create-index \\\\\\n --index-name docs_kabuto \\\\\\n --verbose\\n```\\n\\n## Project Structure\\n\\n### Core Components\\n\\n- **`data/`** - Sample data for the fictional KABUTO system (PDFs, FAQs, troubleshooting guides)\\n- **`template_langgraph/`** - Main Python package containing all agent implementations\\n- **`notebooks/`** - Jupyter notebooks with interactive examples and explanations\\n- **`scripts/`** - Command-line tools for running agents\\n\\n### Agent Examples (`template_langgraph/agents/`)\\n\\nThis project includes several agent implementations, each demonstrating different LangGraph patterns:\\n\\n#### 1. `kabuto_helpdesk_agent/` - **Start Here!**\\n\\nA simple agent using LangGraph\\'s prebuilt `create_react_agent` function. This is the best starting point for understanding the basics.\\n\\n**Key concepts:** ReAct pattern, tool calling, prebuilt agents\\n\\n#### 2. `chat_with_tools_agent/` - **Core Implementation**\\n\\nA manual implementation of the same logic as the helpdesk agent, showing how LangGraph workflows are built from scratch.\\n\\n**Key concepts:** Graph construction, state management, node functions, edges\\n\\n#### 3. `issue_formatter_agent/` - **Structured Output**\\n\\nDemonstrates how to get structured data from AI responses using Pydantic models.\\n\\n**Key concepts:** Structured output, data validation, response formatting\\n\\n#### 4. `task_decomposer_agent/` - **Planning & Decomposition**\\n\\nShows how to break down complex tasks into smaller, manageable steps.\\n\\n**Key concepts:** Task planning, multi-step reasoning, conditional workflows\\n\\n#### 5. `supervisor_agent/` - **Multi-Agent Coordination**\\n\\nImplements the supervisor pattern where one agent coordinates multiple specialized agents.\\n\\n**Key concepts:** Multi-agent systems, agent coordination, supervisor patterns\\n\\n### Supporting Modules\\n\\n- **`template_langgraph/llms/`** - LLM API wrappers (Azure OpenAI, etc.)\\n- **`template_langgraph/tools/`** - Tool implementations for search, data retrieval\\n- **`template_langgraph/internals/`** - Internal utilities and helper functions (CSV/PDF loaders, Otel wrappers, etc.)\\n\\n## Running the Examples\\n\\n### Option 1: LangGraph Studio (Recommended for Development)\\n\\n[LangGraph Studio](https://langchain-ai.github.io/langgraph/concepts/langgraph_studio/) provides a visual interface for developing and debugging agents:\\n\\n```shell\\nuv run langgraph dev\\n```\\n\\nThis opens a web interface where you can:\\n\\n- Visualize agent workflows\\n- Step through executions\\n- Debug state transitions\\n- Test different inputs\\n\\n![langgraph-studio.png](./images/langgraph-studio.png)\\n\\n### Option 2: Jupyter Notebooks (Best for Learning)\\n\\nInteractive notebooks with explanations and examples:\\n\\n```shell\\nuv run jupyter lab\\n# Navigate to http://localhost:8888 and open notebooks/*.ipynb\\n```\\n\\n![jupyterlab.png](./images/jupyterlab.png)\\n\\n### Option 3: Command Line (Quick development)\\n\\nRun agents from the terminal:\\n\\n```shell\\nuv run python scripts/agent_operator.py run \\\\\\n --name \"chat_with_tools_agent\" \\\\\\n --question \"KABUTO startup issue: screen flashes purple and system freezes\" \\\\\\n --verbose\\n```\\n\\nExample output showing the agent\\'s reasoning process:\\n\\n```text\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\', tool_calls=[\\n {\\'name\\': \\'search_elasticsearch\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}},\\n {\\'name\\': \\'search_qdrant\\', \\'args\\': {\\'keywords\\': \\'KABUTO startup purple flashing freeze\\'}}\\n])]}}\\n\\nEvent: {\\'tools\\': {\\'messages\\': [ToolMessage(content=\\'Found documentation about startup protocol...\\')]}}\\n\\nEvent: {\\'chat_with_tools\\': {\\'messages\\': [AIMessage(content=\\'\\n### Problem Analysis\\nThe purple screen flashing during KABUTO startup indicates a \"Shinobi Protocol\" initialization failure...\\n\\n### Solution\\n1. **Disconnect peripheral devices**: Unplug all connected devices for 5+ seconds\\n2. **Clear external clock cache**: This resolves clock synchronization issues\\n3. **Restart KABUTO**: Use the \"Dragon Ball\" button for 5+ seconds if needed\\n\\')]}}\\n```\\n\\n### Option 4: FastAPI (Production-ready)\\n\\nRun the FastAPI server to expose the agent as an API:\\n\\n```shell\\nuv run fastapi run \\\\\\n --host \"0.0.0.0\" \\\\\\n --port 8000 \\\\\\n --workers 4 \\\\\\n template_langgraph/services/fastapis/main.py\\n# Access the API at http://localhost:8000/docs via Swagger UI\\n```\\n\\nThis allows you to interact with the agent programmatically via HTTP requests.\\n\\n![fastapi.png](./images/fastapi.png)\\n\\n### Option 5: Streamlit (PoC demo)\\n\\nRun the Streamlit app to expose the agent as a web interface:\\n\\n```shell\\nuv run streamlit run \\\\\\n template_langgraph/services/streamlits/main.py\\n```\\n\\nDemonstration of the Streamlit app:\\n\\n[![streamlit.png](./images/streamlit.png)](https://youtu.be/undxBwyJ3Sc)\\n\\n## Key Concepts Demonstrated\\n\\n### 1. **ReAct Pattern** (Reasoning + Acting)\\n\\nThe foundation of modern AI agents - the ability to reason about what to do, take actions, and reason about the results.\\n\\n### 2. **Tool Calling**\\n\\nHow agents can use external functions to:\\n\\n- Search databases (Elasticsearch, Qdrant)\\n- Call APIs\\n- Process files\\n- Execute calculations\\n\\n### 3. **State Management**\\n\\nHow LangGraph maintains context across multiple interaction steps, enabling complex multi-turn conversations.\\n\\n### 4. **Conditional Workflows**\\n\\nUsing graph structures to create branching logic based on agent decisions or external conditions.\\n\\n### 5. **Multi-Agent Systems**\\n\\nCoordinating multiple specialized agents to handle complex tasks that require different expertise.\\n\\n## Data Sources Explained\\n\\nThe project uses fictional data about a system called \"KABUTO\" to demonstrate real-world scenarios:\\n\\n- **`data/docs_kabuto.pdf`** - Technical documentation (simulates user manuals)\\n- **`data/qa_kabuto.csv`** - FAQ database (simulates past support tickets)\\n- **`data/docs_kabuto.md`** - Additional documentation\\n\\nThis fictional data serves a purpose: it proves that the AI agents can work with information that isn\\'t in the LLM\\'s training data, demonstrating the value of retrieval-augmented generation (RAG).\\n\\n## Next Steps\\n\\n1. **Start with the basics**: Run the `kabuto_helpdesk_agent` example\\n2. **Understand the implementation**: Compare it with `chat_with_tools_agent`\\n3. **Explore advanced patterns**: Try the task decomposer and supervisor agents\\n4. **Build your own**: Use this template as a starting point for your use case\\n\\n## Learning Resources\\n\\n- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/)\\n- [LangChain Documentation](https://python.langchain.com/)\\n\\n## Architecture Examples\\n\\nThis template demonstrates several proven agent architectures:\\n\\n1. **Single Agent with Tools** - Basic tool-calling pattern\\n2. **ReAct Agent** - Reasoning and acting in loops\\n3. **Structured Output Agent** - Returning formatted data\\n4. **Planning Agent** - Breaking down complex tasks\\n5. **Supervisor Agent** - Coordinating multiple agents\\n\\nEach pattern is implemented with clear examples and documentation to help you understand when and how to use them.\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md', structured_article=StructuredArticle(title='LangGraph AI Agent Template', date='Not provided', summary='LangGraphは、複数のAIエージェントをコーディネートし、会話状態を保持しながら高度なワークフローを作成できるフレームワークです。このテンプレートプロジェクトでは、LangGraphを使用して様々なエージェントパターンとツール統合、および実際のユースケースを例示します。プロジェクトには、簡単なツール呼び出しエージェントから多エージェントシステムまでの実装例が含まれており、実世界のシナリオで情報を取得し構造化された応答を提供できるエージェントの構築方法を示します。', keywords=['LangGraph', 'AIエージェント', 'テンプレート', 'ツール統合', 'ワークフロー'], score=80)), Article(is_valid_url=True, is_valid_content=True, content='## Deployment instructions\\n\\n### Azure resources\\n\\nTo deploy Azure resources for this project, you can use the provided [Bicep template](https://github.com/ks6088ts-labs/baseline-environment-on-azure-bicep/tree/main/infra/scenarios/template-langgraph). This template sets up the necessary resources for running the LangGraph application.\\n\\nTo quickly deploy the application, [Deploy to Azure button](https://learn.microsoft.com/azure/azure-resource-manager/templates/deploy-to-azure-button) is available. By clicking the following button, you can deploy the resources directly from the Azure portal:\\n\\n[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fks6088ts-labs%2Fbaseline-environment-on-azure-bicep%2Frefs%2Fheads%2Fmain%2Finfra%2Fscenarios%2Ftemplate-langgraph%2Fazuredeploy.json)\\n\\n### Docker Hub\\n\\nTo publish the docker image to Docker Hub, you need to [create access token](https://app.docker.com/settings/personal-access-tokens/create) and set the following secrets in the repository settings.\\n\\n```shell\\ngh secret set DOCKERHUB_USERNAME --body $DOCKERHUB_USERNAME\\ngh secret set DOCKERHUB_TOKEN --body $DOCKERHUB_TOKEN\\n```\\n\\n### Azure Static Web Apps\\n\\n```shell\\nRESOURCE_GROUP_NAME=your-resource-group-name\\nSWA_NAME=your-static-web-app-name\\n\\n# Create a static app\\naz staticwebapp create --name $SWA_NAME --resource-group $RESOURCE_GROUP_NAME\\n\\n# Retrieve the API key\\nAZURE_STATIC_WEB_APPS_API_TOKEN=$(az staticwebapp secrets list --name $SWA_NAME --query \"properties.apiKey\" -o tsv)\\n\\n# Set the API key as a GitHub secret\\ngh secret set AZURE_STATIC_WEB_APPS_API_TOKEN --body $AZURE_STATIC_WEB_APPS_API_TOKEN\\n```\\n\\nRefer to the following links for more information:\\n\\n- [Deploying to Azure Static Web App](https://docs.github.com/en/actions/use-cases-and-examples/deploying/deploying-to-azure-static-web-app)\\n- [Create a static web app: `az staticwebapp create`](https://learn.microsoft.com/en-us/cli/azure/staticwebapp?view=azure-cli-latest#az-staticwebapp-create)\\n', url='https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md', structured_article=StructuredArticle(title='AzureリソースとDocker Hubのデプロイ手順', date='2023-10-01', summary='この記事では、AzureリソースのデプロイとDocker Hubへのコンテナイメージの公開手順を解説しています。Azure上でLangGraphアプリケーションを動作させるためのリソースは、Bicepテンプレートを使用して簡単に設定できます。また、Docker Hubには、個人アクセストークンを使ってリポジトリの設定で必要なシークレットを入力することで、コンテナを公開できます。', keywords=['Azure', 'Bicepテンプレート', 'Docker Hub', 'LangGraph', '静的ウェブアプリ'], score=85))]}} (2710366794.py:24)\n", + "2025-08-14 11:34:58,811 [ INFO] {\n", + " \"title\": \"LangGraph AI Agent Template\",\n", + " \"date\": \"Not provided\",\n", + " \"summary\": \"LangGraphは、複数のAIエージェントをコーディネートし、会話状態を保持しながら高度なワークフローを作成できるフレームワークです。このテンプレートプロジェクトでは、LangGraphを使用して様々なエージェントパターンとツール統合、および実際のユースケースを例示します。プロジェクトには、簡単なツール呼び出しエージェントから多エージェントシステムまでの実装例が含まれており、実世界のシナリオで情報を取得し構造化された応答を提供できるエージェントの構築方法を示します。\",\n", + " \"keywords\": [\n", + " \"LangGraph\",\n", + " \"AIエージェント\",\n", + " \"テンプレート\",\n", + " \"ツール統合\",\n", + " \"ワークフロー\"\n", + " ],\n", + " \"score\": 80\n", + "} (2710366794.py:28)\n", + "2025-08-14 11:34:58,812 [ INFO] {\n", + " \"title\": \"AzureリソースとDocker Hubのデプロイ手順\",\n", + " \"date\": \"2023-10-01\",\n", + " \"summary\": \"この記事では、AzureリソースのデプロイとDocker Hubへのコンテナイメージの公開手順を解説しています。Azure上でLangGraphアプリケーションを動作させるためのリソースは、Bicepテンプレートを使用して簡単に設定できます。また、Docker Hubには、個人アクセストークンを使ってリポジトリの設定で必要なシークレットを入力することで、コンテナを公開できます。\",\n", + " \"keywords\": [\n", + " \"Azure\",\n", + " \"Bicepテンプレート\",\n", + " \"Docker Hub\",\n", + " \"LangGraph\",\n", + " \"静的ウェブアプリ\"\n", + " ],\n", + " \"score\": 85\n", + "} (2710366794.py:28)\n" + ] + } + ], + "source": [ + "from uuid import uuid4\n", + "\n", + "from template_langgraph.agents.news_summarizer_agent.agent import NewsSummarizerAgent\n", + "from template_langgraph.agents.news_summarizer_agent.models import (\n", + " AgentInputState,\n", + " AgentState,\n", + " Article,\n", + ")\n", + "\n", + "graph = NewsSummarizerAgent().create_graph()\n", + "for event in graph.stream(\n", + " input=AgentState(\n", + " input=AgentInputState(\n", + " prompt=\"Please summarize the articles in Japanese briefly in 3 sentences.\",\n", + " id=str(uuid4()),\n", + " urls=\"https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/index.md,https://raw.githubusercontent.com/ks6088ts-labs/template-langgraph/refs/heads/main/docs/deployment.md\".split(\n", + " \",\"\n", + " ), # noqa: E501\n", + " ),\n", + " articles=[],\n", + " )\n", + "):\n", + " logger.info(\"-\" * 20)\n", + " logger.info(f\"Event: {event}\")\n", + "\n", + "articles: list[Article] = event[\"notify\"][\"articles\"]\n", + "for article in articles:\n", + " logger.info(f\"{article.structured_article.model_dump_json(indent=2)}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1b188112", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/supervisor_agent.ipynb b/notebooks/supervisor_agent.ipynb new file mode 100644 index 0000000..c6faca7 --- /dev/null +++ b/notebooks/supervisor_agent.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "1f4d669f", + "metadata": {}, + "outputs": [], + "source": [ + "import logging\n", + "\n", + "from dotenv import load_dotenv\n", + "\n", + "from template_langgraph.loggers import get_logger\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")\n", + "\n", + "logger = get_logger(__name__)\n", + "logger.setLevel(logging.DEBUG)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "21bd80ab", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:35:43,017 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='4abc5434-3c7e-4ff1-a7f0-691b252d3052'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'function': {'arguments': '{}', 'name': 'transfer_to_chatwithtoolsagent'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, name='SupervisorAgent', id='run--469834f0-3e80-436c-b626-a54eeb6a2636-0', tool_calls=[{'name': 'transfer_to_chatwithtoolsagent', 'args': {}, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred to ChatWithToolsAgent', name='transfer_to_chatwithtoolsagent', id='e4e1a0a1-0709-4d63-bac5-2ee706bab2f9', tool_call_id='call_r6vg5IHt2FC6wz6lFjZQqeeJ')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'SupervisorAgent': {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='4abc5434-3c7e-4ff1-a7f0-691b252d3052'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'function': {'arguments': '{}', 'name': 'transfer_to_chatwithtoolsagent'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, name='SupervisorAgent', id='run--469834f0-3e80-436c-b626-a54eeb6a2636-0', tool_calls=[{'name': 'transfer_to_chatwithtoolsagent', 'args': {}, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred to ChatWithToolsAgent', name='transfer_to_chatwithtoolsagent', id='e4e1a0a1-0709-4d63-bac5-2ee706bab2f9', tool_call_id='call_r6vg5IHt2FC6wz6lFjZQqeeJ')]}}\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:35:47,781 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='4abc5434-3c7e-4ff1-a7f0-691b252d3052'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'function': {'arguments': '{}', 'name': 'transfer_to_chatwithtoolsagent'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, name='SupervisorAgent', id='run--469834f0-3e80-436c-b626-a54eeb6a2636-0', tool_calls=[{'name': 'transfer_to_chatwithtoolsagent', 'args': {}, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred to ChatWithToolsAgent', name='transfer_to_chatwithtoolsagent', id='e4e1a0a1-0709-4d63-bac5-2ee706bab2f9', tool_call_id='call_r6vg5IHt2FC6wz6lFjZQqeeJ'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_nEX3JSMKSDmddjNOyH3tLSKx', 'function': {'arguments': '{\"keywords\": \"鬼灯 KABUTO 停止 原因 対策\"}', 'name': 'search_qdrant'}, 'type': 'function'}, {'index': 1, 'id': 'call_lLCACkDesXHLvbLvH2qNEHo8', 'function': {'arguments': '{\"keywords\": \"鬼灯 KABUTO 停止 原因 対策\"}', 'name': 'search_elasticsearch'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, id='run--a11d00c5-af3a-4c5b-a862-a426c0dc8fb1-0', tool_calls=[{'name': 'search_qdrant', 'args': {'keywords': '鬼灯 KABUTO 停止 原因 対策'}, 'id': 'call_nEX3JSMKSDmddjNOyH3tLSKx', 'type': 'tool_call'}, {'name': 'search_elasticsearch', 'args': {'keywords': '鬼灯 KABUTO 停止 原因 対策'}, 'id': 'call_lLCACkDesXHLvbLvH2qNEHo8', 'type': 'tool_call'}]), ToolMessage(content='\"[QdrantOutput(file_name=\\'./data/qa_kabuto.csv\\', content=\\'q: 特定のアプリケーション「鬼灯」を実行すると、KABUTOのファンが急に停止し、無音になります。 a: 「鬼灯」は、その特殊な演算処理において、KABUTOの冷却システム「風魔の術」を一時的に停止させ、内部エネルギーの流れを最適化する機能を持っています。これは異常ではありません。ただし、無音状態が15分以上続く場合は、過熱の可能性があるため、アプリケーションを強制終了し、KABUTO本体の電源を一度切ってから再起動してください。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0127 timestamp: 2025-08-03T10:13:02+09:00 user_message: 鬼灯実行中に過熱警告が表示され強制終了したい。\\'), QdrantOutput(file_name=\\'./data/reports_kabuto.csv\\', content=\\'error_code: KABUTO-0116 timestamp: 2025-07-28T10:12:05+09:00 user_message: 鬼灯実行中に無音状態が15分以上続き過熱が不安。\\')]\"', name='search_qdrant', id='beb88101-6360-40fe-b2f5-2111ba45cb3d', tool_call_id='call_nEX3JSMKSDmddjNOyH3tLSKx'), ToolMessage(content='\"[ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'docs_kabuto.md 2025-08-01\\\\\\\\n2 / 3\\\\\\\\nた場合、「虚無」エラーが表⽰され、ログインは拒否される。これは疲労やストレスによる精神状態の変化が原因で\\\\\\\\nある可能性があり、深呼吸による精神状態の安定化が解決策となる。\\\\\\\\n3.3 ネットワーク・通信\\\\\\\\nネットワークモジュール「隠れ蓑」は、外部からの不必要なスキャンを回避するため、デフォルトでステルスモード\\\\\\\\nで動作する。これにより、ネットワーク上の他のデバイスから認識されない状態となる。 KABUTO をネットワーク上\\\\\\\\nで可視化させるには、ネットワーク設定画⾯から「忍びの道」オプションを有効にする必要がある。\\\\\\\\n3.4 演算コア\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'る。これにより、漢字で表⽰されている特定のフォルダ名が、ひらがなとして読み取られる現象が発⽣する。この問\\\\\\\\n題を解消するには、システム設定にて「読み⽅優先モード」を⼀時的に無効化する必要がある。\\\\\\\\n4.2 ⼊⼒・ AI アシスタント\\\\\\\\n内蔵 AI アシスタント「ヤタガラス」は、ユーザーの⼊⼒内容を予測し、システムの基幹⾔語である「KABUTO 語」に\\\\\\\\n最適化しようとする機能を持つ。これにより、特定の⽂字が⾃動的にカタカナに変換される現象が発⽣する。この機\\\\\\\\n能を⼀時的に停⽌するには、⼊⼒中にCtrlキーとShiftキーを同時に押しながら「 KABUTO 」と⼊⼒する。\\\\\\\\n4.3 スクリーンショット機能\\'), ElasticsearchOutput(file_name=\\'docs_kabuto.pdf\\', content=\\'「⻤灯」の実⾏中は、冷却システムが⼀時的に停⽌し、無⾳となる。これは内部エネルギーの流れを最適化するため\\\\\\\\nの仕様であり、異常ではない。ただし、この無⾳状態が 15 分以上継続する場合は、過熱の可能性があるため、アプリ\\\\\\\\nケーションの強制終了およびシステムの再起動が推奨される。\\\\\\\\n第 3 章 ソフトウェア・オペレーション\\\\\\\\n3.1 起動プロトコル\\\\\\\\nKABUTO の起動シーケンスは、「シノビ・プロトコル」に基づき実⾏される。このプロトコルの初期化フェーズで、\\\\\\\\n内部クロックと接続された外部周辺機器のクロックとの同期に失敗した場合、画⾯全体が紫⾊に点滅し、システムが\\')]\"', name='search_elasticsearch', id='fad30499-69ba-491c-a182-86e767c0fbaf', tool_call_id='call_lLCACkDesXHLvbLvH2qNEHo8')]} (agent.py:86)\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "--------------------\n", + "Event: {'ChatWithToolsAgent': {'messages': [AIMessage(content='KABUTOが「鬼灯」を実行した際に急停止する原因と対策について以下の情報が得られました。\\n\\n### 原因:\\n1. **冷却システムの一時停止**: 「鬼灯」は特異な演算処理を含んでおり、KABUTOの冷却システム「風魔の術」を一時的に停止させ、内部エネルギーの流れを最適化する機能を持っています。このため、無音状態になることがありますが、異常ではありません。\\n\\n2. **過熱の可能性**: 無音状態が15分以上続く場合、過熱の可能性があります。過熱による問題が発生し、強制終了が必要となる場合があります。\\n\\n### 対策:\\n1. **強制終了と再起動**: 無音状態が15分以上続く場合は、アプリケーションを強制終了し、KABUTO本体の電源を一度切ってから再起動してください。\\n\\n2. **深呼吸による精神安定化**: ストレスや過剰な疲労が原因でシステムが「虚無」状態となり、ログインが拒否されることがあります。深呼吸により精神状態の安定化を図ることが解決策となり得ます。\\n\\nこれらの情報をもとに、KABUTOの動作を再確認し問題解決を試みてください。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, id='run--0fc6ad63-b83d-4cfb-bfba-ff47b68621c6-0'), AIMessage(content='Transferring back to SupervisorAgent', additional_kwargs={}, response_metadata={'__is_handoff_back': True}, name='ChatWithToolsAgent', id='d5630633-5f99-48dc-af51-57e2da6ce49f', tool_calls=[{'name': 'transfer_back_to_supervisoragent', 'args': {}, 'id': '2a7cf5ab-a2e2-41b7-b36b-d363e4375bb3', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred back to SupervisorAgent', name='transfer_back_to_supervisoragent', id='16172cb8-a612-45e5-a453-12b23dffe48f', tool_call_id='2a7cf5ab-a2e2-41b7-b36b-d363e4375bb3')]}}\n", + "--------------------\n", + "Event: {'SupervisorAgent': {'messages': [HumanMessage(content='「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。', additional_kwargs={}, response_metadata={}, id='4abc5434-3c7e-4ff1-a7f0-691b252d3052'), AIMessage(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'function': {'arguments': '{}', 'name': 'transfer_to_chatwithtoolsagent'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, name='SupervisorAgent', id='run--469834f0-3e80-436c-b626-a54eeb6a2636-0', tool_calls=[{'name': 'transfer_to_chatwithtoolsagent', 'args': {}, 'id': 'call_r6vg5IHt2FC6wz6lFjZQqeeJ', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred to ChatWithToolsAgent', name='transfer_to_chatwithtoolsagent', id='e4e1a0a1-0709-4d63-bac5-2ee706bab2f9', tool_call_id='call_r6vg5IHt2FC6wz6lFjZQqeeJ'), AIMessage(content='KABUTOが「鬼灯」を実行した際に急停止する原因と対策について以下の情報が得られました。\\n\\n### 原因:\\n1. **冷却システムの一時停止**: 「鬼灯」は特異な演算処理を含んでおり、KABUTOの冷却システム「風魔の術」を一時的に停止させ、内部エネルギーの流れを最適化する機能を持っています。このため、無音状態になることがありますが、異常ではありません。\\n\\n2. **過熱の可能性**: 無音状態が15分以上続く場合、過熱の可能性があります。過熱による問題が発生し、強制終了が必要となる場合があります。\\n\\n### 対策:\\n1. **強制終了と再起動**: 無音状態が15分以上続く場合は、アプリケーションを強制終了し、KABUTO本体の電源を一度切ってから再起動してください。\\n\\n2. **深呼吸による精神安定化**: ストレスや過剰な疲労が原因でシステムが「虚無」状態となり、ログインが拒否されることがあります。深呼吸により精神状態の安定化を図ることが解決策となり得ます。\\n\\nこれらの情報をもとに、KABUTOの動作を再確認し問題解決を試みてください。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_8458c98457'}, id='run--0fc6ad63-b83d-4cfb-bfba-ff47b68621c6-0'), AIMessage(content='Transferring back to SupervisorAgent', additional_kwargs={}, response_metadata={'__is_handoff_back': True}, name='ChatWithToolsAgent', id='d5630633-5f99-48dc-af51-57e2da6ce49f', tool_calls=[{'name': 'transfer_back_to_supervisoragent', 'args': {}, 'id': '2a7cf5ab-a2e2-41b7-b36b-d363e4375bb3', 'type': 'tool_call'}]), ToolMessage(content='Successfully transferred back to SupervisorAgent', name='transfer_back_to_supervisoragent', id='16172cb8-a612-45e5-a453-12b23dffe48f', tool_call_id='2a7cf5ab-a2e2-41b7-b36b-d363e4375bb3'), AIMessage(content='KABUTOが「鬼灯」を実行した際に急停止する原因と対策について以下の情報を提供いたします。\\n\\n### 原因:\\n1. **冷却システムの一時停止**: 特定の処理が冷却システムを止めることがあり、これによりシステムが応答しなくなることがあります。\\n\\n2. **過熱の可能性**: 無音状態が長く続くとシステムが過熱する可能性があります。\\n\\n### 対策:\\n1. **強制終了と再起動**: 15分以上続く場合は、強制終了後、電源を切り、再起動してください。\\n\\n2. **精神安定のための深呼吸**: ストレス緩和を目的として深呼吸により精神状態の安定化を図るのも有効です。\\n\\nこれにより、問題が解決するかどうか試みてください。', additional_kwargs={}, response_metadata={'finish_reason': 'stop', 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_ee1d74bde0'}, name='SupervisorAgent', id='run--213f703a-73c9-44bf-ad00-b17ce193fc34-0')]}}\n" + ] + } + ], + "source": [ + "from template_langgraph.agents.supervisor_agent.agent import graph\n", + "\n", + "question = \"「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。\"\n", + "\n", + "# Stream the agent's response to the question\n", + "for event in graph.stream(\n", + " input={\n", + " \"messages\": [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": question,\n", + " }\n", + " ],\n", + " }\n", + "):\n", + " print(\"-\" * 20)\n", + " print(f\"Event: {event}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/task_decomposer_agent.ipynb b/notebooks/task_decomposer_agent.ipynb new file mode 100644 index 0000000..815afea --- /dev/null +++ b/notebooks/task_decomposer_agent.ipynb @@ -0,0 +1,113 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "0e39a91d", + "metadata": {}, + "outputs": [], + "source": [ + "import logging\n", + "\n", + "from dotenv import load_dotenv\n", + "\n", + "from template_langgraph.loggers import get_logger\n", + "\n", + "_ = load_dotenv(\n", + " override=True,\n", + " verbose=True,\n", + ")\n", + "\n", + "logger = get_logger(__name__)\n", + "logger.setLevel(logging.DEBUG)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "1e620cca", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "2025-08-14 11:36:29,578 [ INFO] Chatting with tools using state: {'messages': [HumanMessage(content='KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='3bd74e98-ae20-427e-90de-4b38234826cb')]} (agent.py:41)\n", + "2025-08-14 11:36:34,105 [ INFO] Decomposed tasks: tasks=[Task(title='Investigate KABUTO Login Issue', description=\"Investigate the login issue experienced by Yamada Taro with the KABUTO system. Analyze the situation where the system displays text '虚無' instead of the login interface.\", priority=1, due_date='2023-10-31', assigned_to='Okamoto Taro'), Task(title='Identify Possible Causes', description='Compile a list of potential reasons for the login issue, including system errors, network problems, and authentication failures related to Windows 11 compatibility.', priority=2, due_date='2023-10-25', assigned_to='Okamoto Taro'), Task(title='Check System Logs', description=\"Access KABUTO's system logs to identify any anomalies that might be causing the login issue. Pay special attention to logs generated during Taro’s login attempts.\", priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Test Login Process', description='Conduct tests on the KABUTO system using different accounts and devices to determine if the issue is isolated or widespread.', priority=3, due_date='2023-10-27', assigned_to='Okamoto Taro'), Task(title='Consult IT Support', description='Coordinate with IT support to get their insights on the system configuration and any recent updates that could have affected the login process.', priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Compile Report', description='Compile a detailed report outlining the findings of the investigation, including potential solutions to resolve the login issue for Yamada Taro and ensure system stability.', priority=1, due_date='2023-11-03', assigned_to='Okamoto Taro')] (agent.py:47)\n", + "2025-08-14 11:36:34,106 [ INFO] -------------------- (2530209947.py:15)\n", + "2025-08-14 11:36:34,107 [ INFO] Event: {'chat': {'messages': [HumanMessage(content='KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='3bd74e98-ae20-427e-90de-4b38234826cb')], 'task_list': TaskList(tasks=[Task(title='Investigate KABUTO Login Issue', description=\"Investigate the login issue experienced by Yamada Taro with the KABUTO system. Analyze the situation where the system displays text '虚無' instead of the login interface.\", priority=1, due_date='2023-10-31', assigned_to='Okamoto Taro'), Task(title='Identify Possible Causes', description='Compile a list of potential reasons for the login issue, including system errors, network problems, and authentication failures related to Windows 11 compatibility.', priority=2, due_date='2023-10-25', assigned_to='Okamoto Taro'), Task(title='Check System Logs', description=\"Access KABUTO's system logs to identify any anomalies that might be causing the login issue. Pay special attention to logs generated during Taro’s login attempts.\", priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Test Login Process', description='Conduct tests on the KABUTO system using different accounts and devices to determine if the issue is isolated or widespread.', priority=3, due_date='2023-10-27', assigned_to='Okamoto Taro'), Task(title='Consult IT Support', description='Coordinate with IT support to get their insights on the system configuration and any recent updates that could have affected the login process.', priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Compile Report', description='Compile a detailed report outlining the findings of the investigation, including potential solutions to resolve the login issue for Yamada Taro and ensure system stability.', priority=1, due_date='2023-11-03', assigned_to='Okamoto Taro')])}} (2530209947.py:16)\n", + "2025-08-14 11:36:34,108 [ INFO] -------------------- (2530209947.py:17)\n", + "2025-08-14 11:36:34,108 [ INFO] Event: {'chat': {'messages': [HumanMessage(content='KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='3bd74e98-ae20-427e-90de-4b38234826cb')], 'task_list': TaskList(tasks=[Task(title='Investigate KABUTO Login Issue', description=\"Investigate the login issue experienced by Yamada Taro with the KABUTO system. Analyze the situation where the system displays text '虚無' instead of the login interface.\", priority=1, due_date='2023-10-31', assigned_to='Okamoto Taro'), Task(title='Identify Possible Causes', description='Compile a list of potential reasons for the login issue, including system errors, network problems, and authentication failures related to Windows 11 compatibility.', priority=2, due_date='2023-10-25', assigned_to='Okamoto Taro'), Task(title='Check System Logs', description=\"Access KABUTO's system logs to identify any anomalies that might be causing the login issue. Pay special attention to logs generated during Taro’s login attempts.\", priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Test Login Process', description='Conduct tests on the KABUTO system using different accounts and devices to determine if the issue is isolated or widespread.', priority=3, due_date='2023-10-27', assigned_to='Okamoto Taro'), Task(title='Consult IT Support', description='Coordinate with IT support to get their insights on the system configuration and any recent updates that could have affected the login process.', priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Compile Report', description='Compile a detailed report outlining the findings of the investigation, including potential solutions to resolve the login issue for Yamada Taro and ensure system stability.', priority=1, due_date='2023-11-03', assigned_to='Okamoto Taro')])}} (2530209947.py:18)\n", + "2025-08-14 11:36:34,109 [ INFO] Handling human feedback with state: {'messages': [HumanMessage(content='KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。', additional_kwargs={}, response_metadata={}, id='3bd74e98-ae20-427e-90de-4b38234826cb')], 'task_list': TaskList(tasks=[Task(title='Investigate KABUTO Login Issue', description=\"Investigate the login issue experienced by Yamada Taro with the KABUTO system. Analyze the situation where the system displays text '虚無' instead of the login interface.\", priority=1, due_date='2023-10-31', assigned_to='Okamoto Taro'), Task(title='Identify Possible Causes', description='Compile a list of potential reasons for the login issue, including system errors, network problems, and authentication failures related to Windows 11 compatibility.', priority=2, due_date='2023-10-25', assigned_to='Okamoto Taro'), Task(title='Check System Logs', description=\"Access KABUTO's system logs to identify any anomalies that might be causing the login issue. Pay special attention to logs generated during Taro’s login attempts.\", priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Test Login Process', description='Conduct tests on the KABUTO system using different accounts and devices to determine if the issue is isolated or widespread.', priority=3, due_date='2023-10-27', assigned_to='Okamoto Taro'), Task(title='Consult IT Support', description='Coordinate with IT support to get their insights on the system configuration and any recent updates that could have affected the login process.', priority=2, due_date='2023-10-26', assigned_to='Okamoto Taro'), Task(title='Compile Report', description='Compile a detailed report outlining the findings of the investigation, including potential solutions to resolve the login issue for Yamada Taro and ensure system stability.', priority=1, due_date='2023-11-03', assigned_to='Okamoto Taro')])} (agent.py:52)\n", + "2025-08-14 11:36:34,109 [ INFO] -------------------- (2530209947.py:15)\n", + "2025-08-14 11:36:34,109 [ INFO] Event: {'__interrupt__': (Interrupt(value=\"Type your feedback. If you want to end the conversation, type 'end'.\", id='f897eec7c7c8ae85cd90991bd25cad4e'),)} (2530209947.py:16)\n", + "2025-08-14 11:36:34,110 [ INFO] -------------------- (2530209947.py:17)\n", + "2025-08-14 11:36:34,110 [ INFO] Event: {'__interrupt__': (Interrupt(value=\"Type your feedback. If you want to end the conversation, type 'end'.\", id='f897eec7c7c8ae85cd90991bd25cad4e'),)} (2530209947.py:18)\n" + ] + } + ], + "source": [ + "from template_langgraph.agents.task_decomposer_agent.agent import TaskDecomposerAgent\n", + "\n", + "# Create an instance of the agent\n", + "graph = TaskDecomposerAgent().create_graph()\n", + "for event in graph.stream(\n", + " input={\n", + " \"messages\": [\n", + " {\n", + " \"role\": \"user\",\n", + " \"content\": \"KABUTOにログインできない。パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。\", # noqa: E501\n", + " }\n", + " ],\n", + " }\n", + "):\n", + " logger.info(\"-\" * 20)\n", + " logger.info(f\"Event: {event}\")\n", + " logger.info(\"-\" * 20)\n", + " logger.info(f\"Event: {event}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c6c68866", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'__interrupt__': (Interrupt(value=\"Type your feedback. If you want to end the conversation, type 'end'.\", id='f897eec7c7c8ae85cd90991bd25cad4e'),)}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "event" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.0" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/scripts/test_all.sh b/scripts/test_all.sh deleted file mode 100644 index 452b154..0000000 --- a/scripts/test_all.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -# Stop on errors, undefined variables, and pipe failures -set -euo pipefail - -# Run Docker Compose to set up the environment -docker compose up -d --wait - -# Qdrant -COLLECTION_NAME="qa_kabuto" -uv run python scripts/qdrant_operator.py --help -uv run python scripts/qdrant_operator.py delete-collection --collection-name $COLLECTION_NAME --verbose -uv run python scripts/qdrant_operator.py add-documents --collection-name $COLLECTION_NAME --verbose -uv run python scripts/qdrant_operator.py search-documents --collection-name $COLLECTION_NAME --verbose --question "「鬼灯」を実行すると、KABUTOが急に停止します。原因と対策を教えてください。" - -# Elasticsearch -INDEX_NAME="docs_kabuto" -uv run python scripts/elasticsearch_operator.py --help -uv run python scripts/elasticsearch_operator.py delete-index --index-name $INDEX_NAME --verbose -uv run python scripts/elasticsearch_operator.py create-index --index-name $INDEX_NAME --verbose -uv run python scripts/elasticsearch_operator.py add-documents --index-name $INDEX_NAME --verbose -uv run python scripts/elasticsearch_operator.py search-documents --index-name $INDEX_NAME --verbose --query "禅モード" - -# Azure Cosmos DB NoSQL -uv run python scripts/cosmosdb_operator.py --help -uv run python scripts/cosmosdb_operator.py add-documents --verbose -uv run python scripts/cosmosdb_operator.py similarity-search --verbose --query "禅モード" --k 3 - -# Agents - -## Draw agent graph -mkdir -p generated -AGENT_NAMES=( - "chat_with_tools_agent" - "issue_formatter_agent" - "kabuto_helpdesk_agent" - "task_decomposer_agent" - "news_summarizer_agent" -) -for AGENT_NAME in "${AGENT_NAMES[@]}"; do - uv run python scripts/agent_operator.py png --name "$AGENT_NAME" --verbose --output "generated/${AGENT_NAME}.png" -done - -## Run agents -# An array of pairs of agent names and questions -NAME_QUESTION_ARRAY=( - "chat_with_tools_agent:KABUTOの起動時に、画面全体が紫色に点滅し、システムがフリーズします。KABUTO のマニュアルから、関連する情報を取得したり過去のシステムのトラブルシュート事例が蓄積されたデータベースから、関連する情報を取得して質問に答えてください" - "issue_formatter_agent:KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" - "kabuto_helpdesk_agent:天狗のいたずら という現象について KABUTO のマニュアルから、関連する情報を取得したり過去のシステムのトラブルシュート事例が蓄積されたデータベースから、関連する情報を取得して質問に答えてください" - "task_decomposer_agent:KABUTOにログインできない!パスワードは合ってるはずなのに…若手社員である山田太郎は、Windows 11 を立ち上げ、日課のように自社の業務システムKABUTOのログイン画面を開きます。しかし、そこには、意味をなさない「虚無」という文字だけがただひっそりと表示されていたのです。これは質問でもあり不具合の報告でもあります。岡本太郎さんに本件調査依頼します。" -) -for NAME_QUESTION in "${NAME_QUESTION_ARRAY[@]}"; do - IFS=':' read -r AGENT_NAME QUESTION <<< "$NAME_QUESTION" - echo "Running agent: $AGENT_NAME with question: $QUESTION" - uv run python scripts/agent_operator.py run --name "$AGENT_NAME" --verbose --question "$QUESTION" -done - -# Clean up Docker Compose environment -docker compose down --remove-orphans diff --git a/template_langgraph/agents/supervisor_agent/agent.py b/template_langgraph/agents/supervisor_agent/agent.py index b3e1292..fed4c34 100644 --- a/template_langgraph/agents/supervisor_agent/agent.py +++ b/template_langgraph/agents/supervisor_agent/agent.py @@ -33,4 +33,4 @@ def __init__(self): ) -graph = SupervisorAgent().agent +graph = SupervisorAgent().agent.compile()