Skip to content

Commit d5c4e52

Browse files
committed
update docs
1 parent f2fdeea commit d5c4e52

File tree

6 files changed

+68
-20
lines changed

6 files changed

+68
-20
lines changed

.env.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ELASTICSEARCH_URL="http://localhost:9200"
3333
DIFY_API_URL="https://api.dify.ai/v1"
3434
DIFY_API_KEY="xxx"
3535

36-
## Cosmos DB Settings
36+
## Azure Cosmos DB Settings
3737
COSMOSDB_HOST="https://xxx.documents.azure.com:443/"
3838
COSMOSDB_KEY="xxx"
3939
COSMOSDB_DATABASE_NAME="template_langgraph"

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,11 @@ langgraph-studio: ## run LangGraph Studio
119119
.PHONY: fastapi-dev
120120
fastapi-dev: ## run FastAPI
121121
uv run fastapi dev ./template_langgraph/services/fastapis/main.py
122+
123+
.PHONY: fastapi
124+
fastapi: ## run FastAPI in production mode
125+
uv run fastapi run \
126+
--host "0.0.0.0" \
127+
--port 8000 \
128+
--workers 4 \
129+
template_langgraph/services/fastapis/main.py

docs/images/fastapi.png

205 KB
Loading

docs/index.ja.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
- [uv](https://docs.astral.sh/uv/getting-started/installation/) - モダンな Python パッケージマネージャー
3636
- [GNU Make](https://www.gnu.org/software/make/) - 一般的なタスクの実行用
3737
- [Docker](https://www.docker.com/) - ベクターデータベースの実行用(オプション)
38+
- Azure
39+
- [Azure OpenAI](https://learn.microsoft.com/ja-jp/azure/ai-foundry/openai/overview) - LLM API
40+
- [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/) - データストレージ(オプション)
3841

3942
## クイックスタート
4043

@@ -129,7 +132,7 @@ Pydantic モデルを使用して AI 応答から構造化データを取得す
129132
- **`template_langgraph/tools/`** - 検索、データ取得用ツール実装
130133
- **`template_langgraph/utilities/`** - ドキュメント読み込みと処理用ヘルパー関数
131134

132-
## 例の実行
135+
## サンプルコードの実行
133136

134137
### オプション 1: LangGraph Studio(開発用推奨)
135138

@@ -159,7 +162,7 @@ uv run jupyter lab
159162

160163
![jupyterlab.png](./images/jupyterlab.png)
161164

162-
### オプション 3: コマンドライン(本番環境的
165+
### オプション 3: コマンドライン(クイックな開発
163166

164167
ターミナルからエージェントを実行:
165168

@@ -191,6 +194,23 @@ KABUTO起動時の紫画面点滅は「忍者プロトコル」初期化エラ
191194
')]}}
192195
```
193196

197+
### オプション 4: FastAPI サーバー(プロダクションレディ)
198+
199+
FastAPI サーバーを実行して、エージェントを API として公開:
200+
201+
```shell
202+
uv run fastapi run \
203+
--host "0.0.0.0" \
204+
--port 8000 \
205+
--workers 4 \
206+
template_langgraph/services/fastapis/main.py
207+
# http://localhost:8000/docs を開いて Swagger UI 経由で API にアクセス
208+
```
209+
210+
これにより、HTTP リクエストを介してプログラム的にエージェントと対話できます。
211+
212+
![fastapi.png](./images/fastapi.png)
213+
194214
## 実演されている主要概念
195215

196216
### 1. **ReAct パターン**(推論 + 行動)
@@ -237,8 +257,8 @@ LangGraph が複数のインタラクションステップにわたってコン
237257

238258
## 学習リソース
239259

240-
- [LangGraph 文書](https://langchain-ai.github.io/langgraph/)
241-
- [LangChain 文書](https://python.langchain.com/)
260+
- [LangGraph 公式ドキュメント](https://langchain-ai.github.io/langgraph/)
261+
- [LangChain 公式ドキュメント](https://python.langchain.com/)
242262

243263
## アーキテクチャの例
244264

docs/index.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ This template provides working examples of all these patterns using LangGraph.
3535
- [uv](https://docs.astral.sh/uv/getting-started/installation/) - Modern Python package manager
3636
- [GNU Make](https://www.gnu.org/software/make/) - For running common tasks
3737
- [Docker](https://www.docker.com/) - For running vector databases (optional)
38+
- Azure
39+
- [Azure OpenAI](https://learn.microsoft.com/ja-jp/azure/ai-foundry/openai/overview) - LLM API
40+
- [Azure Cosmos DB](https://learn.microsoft.com/ja-jp/azure/cosmos-db/) - Data storage (optional)
3841

3942
## Quick Start
4043

@@ -159,7 +162,7 @@ uv run jupyter lab
159162

160163
![jupyterlab.png](./images/jupyterlab.png)
161164

162-
### Option 3: Command Line (Production-like)
165+
### Option 3: Command Line (Quick development)
163166

164167
Run agents from the terminal:
165168

@@ -191,6 +194,23 @@ The purple screen flashing during KABUTO startup indicates a "Shinobi Protocol"
191194
')]}}
192195
```
193196

197+
### Option 4: FastAPI (Production-ready)
198+
199+
Run the FastAPI server to expose the agent as an API:
200+
201+
```shell
202+
uv run fastapi run \
203+
--host "0.0.0.0" \
204+
--port 8000 \
205+
--workers 4 \
206+
template_langgraph/services/fastapis/main.py
207+
# Access the API at http://localhost:8000/docs via Swagger UI
208+
```
209+
210+
This allows you to interact with the agent programmatically via HTTP requests.
211+
212+
![fastapi.png](./images/fastapi.png)
213+
194214
## Key Concepts Demonstrated
195215

196216
### 1. **ReAct Pattern** (Reasoning + Acting)

template_langgraph/services/fastapis/routers/agents.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ class RunChatWithToolsAgentResponse(BaseModel):
3232
async def run_chat_with_tools_agent(
3333
request: RunChatWithToolsAgentRequest,
3434
) -> RunChatWithToolsAgentResponse:
35-
async for event in chat_with_tools_agent.astream(
36-
input=AgentState(
37-
messages=[
38-
{
39-
"role": "user",
40-
"content": request.question,
41-
},
42-
],
43-
),
44-
config={
45-
"recursion_limit": 30,
46-
},
47-
):
48-
logger.debug(f"Event received: {event}")
4935
try:
36+
async for event in chat_with_tools_agent.astream(
37+
input=AgentState(
38+
messages=[
39+
{
40+
"role": "user",
41+
"content": request.question,
42+
},
43+
],
44+
),
45+
config={
46+
"recursion_limit": 30,
47+
},
48+
):
49+
logger.debug(f"Event received: {event}")
5050
response = event["chat_with_tools"]["messages"][0].content
5151
return RunChatWithToolsAgentResponse(response=response)
5252
except Exception as e:

0 commit comments

Comments
 (0)