Skip to content

Commit 8e96770

Browse files
committed
manual fix
1 parent 4cf9e8f commit 8e96770

File tree

16 files changed

+452
-323
lines changed

16 files changed

+452
-323
lines changed

docs/index.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,48 +204,48 @@ az resource update \
204204

205205
```bash
206206
# エージェントを作成
207-
python scripts/agents.py create-agent "研究アシスタント" --description "研究をサポートするAIアシスタント" --instructions "あなたは研究者をサポートするAIアシスタントです。質問に対して詳細で正確な回答を提供してください。"
207+
uv run python scripts/agents_azure_ai_foundry.py create-agent "研究アシスタント" --description "研究をサポートするAIアシスタント" --instructions "あなたは研究者をサポートするAIアシスタントです。質問に対して詳細で正確な回答を提供してください。"
208208

209209
# エージェント一覧を取得
210-
python scripts/agents.py list-agents
210+
uv run python scripts/agents_azure_ai_foundry.py list-agents
211211

212212
# エージェントの詳細を取得
213-
python scripts/agents.py get-agent <agent_id>
213+
uv run python scripts/agents_azure_ai_foundry.py get-agent <agent_id>
214214

215215
# エージェントとチャット
216-
python scripts/agents.py chat <agent_id> "機械学習の最新トレンドについて教えてください"
216+
uv run python scripts/agents_azure_ai_foundry.py chat <agent_id> "機械学習の最新トレンドについて教えてください"
217217

218218
# エージェントを削除
219-
python scripts/agents.py delete-agent <agent_id>
219+
uv run python scripts/agents_azure_ai_foundry.py delete-agent <agent_id>
220220
```
221221

222222
### LangGraph Agent
223223

224-
LangGraphベースのエージェントAPIを使用した対話型AIアシスタント。ツール呼び出し機能を持つシンプルなエージェントワークフローを実装しています。
224+
LangGraph ベースのエージェント API を使用した対話型 AI アシスタント。ツール呼び出し機能を持つシンプルなエージェントワークフローを実装しています。
225225

226226
#### CLI 実行例
227227

228228
```bash
229229
# ヘルプ
230-
python scripts/langgraph_agent.py --help
230+
uv run python scripts/agents_langgraph.py --help
231231

232232
# エージェントとチャット
233-
python scripts/langgraph_agent.py chat "こんにちは!今何時ですか?"
233+
uv run python scripts/agents_langgraph.py chat "こんにちは!今何時ですか?"
234234

235235
# スレッドIDを指定してチャット(会話の継続)
236-
python scripts/langgraph_agent.py chat "前回の続きを教えてください" --thread-id "12345-67890-abcdef"
236+
uv run python scripts/agents_langgraph.py chat "前回の続きを教えてください" --thread-id "12345-67890-abcdef"
237237

238238
# 詳細情報付きでチャット
239-
python scripts/langgraph_agent.py chat "2 + 2 × 3 を計算してください" --verbose
239+
uv run python scripts/agents_langgraph.py chat "2 + 2 × 3 を計算してください" --verbose
240240

241241
# 対話モード
242-
python scripts/langgraph_agent.py interactive
242+
uv run python scripts/agents_langgraph.py interactive
243243

244244
# 利用可能なツール一覧
245-
python scripts/langgraph_agent.py tools
245+
uv run python scripts/agents_langgraph.py tools
246246

247247
# デモモード(サンプル質問のテスト)
248-
python scripts/langgraph_agent.py demo
248+
uv run python scripts/agents_langgraph.py demo
249249
```
250250

251251
#### API エンドポイント

scripts/agents.py renamed to scripts/agents_azure_ai_foundry.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/env python
2-
# filepath: /home/runner/work/template-fastapi/template-fastapi/scripts/agents.py
3-
41
import json
52

63
import typer
Lines changed: 47 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
#!/usr/bin/env python
2-
# filepath: /home/runner/work/template-fastapi/template-fastapi/scripts/langgraph_agent.py
3-
41
"""LangGraph Agent CLI tool."""
52

6-
import json
7-
from typing import Optional
8-
93
import typer
104
from rich.console import Console
115
from rich.markdown import Markdown
126
from rich.panel import Panel
137

14-
from template_fastapi.core.langgraph.agent import LangGraphAgent
15-
from template_fastapi.core.langgraph.tools import get_tools
8+
from template_fastapi.internals.langgraph.agents import LangGraphAgent
9+
from template_fastapi.internals.langgraph.tools import get_tools
1610

