-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
88 lines (71 loc) · 2.96 KB
/
Copy pathmain.py
File metadata and controls
88 lines (71 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
Deep Agent RAG - メインエントリポイント
ハーネスを起動してテストクエリを実行
"""
import sys
import logging
from pathlib import Path
# srcディレクトリをパスに追加
sys.path.insert(0, str(Path(__file__).parent / "src"))
from deep_agents_harness import create_default_harness
# ログ設定
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def main():
"""メイン実行"""
logger.info("=" * 80)
logger.info("Deep Agent RAG - Harness Demo")
logger.info("=" * 80)
# ハーネス作成
logger.info("\n[1] Creating harness...")
harness = create_default_harness()
# 初期化
logger.info("\n[2] Initializing all agents...")
harness.initialize_all()
# テストクエリ
test_queries = [
"堤防の天端幅は何メートルですか?", # Fine-grained
"河川管理とは何ですか?", # Coarse-grained
"コンクリートの配合で使用するセメントの種類は?", # Fine-grained
"河川法の目的を説明してください", # Coarse-grained
]
logger.info("\n[3] Executing test queries...")
for i, query in enumerate(test_queries, 1):
logger.info(f"\n--- Query {i}/{len(test_queries)} ---")
result = harness.execute_pipeline(query)
if result.get("final_answer"):
answer = result["final_answer"]
print(f"\n質問: {query}")
print(f"粒度: {answer['granularity']}")
print(f"選択システム: {answer['selected_system']}")
print(f"セレクター信頼度: {answer['selector_confidence']:.2f}")
print(f"検索信頼度: {answer['retrieval_confidence']:.2f}")
print(f"実行時間: {result['total_time_ms']:.2f}ms")
print(f"取得文書数: {len(answer['retrieved_documents'])}")
# 上位3件の文書を表示
print("\n取得文書(上位3件):")
for j, (content, score, metadata) in enumerate(answer['retrieved_documents'][:3], 1):
print(f" {j}. スコア: {score:.4f}")
print(f" {content[:100]}...")
else:
print(f"\nエラー: {result.get('error', 'Unknown error')}")
# 統計表示
logger.info("\n[4] Statistics")
stats = harness.get_statistics()
print(f"\n実行統計:")
print(f" 総実行回数: {stats['total_executions']}")
print(f" 平均実行時間: {stats['average_time_ms']:.2f}ms")
print(f" システム使用率:")
for system, count in stats['system_usage'].items():
print(f" - {system}: {count}回")
# クリーンアップ
logger.info("\n[5] Cleanup")
harness.cleanup_all()
logger.info("\n" + "=" * 80)
logger.info("Demo completed successfully!")
logger.info("=" * 80)
if __name__ == "__main__":
main()