1711
app = typer.Typer()
1812
console = Console()
@@ -21,66 +15,58 @@
2115
@app.command()
2216
def chat(
2317
message: str = typer.Argument(..., help="メッセージ"),
24-
thread_id: Optional[str] = typer.Option(None, "--thread-id", "-t", help="スレッドID(会話の継続用)"),
18+
thread_id: str | None = typer.Option(None, "--thread-id", "-t", help="スレッドID(会話の継続用)"),
2519
verbose: bool = typer.Option(False, "--verbose", "-v", help="詳細な情報を表示"),
2620
):
2721
"""LangGraphエージェントとチャットする"""
2822
console.print("[bold green]LangGraphエージェントとチャットします[/bold green]")
2923
console.print(f"メッセージ: {message}")
30-
24+
3125
if thread_id:
3226
console.print(f"スレッドID: {thread_id}")
3327
else:
3428
console.print("新しいスレッドを作成します")
35-
29+
3630
try:
3731
# Initialize the LangGraph agent
3832
agent = LangGraphAgent()
39-
33+
4034
# Show loading message
4135
with console.status("[bold green]エージェントが応答を生成中...", spinner="dots"):
4236
result = agent.chat(message=message, thread_id=thread_id)
43-
37+
4438
# Display results
45-
console.print("\n" + "="*50)
39+
console.print("\n" + "=" * 50)
4640
console.print("[bold blue]チャット結果[/bold blue]")
47-
console.print("="*50)
48-
41+
console.print("=" * 50)
42+
4943
# Display user message
50-
user_panel = Panel(
51-
message,
52-
title="[bold cyan]あなた[/bold cyan]",
53-
border_style="cyan"
54-
)
44+
user_panel = Panel(message, title="[bold cyan]あなた[/bold cyan]", border_style="cyan")
5545
console.print(user_panel)
56-
46+
5747
# Display agent response with markdown rendering
5848
response_content = result["response"]
5949
if response_content:
6050
try:
6151
# Try to render as markdown for better formatting
6252
markdown = Markdown(response_content)
6353
agent_panel = Panel(
64-
markdown,
65-
title="[bold green]LangGraphエージェント[/bold green]",
66-
border_style="green"
54+
markdown, title="[bold green]LangGraphエージェント[/bold green]", border_style="green"
6755
)
6856
except Exception:
6957
# Fallback to plain text
7058
agent_panel = Panel(
71-
response_content,
72-
title="[bold green]LangGraphエージェント[/bold green]",
73-
border_style="green"
59+
response_content, title="[bold green]LangGraphエージェント[/bold green]", border_style="green"
7460
)
7561
console.print(agent_panel)
76-
62+
7763
# Display metadata
7864
if verbose:
7965
console.print("\n[bold yellow]メタデータ[/bold yellow]:")
8066
console.print(f"スレッドID: {result['thread_id']}")
8167
console.print(f"作成日時: {result['created_at']}")
8268
console.print(f"ステップ数: {result.get('step_count', 0)}")
83-
69+
8470
if result.get("tools_used"):
8571
console.print(f"使用ツール: {', '.join(result['tools_used'])}")
8672
else:
@@ -89,7 +75,7 @@ def chat(
8975
console.print(f"\n[dim]スレッドID: {result['thread_id']}[/dim]")
9076
if result.get("tools_used"):
9177
console.print(f"[dim]使用ツール: {', '.join(result['tools_used'])}[/dim]")
92-
78+
9379
except Exception as e:
9480
console.print(f"❌ [bold red]エラー[/bold red]: {str(e)}")
9581

@@ -99,41 +85,41 @@ def interactive():
9985
"""対話モードでLangGraphエージェントとチャットする"""
10086
console.print("[bold green]LangGraphエージェント対話モード[/bold green]")
10187
console.print("終了するには 'exit', 'quit', または 'bye' と入力してください\n")
102-
88+
10389
agent = LangGraphAgent()
10490
thread_id = None
105-
91+
10692
while True:
10793
try:
10894
# Get user input
10995
user_input = typer.prompt("あなた")
110-
96+
11197
# Check for exit commands
112-
if user_input.lower() in ['exit', 'quit', 'bye', '終了']:
98+
if user_input.lower() in ["exit", "quit", "bye", "終了"]:
11399
console.print("[yellow]対話を終了します。ありがとうございました![/yellow]")
114100
break
115-
101+
116102
# Process the message
117103
with console.status("[bold green]応答を生成中...", spinner="dots"):
118104
result = agent.chat(message=user_input, thread_id=thread_id)
119-
105+
120106
# Update thread_id for conversation continuity
121107
thread_id = result["thread_id"]
122-
108+
123109
# Display agent response
124110
response_panel = Panel(
125111
Markdown(result["response"]) if result["response"] else "応答がありません",
126112
title="[bold green]エージェント[/bold green]",
127-
border_style="green"
113+
border_style="green",
128114
)
129115
console.print(response_panel)
130-
116+
131117
# Show tools used if any
132118
if result.get("tools_used"):
133119
console.print(f"[dim]使用ツール: {', '.join(result['tools_used'])}[/dim]")
134-
120+
135121
console.print() # Add spacing
136-
122+
137123
except KeyboardInterrupt:
138124
console.print("\n[yellow]対話を終了します[/yellow]")
139125
break
@@ -145,36 +131,32 @@ def interactive():
145131
def tools():
146132
"""利用可能なツールの一覧を表示する"""
147133
console.print("[bold green]利用可能なツール一覧[/bold green]")
148-
134+
149135
try:
150136
available_tools = get_tools()
151-
137+
152138
if not available_tools:
153139
console.print("[yellow]利用可能なツールがありません[/yellow]")
154140
return
155-
141+
156142
console.print(f"\n[bold blue]合計 {len(available_tools)} 個のツールが利用可能です[/bold blue]\n")
157-
143+
158144
for i, tool in enumerate(available_tools, 1):
159145
tool_info = f"""
160146
**名前:** {tool.name}
161147
**説明:** {tool.description}
162148
"""
163-
if hasattr(tool, 'args_schema') and tool.args_schema:
149+
if hasattr(tool, "args_schema") and tool.args_schema:
164150
try:
165151
schema = tool.args_schema.model_json_schema()
166-
if 'properties' in schema:
152+
if "properties" in schema:
167153
tool_info += f"**パラメータ:** {', '.join(schema['properties'].keys())}"
168154
except Exception:
169155
pass
170-
171-
panel = Panel(
172-
Markdown(tool_info),
173-
title=f"[bold cyan]ツール {i}[/bold cyan]",
174-
border_style="cyan"
175-
)
156+
157+
panel = Panel(Markdown(tool_info), title=f"[bold cyan]ツール {i}[/bold cyan]", border_style="cyan")
176158
console.print(panel)
177-
159+
178160
except Exception as e:
179161
console.print(f"❌ [bold red]エラー[/bold red]: {str(e)}")
180162

@@ -184,38 +166,38 @@ def demo():
184166
"""デモンストレーション用のサンプルチャット"""
185167
console.print("[bold green]LangGraphエージェント デモモード[/bold green]")
186168
console.print("いくつかのサンプル質問でエージェントをテストします\n")
187-
169+
188170
sample_queries = [
189171
"こんにちは!今何時ですか?",
190172
"2 + 2 × 3 を計算してください",
191173
"Pythonについて検索してください",
192174
]
193-
175+
194176
agent = LangGraphAgent()
195-
177+
196178
for i, query in enumerate(sample_queries, 1):
197179
console.print(f"[bold yellow]サンプル質問 {i}:[/bold yellow] {query}")
198-
180+
199181
try:
200182
with console.status(f"[bold green]質問 {i} を処理中...", spinner="dots"):
201183
result = agent.chat(message=query)
202-
184+
203185
response_panel = Panel(
204186
Markdown(result["response"]) if result["response"] else "応答がありません",
205187
title="[bold green]エージェントの応答[/bold green]",
206-
border_style="green"
188+
border_style="green",
207189
)
208190
console.print(response_panel)
209-
191+
210192
if result.get("tools_used"):
211193
console.print(f"[dim]使用ツール: {', '.join(result['tools_used'])}[/dim]")
212-
194+
213195
console.print() # Add spacing
214-
196+
215197
except Exception as e:
216198
console.print(f"❌ [bold red]エラー[/bold red]: {str(e)}")
217199
console.print()
218200

219201

220202
if __name__ == "__main__":
221-
app()
203+
app()

template_fastapi/core/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

template_fastapi/core/langgraph/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Core module for template_fastapi."""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""LangGraph components for agent implementation."""

0 commit comments

Comments
 (0)