agent_evaluator 0.7.0__tar.gz → 0.7.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_evaluator-0.7.4/PKG-INFO +1467 -0
- agent_evaluator-0.7.4/README.md +1335 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/__init__.py +60 -67
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/alerts/engine.py +5 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/anomaly/detector.py +52 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cli/main.py +7 -6
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/agent_evaluator.py +0 -1
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/monitor_context.py +2 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/otel/provider.py +2 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/base.py +2 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/conversation.py +2 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/layer1.py +181 -27
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/layer2.py +103 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/monitor.py +2055 -58
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cost/policy.py +95 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/datasets/builder.py +41 -2
- agent_evaluator-0.7.4/agent_evaluator/decorators.py +6466 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/exceptions.py +47 -1
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/helpers/taskresult_helpers.py +36 -28
- agent_evaluator-0.7.4/agent_evaluator/integrations/__init__.py +149 -0
- agent_evaluator-0.7.4/agent_evaluator/integrations/dspy_integration.py +267 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/integrations/framework_integrations.py +34 -29
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/integrations/llm_judge.py +12 -5
- agent_evaluator-0.7.4/agent_evaluator/integrations/pydanticai_integration.py +314 -0
- agent_evaluator-0.7.4/agent_evaluator/quick_eval.py +1284 -0
- agent_evaluator-0.7.4/agent_evaluator/serve/cache.py +83 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/loader.py +25 -1
- agent_evaluator-0.7.4/agent_evaluator/serve/routers/alerts.py +303 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/config.py +5 -2
- agent_evaluator-0.7.4/agent_evaluator/serve/routers/conversation.py +119 -0
- agent_evaluator-0.7.4/agent_evaluator/serve/routers/cost.py +177 -0
- agent_evaluator-0.7.4/agent_evaluator/serve/routers/data.py +2719 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/export.py +140 -3
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/golden.py +54 -3
- agent_evaluator-0.7.4/agent_evaluator/serve/routers/stream.py +469 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/transparency.py +5 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/templates/dashboard.html.j2 +13 -11
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/templates/dashboard2.html.j2 +6 -4
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/templates/sdk_docs.html.j2 +955 -500
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/templates/slides.html.j2 +3 -2
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/streaming/evaluator.py +7 -4
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/utils/data_registry.py +2 -2
- agent_evaluator-0.7.4/agent_evaluator/utils/text_similarity.py +42 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/pyproject.toml +9 -1
- agent_evaluator-0.7.0/PKG-INFO +0 -1049
- agent_evaluator-0.7.0/README.md +0 -921
- agent_evaluator-0.7.0/agent_evaluator/integrations/__init__.py +0 -111
- agent_evaluator-0.7.0/agent_evaluator/integrations/autogen_integration.py +0 -1343
- agent_evaluator-0.7.0/agent_evaluator/integrations/crewai_integration.py +0 -1434
- agent_evaluator-0.7.0/agent_evaluator/integrations/langchain_integration.py +0 -1104
- agent_evaluator-0.7.0/agent_evaluator/integrations/langgraph_integration.py +0 -1489
- agent_evaluator-0.7.0/agent_evaluator/integrations/llm_helpers.py +0 -319
- agent_evaluator-0.7.0/agent_evaluator/serve/routers/alerts.py +0 -130
- agent_evaluator-0.7.0/agent_evaluator/serve/routers/conversation.py +0 -62
- agent_evaluator-0.7.0/agent_evaluator/serve/routers/cost.py +0 -44
- agent_evaluator-0.7.0/agent_evaluator/serve/routers/data.py +0 -209
- agent_evaluator-0.7.0/agent_evaluator/serve/routers/stream.py +0 -132
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/.gitignore +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/LICENSE +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/alerts/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/alerts/handlers.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/anomaly/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cli/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cli/dataset.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cli/gate.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cli/monitor.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/config.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/hybrid_monitor.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/otel/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/otel/metrics.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/feedback.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/core/trackers/security.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/cost/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/datasets/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/datasets/korean_rag_dataset_generator.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/datasets/korean_rag_evaluator.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/examples/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/examples/example_runner.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/helpers/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/integrations/metric_adapters.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/py.typed +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/reporting/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/reporting/comprehensive_report.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/anomaly.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/feedback.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/routers/webhook.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/server.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/serve/watcher.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/streaming/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/streaming/middleware.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/utils/__init__.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/utils/dashboard_integration.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/utils/path_helpers.py +0 -0
- {agent_evaluator-0.7.0 → agent_evaluator-0.7.4}/agent_evaluator/utils/transparency_manager.py +0 -0
|
@@ -0,0 +1,1467 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-evaluator
|
|
3
|
+
Version: 0.7.4
|
|
4
|
+
Summary: Production-ready evaluation framework for AI agents — 25 metrics across task completion, accuracy, hallucination, latency, security, and agentic behavior
|
|
5
|
+
Project-URL: Homepage, https://github.com/bullpeng72/Agent-Evaluator
|
|
6
|
+
Project-URL: Repository, https://github.com/bullpeng72/Agent-Evaluator
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/bullpeng72/Agent-Evaluator/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/bullpeng72/Agent-Evaluator/blob/main/README.md
|
|
9
|
+
Author-email: Sungwoo Kim <sungwoo.kim@gmail.com>
|
|
10
|
+
Maintainer-email: Sungwoo Kim <sungwoo.kim@gmail.com>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: accuracy,agent,ai,autogen,benchmark,crewai,deepeval,evaluation,hallucination,langchain,langgraph,latency,llm,monitoring,observability,performance,rag,ragas,security,token
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
28
|
+
Classifier: Topic :: System :: Monitoring
|
|
29
|
+
Classifier: Typing :: Typed
|
|
30
|
+
Requires-Python: >=3.8
|
|
31
|
+
Requires-Dist: numpy<3.0.0,>=1.20.0
|
|
32
|
+
Requires-Dist: pandas<4.0.0,>=1.3.0
|
|
33
|
+
Requires-Dist: python-dotenv<2.0.0,>=0.19.0
|
|
34
|
+
Provides-Extra: all
|
|
35
|
+
Requires-Dist: anthropic<1.0.0,>=0.20.0; extra == 'all'
|
|
36
|
+
Requires-Dist: datasets<6.0.0,>=4.0.0; extra == 'all'
|
|
37
|
+
Requires-Dist: deepeval<4.0.0,>=0.20.0; extra == 'all'
|
|
38
|
+
Requires-Dist: fastapi<1.0.0,>=0.110.0; extra == 'all'
|
|
39
|
+
Requires-Dist: jinja2<4.0.0,>=3.1.0; extra == 'all'
|
|
40
|
+
Requires-Dist: langchain-anthropic<3.0.0,>=0.1.0; extra == 'all'
|
|
41
|
+
Requires-Dist: langchain-core<3.0.0,>=1.0.0; extra == 'all'
|
|
42
|
+
Requires-Dist: langchain-openai<3.0.0,>=0.1.0; extra == 'all'
|
|
43
|
+
Requires-Dist: langchain<3.0.0,>=1.0.0; extra == 'all'
|
|
44
|
+
Requires-Dist: langgraph<3.0.0,>=1.0.0; extra == 'all'
|
|
45
|
+
Requires-Dist: openai<3.0.0,>=1.0.0; extra == 'all'
|
|
46
|
+
Requires-Dist: pdfplumber<1.0.0,>=0.10.0; extra == 'all'
|
|
47
|
+
Requires-Dist: pypdf<7.0.0,>=3.0.0; extra == 'all'
|
|
48
|
+
Requires-Dist: python-multipart<1.0.0,>=0.0.9; extra == 'all'
|
|
49
|
+
Requires-Dist: ragas<2.0.0,>=0.4.0; extra == 'all'
|
|
50
|
+
Requires-Dist: uvicorn[standard]<1.0.0,>=0.29.0; extra == 'all'
|
|
51
|
+
Provides-Extra: autogen
|
|
52
|
+
Requires-Dist: autogen-agentchat<1.0.0,>=0.4.0; extra == 'autogen'
|
|
53
|
+
Requires-Dist: autogen-core<1.0.0,>=0.4.0; extra == 'autogen'
|
|
54
|
+
Requires-Dist: pyautogen<1.0.0,>=0.3.0; extra == 'autogen'
|
|
55
|
+
Provides-Extra: crewai
|
|
56
|
+
Requires-Dist: crewai<2.0.0,>=1.0.0; extra == 'crewai'
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: build>=1.0.0; extra == 'dev'
|
|
59
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
60
|
+
Requires-Dist: pre-commit>=3.0.0; extra == 'dev'
|
|
61
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
62
|
+
Requires-Dist: pytest-cov>=3.0.0; extra == 'dev'
|
|
63
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
64
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
65
|
+
Requires-Dist: twine>=5.0.0; extra == 'dev'
|
|
66
|
+
Provides-Extra: dspy
|
|
67
|
+
Requires-Dist: dspy-ai>=2.0.0; extra == 'dspy'
|
|
68
|
+
Provides-Extra: eval
|
|
69
|
+
Requires-Dist: datasets<6.0.0,>=4.0.0; extra == 'eval'
|
|
70
|
+
Requires-Dist: deepeval<4.0.0,>=3.0.0; extra == 'eval'
|
|
71
|
+
Requires-Dist: langchain-openai<3.0.0,>=0.1.0; extra == 'eval'
|
|
72
|
+
Requires-Dist: langchain<3.0.0,>=0.2.0; extra == 'eval'
|
|
73
|
+
Requires-Dist: ragas<2.0.0,>=0.4.0; extra == 'eval'
|
|
74
|
+
Provides-Extra: frameworks
|
|
75
|
+
Requires-Dist: autogen-agentchat<1.0.0,>=0.4.0; extra == 'frameworks'
|
|
76
|
+
Requires-Dist: autogen-core<1.0.0,>=0.4.0; extra == 'frameworks'
|
|
77
|
+
Requires-Dist: crewai<2.0.0,>=1.0.0; extra == 'frameworks'
|
|
78
|
+
Requires-Dist: langchain-anthropic<3.0.0,>=0.1.0; extra == 'frameworks'
|
|
79
|
+
Requires-Dist: langchain-core<3.0.0,>=1.0.0; extra == 'frameworks'
|
|
80
|
+
Requires-Dist: langchain-openai<3.0.0,>=0.1.0; extra == 'frameworks'
|
|
81
|
+
Requires-Dist: langchain<3.0.0,>=1.0.0; extra == 'frameworks'
|
|
82
|
+
Requires-Dist: langgraph<3.0.0,>=1.0.0; extra == 'frameworks'
|
|
83
|
+
Requires-Dist: pyautogen<1.0.0,>=0.3.0; extra == 'frameworks'
|
|
84
|
+
Provides-Extra: full
|
|
85
|
+
Requires-Dist: anthropic<1.0.0,>=0.20.0; extra == 'full'
|
|
86
|
+
Requires-Dist: arize-phoenix>=0.11.0; extra == 'full'
|
|
87
|
+
Requires-Dist: autogen-agentchat<1.0.0,>=0.4.0; extra == 'full'
|
|
88
|
+
Requires-Dist: autogen-core<1.0.0,>=0.4.0; extra == 'full'
|
|
89
|
+
Requires-Dist: crewai<2.0.0,>=1.0.0; extra == 'full'
|
|
90
|
+
Requires-Dist: datasets<6.0.0,>=4.0.0; extra == 'full'
|
|
91
|
+
Requires-Dist: deepeval<4.0.0,>=3.0.0; extra == 'full'
|
|
92
|
+
Requires-Dist: fastapi<1.0.0,>=0.110.0; extra == 'full'
|
|
93
|
+
Requires-Dist: jinja2<4.0.0,>=3.1.0; extra == 'full'
|
|
94
|
+
Requires-Dist: langchain-anthropic<3.0.0,>=0.1.0; extra == 'full'
|
|
95
|
+
Requires-Dist: langchain-core<3.0.0,>=1.0.0; extra == 'full'
|
|
96
|
+
Requires-Dist: langchain-openai<3.0.0,>=0.1.0; extra == 'full'
|
|
97
|
+
Requires-Dist: langchain<3.0.0,>=1.0.0; extra == 'full'
|
|
98
|
+
Requires-Dist: langgraph<3.0.0,>=1.0.0; extra == 'full'
|
|
99
|
+
Requires-Dist: openai<3.0.0,>=1.0.0; extra == 'full'
|
|
100
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.20.0; extra == 'full'
|
|
101
|
+
Requires-Dist: opentelemetry-sdk<2.0.0,>=1.20.0; extra == 'full'
|
|
102
|
+
Requires-Dist: pdfplumber<1.0.0,>=0.10.0; extra == 'full'
|
|
103
|
+
Requires-Dist: pyautogen<1.0.0,>=0.3.0; extra == 'full'
|
|
104
|
+
Requires-Dist: pypdf<7.0.0,>=3.0.0; extra == 'full'
|
|
105
|
+
Requires-Dist: python-multipart<1.0.0,>=0.0.9; extra == 'full'
|
|
106
|
+
Requires-Dist: ragas<2.0.0,>=0.4.0; extra == 'full'
|
|
107
|
+
Requires-Dist: uvicorn[standard]<1.0.0,>=0.29.0; extra == 'full'
|
|
108
|
+
Provides-Extra: langchain
|
|
109
|
+
Requires-Dist: langchain-anthropic<3.0.0,>=0.1.0; extra == 'langchain'
|
|
110
|
+
Requires-Dist: langchain-core<3.0.0,>=1.0.0; extra == 'langchain'
|
|
111
|
+
Requires-Dist: langchain-openai<3.0.0,>=0.1.0; extra == 'langchain'
|
|
112
|
+
Requires-Dist: langchain<3.0.0,>=1.0.0; extra == 'langchain'
|
|
113
|
+
Requires-Dist: langgraph<3.0.0,>=1.0.0; extra == 'langchain'
|
|
114
|
+
Provides-Extra: llm
|
|
115
|
+
Requires-Dist: anthropic<1.0.0,>=0.20.0; extra == 'llm'
|
|
116
|
+
Requires-Dist: openai<3.0.0,>=1.0.0; extra == 'llm'
|
|
117
|
+
Provides-Extra: otel
|
|
118
|
+
Requires-Dist: arize-phoenix>=0.11.0; extra == 'otel'
|
|
119
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2.0.0,>=1.20.0; extra == 'otel'
|
|
120
|
+
Requires-Dist: opentelemetry-sdk<2.0.0,>=1.20.0; extra == 'otel'
|
|
121
|
+
Provides-Extra: pdf
|
|
122
|
+
Requires-Dist: pdfplumber<1.0.0,>=0.10.0; extra == 'pdf'
|
|
123
|
+
Requires-Dist: pypdf<7.0.0,>=3.0.0; extra == 'pdf'
|
|
124
|
+
Provides-Extra: pydanticai
|
|
125
|
+
Requires-Dist: pydantic-ai>=0.0.13; extra == 'pydanticai'
|
|
126
|
+
Provides-Extra: serve
|
|
127
|
+
Requires-Dist: fastapi<1.0.0,>=0.110.0; extra == 'serve'
|
|
128
|
+
Requires-Dist: jinja2<4.0.0,>=3.1.0; extra == 'serve'
|
|
129
|
+
Requires-Dist: python-multipart<1.0.0,>=0.0.9; extra == 'serve'
|
|
130
|
+
Requires-Dist: uvicorn[standard]<1.0.0,>=0.29.0; extra == 'serve'
|
|
131
|
+
Description-Content-Type: text/markdown
|
|
132
|
+
|
|
133
|
+
# Agent Evaluator
|
|
134
|
+
|
|
135
|
+
[](https://pypi.org/project/agent-evaluator/)
|
|
136
|
+
[](https://www.python.org/downloads/)
|
|
137
|
+
[](https://opensource.org/licenses/MIT)
|
|
138
|
+
[](https://github.com/bullpeng72/Agent-Evaluator)
|
|
139
|
+
|
|
140
|
+
**AI 에이전트를 위한 프로덕션 레디 평가 프레임워크**
|
|
141
|
+
|
|
142
|
+
함수 위에 데코레이터 한 줄을 추가하는 것만으로 에이전트를 평가할 수 있습니다.
|
|
143
|
+
LangChain, CrewAI, AutoGen, LangGraph 등 **21개 프레임워크**를 자동 인식하고,
|
|
144
|
+
태스크 완료율부터 보안 취약점까지 **25개 지표**를 코드 수정 없이 측정합니다.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 왜 데코레이터인가?
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
# ❌ 기존 방식 — 에이전트 코드를 직접 수정, 보일러플레이트 작성 필요
|
|
152
|
+
import time, uuid
|
|
153
|
+
from datetime import datetime
|
|
154
|
+
|
|
155
|
+
def my_agent(question, ground_truth):
|
|
156
|
+
start = time.time()
|
|
157
|
+
response = llm.invoke(question)
|
|
158
|
+
elapsed = time.time() - start
|
|
159
|
+
|
|
160
|
+
task = TaskResult(
|
|
161
|
+
task_id=str(uuid.uuid4()), task_type="qa", success=True,
|
|
162
|
+
completion_score=1.0,
|
|
163
|
+
accuracy_score=compute_accuracy(response, ground_truth), # 직접 계산
|
|
164
|
+
execution_time=elapsed, # 직접 측정
|
|
165
|
+
tokens_used=extract_tokens(response), # 프레임워크마다 다름
|
|
166
|
+
tool_calls=[], attempts=1, errors=[], timestamp=datetime.now(),
|
|
167
|
+
question=question, response=str(response), ground_truth=ground_truth,
|
|
168
|
+
)
|
|
169
|
+
monitor.record_task(task)
|
|
170
|
+
return response
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
# ✅ 데코레이터 방식 — 한 줄 추가, 에이전트 코드 무수정
|
|
175
|
+
from agent_evaluator import QuickEval
|
|
176
|
+
|
|
177
|
+
eval = QuickEval("results/")
|
|
178
|
+
|
|
179
|
+
@eval.qa # 이 한 줄이 전부
|
|
180
|
+
def my_agent(question, ground_truth=""):
|
|
181
|
+
return llm.invoke(question) # 에이전트 로직 그대로 유지
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
데코레이터는 **비침습적(non-invasive)**입니다. 원본 함수의 시그니처·반환값·예외 처리가 변경되지 않으며, 측정이 끝나면 원래 반환값이 그대로 호출자에게 전달됩니다.
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## 데코레이터 동작 원리
|
|
189
|
+
|
|
190
|
+
```
|
|
191
|
+
호출자
|
|
192
|
+
│
|
|
193
|
+
▼
|
|
194
|
+
@agent_eval / @batch_eval / @conversation_eval
|
|
195
|
+
│
|
|
196
|
+
├─ [1] 실행 시간 측정 시작
|
|
197
|
+
├─ [2] 원본 함수 실행
|
|
198
|
+
├─ [3] 프레임워크 어댑터 적용 ← tool_calls · chain_steps · tokens_used 자동 추출
|
|
199
|
+
├─ [4] EvalMetadata 병합 ← 함수가 (response, EvalMetadata(...)) 반환 시
|
|
200
|
+
├─ [5] TaskResult 자동 구성 ← 24개 필드 완성
|
|
201
|
+
├─ [6] PerformanceMonitor.record_task() 호출
|
|
202
|
+
│ ├─ Layer 1: TCR · Accuracy · Hallucination · Quality · Latency · Token
|
|
203
|
+
│ ├─ Layer 2: Tool · Retry · Coordination · Workflow · Security (5종)
|
|
204
|
+
│ └─ Layer 3: DeepEval · Ragas · LangSmith (opt-in)
|
|
205
|
+
│
|
|
206
|
+
└─ [7] 원본 반환값 그대로 호출자에게 전달
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## 설치
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
pip install agent-evaluator # 기본 (Layer 1/2 즉시 사용)
|
|
215
|
+
pip install "agent-evaluator[llm]" # OpenAI + Anthropic 클라이언트
|
|
216
|
+
pip install "agent-evaluator[langchain]" # LangChain / LangGraph
|
|
217
|
+
pip install "agent-evaluator[eval]" # DeepEval + Ragas (Layer 3)
|
|
218
|
+
pip install "agent-evaluator[serve]" # FastAPI 대시보드
|
|
219
|
+
pip install "agent-evaluator[all]" # 권장 — crewai/autogen/otel 제외 전체
|
|
220
|
+
pip install "agent-evaluator[full]" # 전체 (⚠️ 10분+ 소요)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 3가지 데코레이터
|
|
226
|
+
|
|
227
|
+
Agent Evaluator의 평가 인터페이스는 호출 패턴에 따라 정확히 **3종**으로 구성됩니다.
|
|
228
|
+
|
|
229
|
+
| 데코레이터 | 호출 패턴 | 사용 시나리오 |
|
|
230
|
+
|-----------|---------|-------------|
|
|
231
|
+
| `@agent_eval` | 함수 1회 호출 = TaskResult 1건 | 단일 QA · 도구 호출 · RAG · 보안 검사 |
|
|
232
|
+
| `@batch_eval` | 함수 1회 호출 = TaskResult N건 | 데이터셋 일괄 평가 · 벤치마크 |
|
|
233
|
+
| `@conversation_eval` | 함수 N회 호출 = TaskResult 1건 | 멀티턴 대화 · 챗봇 세션 |
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### 데코레이터 1: `@agent_eval`
|
|
238
|
+
|
|
239
|
+
**1번 호출 → 1개 TaskResult**. 동기·비동기·제너레이터·재시도를 모두 지원합니다.
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
from agent_evaluator import PerformanceMonitor
|
|
243
|
+
from agent_evaluator.decorators import agent_eval
|
|
244
|
+
|
|
245
|
+
monitor = PerformanceMonitor("results/")
|
|
246
|
+
|
|
247
|
+
# 기본 — QA 평가
|
|
248
|
+
@agent_eval(monitor, task_type="qa")
|
|
249
|
+
def agent(question: str, ground_truth: str = "") -> str:
|
|
250
|
+
return llm.invoke(question)
|
|
251
|
+
|
|
252
|
+
# 비동기 함수 — 동일한 데코레이터 사용
|
|
253
|
+
@agent_eval(monitor, task_type="qa")
|
|
254
|
+
async def async_agent(question: str, ground_truth: str = "") -> str:
|
|
255
|
+
return await async_llm.invoke(question)
|
|
256
|
+
|
|
257
|
+
# 재시도 내장 — 실패 시 자동 재시도, attempts 필드 자동 기록
|
|
258
|
+
@agent_eval(monitor, task_type="qa", max_retries=3, delay=1.0, backoff=2.0)
|
|
259
|
+
def robust_agent(question: str, ground_truth: str = "") -> str:
|
|
260
|
+
return unreliable_llm.invoke(question)
|
|
261
|
+
|
|
262
|
+
# RAG 에이전트 — rag_mode=True 하나로 context + hallucination 자동 활성
|
|
263
|
+
@agent_eval(monitor, task_type="information_retrieval", rag_mode=True, context_arg="context")
|
|
264
|
+
def rag_agent(question: str, context: str = "", ground_truth: str = "") -> str:
|
|
265
|
+
return retrieval_llm.invoke(question, context)
|
|
266
|
+
|
|
267
|
+
# 보안 검사 — security_mode=True 로 5개 보안 트래커 임시 활성
|
|
268
|
+
@agent_eval(monitor, task_type="qa", security_mode=True)
|
|
269
|
+
def secure_agent(question: str, ground_truth: str = "") -> str:
|
|
270
|
+
return llm.invoke(question)
|
|
271
|
+
|
|
272
|
+
# LLM 프레임워크 어댑터 — tool_calls · tokens_used 자동 추출
|
|
273
|
+
@agent_eval(monitor, task_type="tool_use", framework="langchain")
|
|
274
|
+
def langchain_agent(question: str, ground_truth: str = "") -> str:
|
|
275
|
+
return executor.invoke({"input": question})
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
**`@agent_eval` 주요 파라미터**
|
|
279
|
+
|
|
280
|
+
| 파라미터 | 기본값 | 설명 |
|
|
281
|
+
|---------|--------|------|
|
|
282
|
+
| `task_type` | `"qa"` | 태스크 유형 (qa · tool_use · information_retrieval · code_generation 등) |
|
|
283
|
+
| `framework` | `"native"` | 프레임워크 어댑터 (21종 지원) |
|
|
284
|
+
| `auto_detect_framework` | `True` | 반환값 타입으로 프레임워크 자동 감지 |
|
|
285
|
+
| `question_arg` | `"question"` | 질문 인자명 |
|
|
286
|
+
| `ground_truth_arg` | `"ground_truth"` | 정답 인자명 |
|
|
287
|
+
| `context_arg` | `None` | RAG 컨텍스트 인자명 |
|
|
288
|
+
| `expected_tools_arg` | `None` | 기대 툴 목록 인자명 (Tool Selection F1 자동 계산) |
|
|
289
|
+
| `score_fn` | `None` | 커스텀 정확도 계산 함수 `(response, gt) → float` |
|
|
290
|
+
| `rag_mode` | `False` | context_arg + hallucination 자동 활성 단축 설정 |
|
|
291
|
+
| `security_mode` | `False` | 보안 지표 이 호출에만 임시 활성 |
|
|
292
|
+
| `enable_hallucination` | `False` | Hallucination Detection 이 호출에만 임시 활성 |
|
|
293
|
+
| `enable_llm_judge` | `False` | LLM Judge 이 호출에만 임시 활성 |
|
|
294
|
+
| `max_retries` | `1` | 실패 시 최대 재시도 횟수 |
|
|
295
|
+
| `delay` / `backoff` | `0.0` / `1.0` | 재시도 대기 시간 / 지수 백오프 계수 |
|
|
296
|
+
| `timeout` | `None` | 최대 실행 시간(초) |
|
|
297
|
+
| `sample_rate` | `1.0` | 기록 샘플링 비율 |
|
|
298
|
+
| `on_record` | `None` | 기록 직전 콜백 (TaskResult 교체 가능) |
|
|
299
|
+
| `alert_rules` | `[]` | 조건부 알림 규칙 목록 |
|
|
300
|
+
| `flush_every` | `0` | N건마다 자동 `save_to_file()` |
|
|
301
|
+
| `preset` | `None` | 사전 정의 설정 묶음 |
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
### 데코레이터 2: `@batch_eval`
|
|
306
|
+
|
|
307
|
+
**1번 호출 → N개 TaskResult**. 질문 리스트를 받아 건별로 독립된 평가 레코드를 생성합니다.
|
|
308
|
+
|
|
309
|
+
```python
|
|
310
|
+
from agent_evaluator.decorators import batch_eval
|
|
311
|
+
|
|
312
|
+
# 기본 — 리스트 입력, 리스트 반환
|
|
313
|
+
@batch_eval(monitor, task_type="qa")
|
|
314
|
+
def batch_agent(questions: list, ground_truths: list = None) -> list:
|
|
315
|
+
return [llm.invoke(q) for q in questions]
|
|
316
|
+
|
|
317
|
+
# DataFrame 반환 — accuracy_score · execution_time · tokens_total 등 포함
|
|
318
|
+
@batch_eval(monitor, task_type="qa", return_format="dataframe")
|
|
319
|
+
def batch_agent_df(questions: list, ground_truths: list = None) -> list:
|
|
320
|
+
return [llm.invoke(q) for q in questions]
|
|
321
|
+
|
|
322
|
+
# 병렬 실행 (async 함수) — asyncio.gather 기반
|
|
323
|
+
@batch_eval(monitor, task_type="qa", concurrent=True, max_concurrent=4)
|
|
324
|
+
async def parallel_agent(questions: list, ground_truths: list = None) -> list:
|
|
325
|
+
return await asyncio.gather(*[async_llm.invoke(q) for q in questions])
|
|
326
|
+
|
|
327
|
+
# 진행률 콜백 — 대규모 배치 모니터링
|
|
328
|
+
@batch_eval(
|
|
329
|
+
monitor,
|
|
330
|
+
task_type="qa",
|
|
331
|
+
return_format="tuple", # (responses, task_results) 반환
|
|
332
|
+
on_batch_progress=lambda done, total: print(f"{done}/{total}"),
|
|
333
|
+
flush_every=100, # 100건마다 중간 저장
|
|
334
|
+
)
|
|
335
|
+
def large_batch(questions: list, ground_truths: list = None) -> list:
|
|
336
|
+
return [llm.invoke(q) for q in questions]
|
|
337
|
+
|
|
338
|
+
responses, task_results = large_batch(questions, ground_truths)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**`@batch_eval` 주요 파라미터**
|
|
342
|
+
|
|
343
|
+
| 파라미터 | 기본값 | 설명 |
|
|
344
|
+
|---------|--------|------|
|
|
345
|
+
| `questions_arg` | `"questions"` | 질문 리스트 인자명 |
|
|
346
|
+
| `ground_truths_arg` | `"ground_truths"` | 정답 리스트 인자명 |
|
|
347
|
+
| `return_format` | `"list"` | 반환 형식: `"list"` · `"tuple"` · `"dataframe"` |
|
|
348
|
+
| `concurrent` | `False` | async 함수 항목별 병렬 실행 |
|
|
349
|
+
| `max_concurrent` | `0` | 병렬 상한 (0 = 무제한) |
|
|
350
|
+
| `shuffle` | `False` | 처리 순서 무작위화 |
|
|
351
|
+
| `item_timeout` | `None` | 항목별 최대 처리 시간(초) |
|
|
352
|
+
| `on_batch_progress` | `None` | 진행률 콜백 `(completed, total) → None` |
|
|
353
|
+
| `on_batch_complete` | `None` | 배치 완료 콜백 `(results) → None` |
|
|
354
|
+
| `on_item_error` | `None` | 항목 실패 콜백 `(index, question, error) → None` |
|
|
355
|
+
| `streaming_mode` | `False` | 메모리 효율적 스트리밍 처리 |
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
### 데코레이터 3: `@conversation_eval`
|
|
360
|
+
|
|
361
|
+
**N번 호출 → 1개 TaskResult**. 동일 `session_id`로 반복 호출하면 내부에서 턴을 누적하다가 `max_turns` 도달 또는 `flush_conversation()` 호출 시 세션을 종료하고 지표를 계산합니다.
|
|
362
|
+
|
|
363
|
+
```python
|
|
364
|
+
from agent_evaluator.decorators import conversation_eval
|
|
365
|
+
|
|
366
|
+
# 기본 — session_id별 자동 누적, max_turns 도달 시 자동 flush
|
|
367
|
+
@conversation_eval(monitor, session_id_arg="session_id", max_turns=5)
|
|
368
|
+
def chat(question: str, session_id: str = "default") -> str:
|
|
369
|
+
return llm.invoke(question)
|
|
370
|
+
|
|
371
|
+
# 사용 — 동일 session_id로 반복 호출
|
|
372
|
+
chat("파이썬 비동기 처리 방법 알려줘", session_id="conv_001")
|
|
373
|
+
chat("방금 설명한 방법의 단점은?", session_id="conv_001")
|
|
374
|
+
chat("asyncio.gather 예시 코드 보여줘", session_id="conv_001")
|
|
375
|
+
# → 5턴 도달 시 자동 flush: context_retention · topic_coherence · progressive_depth 계산
|
|
376
|
+
|
|
377
|
+
# 수동 flush — 원하는 시점에 세션 종료
|
|
378
|
+
from agent_evaluator.decorators import flush_conversation
|
|
379
|
+
flush_conversation("conv_001")
|
|
380
|
+
|
|
381
|
+
# 턴별 콜백 + 세션 스코어 함수
|
|
382
|
+
@conversation_eval(
|
|
383
|
+
monitor,
|
|
384
|
+
max_turns=10,
|
|
385
|
+
on_turn=lambda sid, user, resp, meta: print(f"[{sid}] {user[:20]}…"),
|
|
386
|
+
session_score_fn=lambda metrics: metrics.overall_score * 100,
|
|
387
|
+
flush_every=3, # 세션 3개마다 save_to_file() 자동 호출
|
|
388
|
+
)
|
|
389
|
+
def advanced_chat(question: str, session_id: str = "s1") -> str:
|
|
390
|
+
return llm.invoke(question)
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
`@conversation_eval`이 측정하는 지표:
|
|
394
|
+
|
|
395
|
+
| 지표 | 설명 |
|
|
396
|
+
|------|------|
|
|
397
|
+
| `context_retention` | 이전 턴 맥락이 후속 응답에 반영된 정도 |
|
|
398
|
+
| `topic_coherence` | 대화 전반의 주제 일관성 |
|
|
399
|
+
| `progressive_depth` | 대화가 심화될수록 정보 밀도가 높아지는 정도 |
|
|
400
|
+
| `session_completion` | 목표 대화 완성도 |
|
|
401
|
+
| `avg_turn_latency` | 턴별 평균 응답 시간 |
|
|
402
|
+
| `turn_scores` | 턴별 품질 점수 (Optional) |
|
|
403
|
+
|
|
404
|
+
**`@conversation_eval` 주요 파라미터**
|
|
405
|
+
|
|
406
|
+
| 파라미터 | 기본값 | 설명 |
|
|
407
|
+
|---------|--------|------|
|
|
408
|
+
| `session_id_arg` | `"session_id"` | 세션 ID 인자명 |
|
|
409
|
+
| `user_arg` | `"question"` | 사용자 메시지 인자명 |
|
|
410
|
+
| `max_turns` | `None` | 최대 턴 수 (도달 시 자동 flush) |
|
|
411
|
+
| `max_turns_exceeded_action` | `"flush"` | 초과 시 동작: `"flush"` · `"warn"` · `"error"` |
|
|
412
|
+
| `flush_on_error` | `True` | 예외 발생 시 세션 자동 flush |
|
|
413
|
+
| `on_turn` | `None` | 턴 완료 콜백 `(sid, user, response, meta) → None` |
|
|
414
|
+
| `on_flush` | `None` | 세션 종료 콜백 `(metrics, session_id) → None` |
|
|
415
|
+
| `session_score_fn` | `None` | 세션 종합 점수 함수 `(ConversationMetrics) → float` |
|
|
416
|
+
| `turn_score_fn` | `None` | 턴별 점수 함수 `(user, response, meta) → float` |
|
|
417
|
+
| `load_previous_session` | `False` | 이전 세션 이어받기 |
|
|
418
|
+
| `max_session_seconds` | `None` | 비활성 세션 자동 flush 타이머(초) |
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
## EvalDecorator — 3종 통합 팩토리
|
|
423
|
+
|
|
424
|
+
공통 설정(monitor, framework, model_name 등)을 **한 번만 정의**하고 3종 데코레이터 모두에 재사용합니다.
|
|
425
|
+
|
|
426
|
+
```python
|
|
427
|
+
from agent_evaluator.decorators import EvalDecorator
|
|
428
|
+
|
|
429
|
+
# 공통 설정 한 번 정의
|
|
430
|
+
dec = EvalDecorator(
|
|
431
|
+
monitor,
|
|
432
|
+
framework="langchain",
|
|
433
|
+
model_name="gpt-4o-mini",
|
|
434
|
+
flush_every=10,
|
|
435
|
+
alert_rules=[slow_rule, error_rule],
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
# ── agent_eval 계열 ──────────────────────────────────
|
|
439
|
+
@dec(task_type="qa") # agent_eval 직접 호출
|
|
440
|
+
def qa_agent(question, ground_truth=""): ...
|
|
441
|
+
|
|
442
|
+
@dec.with_retry(task_type="qa", max_retries=3) # 재시도 포함
|
|
443
|
+
def robust_agent(question, ground_truth=""): ...
|
|
444
|
+
|
|
445
|
+
# ── batch_eval ───────────────────────────────────────
|
|
446
|
+
@dec.batch(task_type="qa", return_format="dataframe")
|
|
447
|
+
def batch_agent(questions, ground_truths=None): ...
|
|
448
|
+
|
|
449
|
+
# ── conversation_eval ────────────────────────────────
|
|
450
|
+
@dec.conversation(session_id_arg="sid", max_turns=5)
|
|
451
|
+
def chat(question, sid="s1"): ...
|
|
452
|
+
|
|
453
|
+
# ── task_type 단축 속성 (QuickEval과 동일한 API) ─────
|
|
454
|
+
@dec.qa # task_type="qa"
|
|
455
|
+
@dec.tool_use # task_type="tool_use"
|
|
456
|
+
@dec.rag # task_type="information_retrieval" + rag_mode=True
|
|
457
|
+
@dec.code # task_type="code_generation"
|
|
458
|
+
@dec.reasoning # task_type="reasoning"
|
|
459
|
+
@dec.secure # task_type="qa" + security_mode=True
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## QuickEval — 1줄 시작 Facade
|
|
465
|
+
|
|
466
|
+
`PerformanceMonitor` + `EvalDecorator`를 1줄로 구성하는 원스톱 진입점입니다.
|
|
467
|
+
|
|
468
|
+
```python
|
|
469
|
+
from agent_evaluator import QuickEval
|
|
470
|
+
|
|
471
|
+
# 기본 초기화
|
|
472
|
+
eval = QuickEval("results/")
|
|
473
|
+
|
|
474
|
+
# 용도별 팩토리 — 관련 옵션 자동 설정
|
|
475
|
+
eval = QuickEval.for_rag("results/") # hallucination_detection=True 기본 활성
|
|
476
|
+
eval = QuickEval.for_security("results/") # enable_security_metrics=True 기본 활성
|
|
477
|
+
eval = QuickEval.for_llm_judge("results/", model="claude-sonnet-4-6")
|
|
478
|
+
|
|
479
|
+
# 데코레이터 단축 속성 11종
|
|
480
|
+
@eval.qa @eval.tool_use @eval.rag
|
|
481
|
+
@eval.code @eval.reasoning @eval.planning
|
|
482
|
+
@eval.data_analysis @eval.creative @eval.multi_agent
|
|
483
|
+
@eval.secure @eval.streaming
|
|
484
|
+
|
|
485
|
+
# 배치 · 대화 데코레이터도 동일 인터페이스
|
|
486
|
+
@eval.batch(task_type="qa", return_format="dataframe")
|
|
487
|
+
def batch_agent(questions, ground_truths=None): ...
|
|
488
|
+
|
|
489
|
+
@eval.conversation(session_id_arg="sid", max_turns=5)
|
|
490
|
+
def chat(question, sid="s1"): ...
|
|
491
|
+
|
|
492
|
+
# 결과 저장 · 게이팅
|
|
493
|
+
eval.save() # results/*.json + *.html
|
|
494
|
+
eval.gate(tcr=85, accuracy=70, hallucination=5) # CI/CD 게이트
|
|
495
|
+
eval.summary() # 주요 지표 요약 출력
|
|
496
|
+
eval.export_to_dataframe() # pd.DataFrame 반환
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
## eval_context — 데코레이터 불가 시 탈출구
|
|
502
|
+
|
|
503
|
+
외부 라이브러리 함수, lambda, 동적 호출 등 **데코레이터를 붙일 수 없는 코드**에서 사용합니다. `@agent_eval`과 동일한 평가를 수행합니다.
|
|
504
|
+
|
|
505
|
+
```python
|
|
506
|
+
from agent_evaluator.decorators import eval_context, get_eval_ctx
|
|
507
|
+
|
|
508
|
+
# 기본 — with 블록 종료 시 자동 record_task()
|
|
509
|
+
with eval_context(monitor, task_type="qa",
|
|
510
|
+
question="한국의 수도는?", ground_truth="서울") as ctx:
|
|
511
|
+
ctx.response = external_lib.call("한국의 수도는?")
|
|
512
|
+
|
|
513
|
+
# get_eval_ctx() 로 추가 메타데이터 주입
|
|
514
|
+
with eval_context(monitor, task_type="tool_use", question=q) as ctx:
|
|
515
|
+
result = external_agent.run(q)
|
|
516
|
+
ctx.response = result["output"]
|
|
517
|
+
ec = get_eval_ctx()
|
|
518
|
+
if ec:
|
|
519
|
+
ec.framework = "langchain"
|
|
520
|
+
ec.chain_steps = parse_steps(result)
|
|
521
|
+
|
|
522
|
+
# 비동기
|
|
523
|
+
async with eval_context(monitor, task_type="qa", question=q) as ctx:
|
|
524
|
+
ctx.response = await async_external.call(q)
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
## EvalMetadata — 추가 메타데이터 주입
|
|
530
|
+
|
|
531
|
+
3종 데코레이터 모두에서 사용 가능합니다. 반환값을 `(response, EvalMetadata(...))` 튜플로 바꾸면 자동 추출 결과를 덮어쓸 수 있습니다.
|
|
532
|
+
|
|
533
|
+
```python
|
|
534
|
+
from agent_evaluator.decorators import EvalMetadata
|
|
535
|
+
|
|
536
|
+
@agent_eval(monitor, task_type="tool_use")
|
|
537
|
+
def agent(question, ground_truth=""):
|
|
538
|
+
response = llm.invoke(question)
|
|
539
|
+
return response, EvalMetadata(
|
|
540
|
+
accuracy_score=0.95, # 커스텀 점수 직접 지정
|
|
541
|
+
tool_calls=["search", "calculator"], # 툴 호출 목록
|
|
542
|
+
tokens_used={"input": 120, "output": 80},
|
|
543
|
+
chain_steps=["search", "parse", "answer"],
|
|
544
|
+
agent_interactions=[("planner", "executor", "task_complete")],
|
|
545
|
+
)
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
`@conversation_eval`에서는 `TurnMetadata`를 사용합니다.
|
|
549
|
+
|
|
550
|
+
```python
|
|
551
|
+
from agent_evaluator.decorators import TurnMetadata
|
|
552
|
+
|
|
553
|
+
@conversation_eval(monitor, max_turns=5)
|
|
554
|
+
def chat(question: str, session_id: str = "s1") -> str:
|
|
555
|
+
response = llm.invoke(question)
|
|
556
|
+
return response, TurnMetadata(
|
|
557
|
+
model="gpt-4o-mini",
|
|
558
|
+
tokens={"input": 50, "output": 30},
|
|
559
|
+
tool_calls=["search"],
|
|
560
|
+
)
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
|
|
565
|
+
## 21개 프레임워크 자동 인식
|
|
566
|
+
|
|
567
|
+
`framework=` 파라미터 하나로 응답 객체에서 `tool_calls`, `chain_steps`, `tokens_used` 등을 자동 추출합니다.
|
|
568
|
+
3종 데코레이터 모두 동일한 `framework=` 파라미터를 지원합니다.
|
|
569
|
+
|
|
570
|
+
```python
|
|
571
|
+
# 명시적 지정 — IDE 자동완성 지원 (FrameworkLiteral 타입 힌트)
|
|
572
|
+
@agent_eval(monitor, task_type="tool_use", framework="langchain")
|
|
573
|
+
def lc_agent(question, ground_truth=""): ...
|
|
574
|
+
|
|
575
|
+
# 자동 감지 (기본 활성 — auto_detect_framework=True)
|
|
576
|
+
@agent_eval(monitor, task_type="qa")
|
|
577
|
+
def auto_agent(question, ground_truth=""): ...
|
|
578
|
+
|
|
579
|
+
# batch_eval · conversation_eval에도 동일하게 적용
|
|
580
|
+
@batch_eval(monitor, task_type="qa", framework="openai")
|
|
581
|
+
def batch_agent(questions, ground_truths=None): ...
|
|
582
|
+
|
|
583
|
+
@conversation_eval(monitor, max_turns=5, framework="anthropic")
|
|
584
|
+
def chat(question, session_id="s1"): ...
|
|
585
|
+
|
|
586
|
+
# 프레임워크 어댑터 정보 조회
|
|
587
|
+
from agent_evaluator.decorators import get_framework_info
|
|
588
|
+
info = get_framework_info("langchain")
|
|
589
|
+
# → {"name": "LangChain", "extras": "langchain",
|
|
590
|
+
# "extracts": ["tool_calls", "chain_steps"], "async_supported": True, ...}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### 어댑터 전체 목록
|
|
594
|
+
|
|
595
|
+
| 식별자 | 이름 | 필요 extras | 자동 추출 필드 | async |
|
|
596
|
+
|--------|------|------------|--------------|-------|
|
|
597
|
+
| `langchain` | LangChain | `[langchain]` | `tool_calls` · `chain_steps` | ✅ |
|
|
598
|
+
| `langgraph` | LangGraph | `[langchain]` | `state_transitions` · `graph_traversal` · `tool_calls` · `chain_steps` | ✅ |
|
|
599
|
+
| `crewai` | CrewAI | `[crewai]` | `agent_interactions` | ❌ |
|
|
600
|
+
| `autogen` | AutoGen | `[autogen]` | `conversation_turns` · `tokens_used` | ✅ |
|
|
601
|
+
| `dspy` | DSPy | `[dspy]` | `chain_steps` · `tokens_used` | ❌ |
|
|
602
|
+
| `pydanticai` | PydanticAI | `[pydanticai]` | `chain_steps` · `tokens_used` | ✅ |
|
|
603
|
+
| `anthropic` | Anthropic | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
604
|
+
| `openai` | OpenAI | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
605
|
+
| `gemini` | Google Gemini | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
606
|
+
| `vertexai` | Vertex AI | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
607
|
+
| `cohere` | Cohere | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
608
|
+
| `groq` | Groq | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
609
|
+
| `mistral` | Mistral AI | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
610
|
+
| `bedrock` | AWS Bedrock | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
611
|
+
| `ollama` | Ollama | `[llm]` | `tool_calls` · `tokens_used` | ❌ |
|
|
612
|
+
| `llamaindex` | LlamaIndex | `[llm]` | `chain_steps` | ✅ |
|
|
613
|
+
| `haystack` | Haystack | `[llm]` | `chain_steps` | ✅ |
|
|
614
|
+
| `semantic_kernel` | Semantic Kernel | `[llm]` | `chain_steps` · `tokens_used` | ✅ |
|
|
615
|
+
| `smolagents` | HuggingFace smolagents | `[llm]` | `tool_calls` · `chain_steps` | ❌ |
|
|
616
|
+
| `vllm` | vLLM | `[llm]` | `tool_calls` · `tokens_used` | ✅ |
|
|
617
|
+
| `huggingface` | HuggingFace | `[llm]` | `chain_steps` · `tool_calls` | ❌ |
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
### 오케스트레이션 프레임워크
|
|
622
|
+
|
|
623
|
+
#### LangChain
|
|
624
|
+
|
|
625
|
+
`AgentExecutor.invoke()` 결과의 `intermediate_steps`에서 툴 호출과 체인 단계를 자동 추출합니다.
|
|
626
|
+
|
|
627
|
+
```python
|
|
628
|
+
from langchain.agents import AgentExecutor
|
|
629
|
+
from agent_evaluator.decorators import agent_eval
|
|
630
|
+
|
|
631
|
+
# intermediate_steps → tool_calls + chain_steps 자동 변환
|
|
632
|
+
# usage_metadata / response_metadata.token_usage → tokens_used 자동 추출
|
|
633
|
+
@agent_eval(monitor, task_type="tool_use", framework="langchain")
|
|
634
|
+
def lc_agent(question: str, ground_truth: str = "") -> str:
|
|
635
|
+
result = agent_executor.invoke({"input": question})
|
|
636
|
+
return result # dict 그대로 반환 — "output" 키에서 텍스트 자동 추출
|
|
637
|
+
|
|
638
|
+
# 프레임워크 전용 별칭 (agent_evaluator.integrations)
|
|
639
|
+
from agent_evaluator.integrations import langchain_eval
|
|
640
|
+
|
|
641
|
+
@langchain_eval(monitor, task_type="tool_use")
|
|
642
|
+
def lc_agent2(question: str, ground_truth: str = "") -> str:
|
|
643
|
+
return agent_executor.invoke({"input": question})
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
#### LangGraph
|
|
647
|
+
|
|
648
|
+
그래프 실행 결과의 `messages` 배열에서 상태 전이·그래프 경로·툴 호출을 추출합니다.
|
|
649
|
+
`__metadata__` 키가 있으면 그래프 메타데이터도 자동 수집합니다.
|
|
650
|
+
|
|
651
|
+
```python
|
|
652
|
+
from langgraph.graph import StateGraph
|
|
653
|
+
from agent_evaluator.decorators import agent_eval
|
|
654
|
+
|
|
655
|
+
# messages → state_transitions + graph_traversal
|
|
656
|
+
# ToolMessage / AIMessage → chain_steps + 타임스탬프 기반 실행 시간
|
|
657
|
+
@agent_eval(monitor, task_type="tool_use", framework="langgraph")
|
|
658
|
+
def lg_agent(question: str, ground_truth: str = "") -> str:
|
|
659
|
+
result = graph.invoke({"messages": [("user", question)]})
|
|
660
|
+
return result # "messages"[-1].content 자동 추출
|
|
661
|
+
|
|
662
|
+
from agent_evaluator.integrations import langgraph_eval
|
|
663
|
+
|
|
664
|
+
@langgraph_eval(monitor, task_type="tool_use")
|
|
665
|
+
def lg_agent2(question: str, ground_truth: str = "") -> str:
|
|
666
|
+
return graph.invoke({"messages": [("user", question)]})
|
|
667
|
+
```
|
|
668
|
+
|
|
669
|
+
#### CrewAI
|
|
670
|
+
|
|
671
|
+
`Crew.kickoff()` 결과의 `tasks_output`에서 에이전트 간 상호작용을 추출합니다.
|
|
672
|
+
`output_pydantic` / `output_format` (v2.x) 필드를 지원합니다.
|
|
673
|
+
|
|
674
|
+
```python
|
|
675
|
+
from crewai import Crew, Agent, Task
|
|
676
|
+
from agent_evaluator.decorators import agent_eval
|
|
677
|
+
|
|
678
|
+
# tasks_output → agent_interactions 자동 변환
|
|
679
|
+
# 주의: CrewAI는 async 미지원 — 동기 함수로만 사용
|
|
680
|
+
@agent_eval(monitor, task_type="tool_use", framework="crewai")
|
|
681
|
+
def crew_agent(question: str, ground_truth: str = "") -> str:
|
|
682
|
+
result = crew.kickoff(inputs={"topic": question})
|
|
683
|
+
return str(result)
|
|
684
|
+
|
|
685
|
+
from agent_evaluator.integrations import crewai_eval
|
|
686
|
+
|
|
687
|
+
@crewai_eval(monitor, task_type="tool_use")
|
|
688
|
+
def crew_agent2(question: str, ground_truth: str = "") -> str:
|
|
689
|
+
return str(crew.kickoff(inputs={"topic": question}))
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### AutoGen
|
|
693
|
+
|
|
694
|
+
`chat_result.messages` / `chat_history`에서 대화 턴과 비용 정보를 추출합니다.
|
|
695
|
+
AutoGen 0.4+ async API는 `autogen_eval_async` 전용 데코레이터를 사용합니다.
|
|
696
|
+
|
|
697
|
+
```python
|
|
698
|
+
from autogen import ConversableAgent
|
|
699
|
+
from agent_evaluator.decorators import agent_eval
|
|
700
|
+
from agent_evaluator.integrations import autogen_eval, autogen_eval_async
|
|
701
|
+
|
|
702
|
+
# messages/chat_history → conversation_turns
|
|
703
|
+
# cost/usage_summary → tokens_used
|
|
704
|
+
@agent_eval(monitor, task_type="qa", framework="autogen")
|
|
705
|
+
def autogen_agent(question: str, ground_truth: str = "") -> str:
|
|
706
|
+
result = assistant.initiate_chat(user_proxy, message=question, max_turns=3)
|
|
707
|
+
return result.summary
|
|
708
|
+
|
|
709
|
+
# AutoGen 0.4+ async API 전용
|
|
710
|
+
@autogen_eval_async(monitor, task_type="qa")
|
|
711
|
+
async def autogen_agent_async(question: str, ground_truth: str = "") -> str:
|
|
712
|
+
result = await team.run(task=question)
|
|
713
|
+
return result.messages[-1].content
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
---
|
|
717
|
+
|
|
718
|
+
### LLM 공급자
|
|
719
|
+
|
|
720
|
+
#### OpenAI
|
|
721
|
+
|
|
722
|
+
`ChatCompletion` 응답의 `choices[0].message.tool_calls`와 `usage.total_tokens`를 자동 추출합니다.
|
|
723
|
+
Assistants API의 `required_action`도 지원합니다.
|
|
724
|
+
|
|
725
|
+
```python
|
|
726
|
+
import openai
|
|
727
|
+
from agent_evaluator.decorators import agent_eval
|
|
728
|
+
|
|
729
|
+
client = openai.OpenAI()
|
|
730
|
+
|
|
731
|
+
@agent_eval(monitor, task_type="tool_use", framework="openai")
|
|
732
|
+
def gpt_agent(question: str, ground_truth: str = "") -> str:
|
|
733
|
+
return client.chat.completions.create(
|
|
734
|
+
model="gpt-4o-mini",
|
|
735
|
+
messages=[{"role": "user", "content": question}],
|
|
736
|
+
tools=[...],
|
|
737
|
+
) # ChatCompletion 객체 그대로 반환 — choices[0].message.content 자동 추출
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
#### Anthropic
|
|
741
|
+
|
|
742
|
+
`Message` 응답의 `content[].tool_use`와 `usage.input_tokens/output_tokens`를 추출합니다.
|
|
743
|
+
캐시 토큰(`cache_creation_input_tokens`, `cache_read_input_tokens`, SDK ≥0.29)도 지원합니다.
|
|
744
|
+
|
|
745
|
+
```python
|
|
746
|
+
import anthropic
|
|
747
|
+
from agent_evaluator.decorators import agent_eval
|
|
748
|
+
|
|
749
|
+
client = anthropic.Anthropic()
|
|
750
|
+
|
|
751
|
+
@agent_eval(monitor, task_type="tool_use", framework="anthropic")
|
|
752
|
+
def claude_agent(question: str, ground_truth: str = "") -> str:
|
|
753
|
+
return client.messages.create(
|
|
754
|
+
model="claude-sonnet-4-6",
|
|
755
|
+
max_tokens=1024,
|
|
756
|
+
messages=[{"role": "user", "content": question}],
|
|
757
|
+
tools=[...],
|
|
758
|
+
) # Message 객체 그대로 반환 — content[0].text 자동 추출
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
#### Google Gemini / Vertex AI
|
|
762
|
+
|
|
763
|
+
`GenerateContentResponse`의 `candidates[0].content.parts[].function_call`과 `usage_metadata`를 추출합니다.
|
|
764
|
+
|
|
765
|
+
```python
|
|
766
|
+
import google.generativeai as genai
|
|
767
|
+
from agent_evaluator.decorators import agent_eval
|
|
768
|
+
|
|
769
|
+
model = genai.GenerativeModel("gemini-1.5-flash")
|
|
770
|
+
|
|
771
|
+
@agent_eval(monitor, task_type="tool_use", framework="gemini")
|
|
772
|
+
def gemini_agent(question: str, ground_truth: str = "") -> str:
|
|
773
|
+
return model.generate_content(question) # GenerateContentResponse 그대로 반환
|
|
774
|
+
|
|
775
|
+
# Vertex AI는 동일한 응답 구조 — framework="vertexai"
|
|
776
|
+
@agent_eval(monitor, task_type="tool_use", framework="vertexai")
|
|
777
|
+
def vertex_agent(question: str, ground_truth: str = "") -> str:
|
|
778
|
+
return vertex_model.generate_content(question)
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
#### Cohere
|
|
782
|
+
|
|
783
|
+
`NonStreamedChatResponse`의 `tool_calls`와 `meta.tokens`를 추출합니다.
|
|
784
|
+
스트리밍 응답(`finish_reason` 속성)도 자동 감지합니다.
|
|
785
|
+
|
|
786
|
+
```python
|
|
787
|
+
import cohere
|
|
788
|
+
from agent_evaluator.decorators import agent_eval
|
|
789
|
+
|
|
790
|
+
co = cohere.Client()
|
|
791
|
+
|
|
792
|
+
@agent_eval(monitor, task_type="tool_use", framework="cohere")
|
|
793
|
+
def cohere_agent(question: str, ground_truth: str = "") -> str:
|
|
794
|
+
return co.chat(message=question, tools=[...])
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
#### Groq
|
|
798
|
+
|
|
799
|
+
OpenAI 호환 API 구조 — `tool_calls`와 `usage`를 추출합니다.
|
|
800
|
+
캐시 토큰(`cache_creation_input_tokens`, `cache_read_input_tokens`, v0.9+)도 지원합니다.
|
|
801
|
+
|
|
802
|
+
```python
|
|
803
|
+
from groq import Groq
|
|
804
|
+
from agent_evaluator.decorators import agent_eval
|
|
805
|
+
|
|
806
|
+
client = Groq()
|
|
807
|
+
|
|
808
|
+
@agent_eval(monitor, task_type="tool_use", framework="groq")
|
|
809
|
+
def groq_agent(question: str, ground_truth: str = "") -> str:
|
|
810
|
+
return client.chat.completions.create(
|
|
811
|
+
model="llama-3.3-70b-versatile",
|
|
812
|
+
messages=[{"role": "user", "content": question}],
|
|
813
|
+
)
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
#### Mistral AI
|
|
817
|
+
|
|
818
|
+
`ChatCompletionResponse`의 `tool_calls`와 `usage`를 추출합니다.
|
|
819
|
+
구버전 `function_call` 필드도 지원합니다.
|
|
820
|
+
|
|
821
|
+
```python
|
|
822
|
+
from mistralai import Mistral
|
|
823
|
+
from agent_evaluator.decorators import agent_eval
|
|
824
|
+
|
|
825
|
+
client = Mistral()
|
|
826
|
+
|
|
827
|
+
@agent_eval(monitor, task_type="tool_use", framework="mistral")
|
|
828
|
+
def mistral_agent(question: str, ground_truth: str = "") -> str:
|
|
829
|
+
return client.chat.complete(
|
|
830
|
+
model="mistral-large-latest",
|
|
831
|
+
messages=[{"role": "user", "content": question}],
|
|
832
|
+
)
|
|
833
|
+
```
|
|
834
|
+
|
|
835
|
+
#### AWS Bedrock
|
|
836
|
+
|
|
837
|
+
Bedrock Converse API 응답에서 `model_id` 기반으로 Titan / Mistral on Bedrock / Claude 응답을 분기 처리합니다.
|
|
838
|
+
|
|
839
|
+
```python
|
|
840
|
+
import boto3
|
|
841
|
+
from agent_evaluator.decorators import agent_eval
|
|
842
|
+
|
|
843
|
+
client = boto3.client("bedrock-runtime", region_name="us-east-1")
|
|
844
|
+
|
|
845
|
+
@agent_eval(monitor, task_type="tool_use", framework="bedrock")
|
|
846
|
+
def bedrock_agent(question: str, ground_truth: str = "") -> str:
|
|
847
|
+
return client.converse(
|
|
848
|
+
modelId="anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
849
|
+
messages=[{"role": "user", "content": [{"text": question}]}],
|
|
850
|
+
)
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
#### Ollama
|
|
854
|
+
|
|
855
|
+
`ollama.chat()` / `ollama.generate()` 응답의 `tool_calls`와 `prompt_eval_count` / `eval_count`를 추출합니다.
|
|
856
|
+
주의: Ollama는 async 미지원입니다.
|
|
857
|
+
|
|
858
|
+
```python
|
|
859
|
+
import ollama
|
|
860
|
+
from agent_evaluator.decorators import agent_eval
|
|
861
|
+
|
|
862
|
+
@agent_eval(monitor, task_type="qa", framework="ollama")
|
|
863
|
+
def ollama_agent(question: str, ground_truth: str = "") -> str:
|
|
864
|
+
return ollama.chat(
|
|
865
|
+
model="llama3.2",
|
|
866
|
+
messages=[{"role": "user", "content": question}],
|
|
867
|
+
)
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
---
|
|
871
|
+
|
|
872
|
+
### AI 프레임워크
|
|
873
|
+
|
|
874
|
+
#### DSPy
|
|
875
|
+
|
|
876
|
+
`dspy.Prediction`의 `_completions` 속성에서 체인 단계를 추출합니다.
|
|
877
|
+
LM history 전체 multi-step도 지원합니다. 주의: DSPy는 async 미지원입니다.
|
|
878
|
+
|
|
879
|
+
```python
|
|
880
|
+
import dspy
|
|
881
|
+
from agent_evaluator.decorators import agent_eval
|
|
882
|
+
from agent_evaluator.integrations import dspy_eval
|
|
883
|
+
|
|
884
|
+
lm = dspy.LM("openai/gpt-4o-mini")
|
|
885
|
+
dspy.configure(lm=lm)
|
|
886
|
+
|
|
887
|
+
@agent_eval(monitor, task_type="qa", framework="dspy")
|
|
888
|
+
def dspy_agent(question: str, ground_truth: str = "") -> str:
|
|
889
|
+
predictor = dspy.Predict("question -> answer")
|
|
890
|
+
return predictor(question=question) # Prediction 객체 → .answer 자동 추출
|
|
891
|
+
|
|
892
|
+
@dspy_eval(monitor, task_type="qa")
|
|
893
|
+
def dspy_agent2(question: str, ground_truth: str = "") -> str:
|
|
894
|
+
return dspy.ChainOfThought("question -> answer")(question=question)
|
|
895
|
+
```
|
|
896
|
+
|
|
897
|
+
#### PydanticAI
|
|
898
|
+
|
|
899
|
+
`RunResult.all_messages()` (우선) 또는 `.messages` (fallback)에서 체인 단계를 추출합니다.
|
|
900
|
+
`ToolCallPart` / `ToolReturnPart` / `TextPart`를 세분화해 추출합니다.
|
|
901
|
+
|
|
902
|
+
```python
|
|
903
|
+
from pydantic_ai import Agent
|
|
904
|
+
from agent_evaluator.decorators import agent_eval
|
|
905
|
+
from agent_evaluator.integrations import pydanticai_eval
|
|
906
|
+
|
|
907
|
+
agent = Agent("openai:gpt-4o-mini", system_prompt="...")
|
|
908
|
+
|
|
909
|
+
@agent_eval(monitor, task_type="qa", framework="pydanticai")
|
|
910
|
+
async def pydantic_agent(question: str, ground_truth: str = "") -> str:
|
|
911
|
+
result = await agent.run(question)
|
|
912
|
+
return result # RunResult 객체 → .data 자동 추출
|
|
913
|
+
|
|
914
|
+
@pydanticai_eval(monitor, task_type="qa")
|
|
915
|
+
async def pydantic_agent2(question: str, ground_truth: str = "") -> str:
|
|
916
|
+
return await agent.run(question)
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
#### LlamaIndex
|
|
920
|
+
|
|
921
|
+
`Response.source_nodes`에서 체인 단계를 추출합니다.
|
|
922
|
+
`AgentChatResponse.sources`의 `ToolOutput`도 지원합니다.
|
|
923
|
+
|
|
924
|
+
```python
|
|
925
|
+
from llama_index.core import VectorStoreIndex
|
|
926
|
+
from agent_evaluator.decorators import agent_eval
|
|
927
|
+
|
|
928
|
+
index = VectorStoreIndex.from_documents([...])
|
|
929
|
+
query_engine = index.as_query_engine()
|
|
930
|
+
|
|
931
|
+
# source_nodes → chain_steps (score + metadata 포함)
|
|
932
|
+
@agent_eval(monitor, task_type="information_retrieval", framework="llamaindex", rag_mode=True)
|
|
933
|
+
def llamaindex_agent(question: str, ground_truth: str = "") -> str:
|
|
934
|
+
return query_engine.query(question)
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### Haystack
|
|
938
|
+
|
|
939
|
+
파이프라인 컴포넌트 출력 dict에서 retriever / generator / reader / embedder / ranker를 `chain_steps`로 추출합니다.
|
|
940
|
+
|
|
941
|
+
```python
|
|
942
|
+
from haystack import Pipeline
|
|
943
|
+
from agent_evaluator.decorators import agent_eval
|
|
944
|
+
|
|
945
|
+
pipeline = Pipeline()
|
|
946
|
+
# ... 컴포넌트 추가 ...
|
|
947
|
+
|
|
948
|
+
# 컴포넌트 출력 dict → chain_steps
|
|
949
|
+
@agent_eval(monitor, task_type="information_retrieval", framework="haystack", rag_mode=True)
|
|
950
|
+
def haystack_agent(question: str, ground_truth: str = "") -> str:
|
|
951
|
+
return pipeline.run({"query": question})
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
#### Semantic Kernel
|
|
955
|
+
|
|
956
|
+
`inner_content`에서 OpenAI / Anthropic 백엔드 토큰을 자동 추출합니다.
|
|
957
|
+
`function_name` + `plugin_name` → `"Plugin.function"` 형식 툴 호출도 지원합니다.
|
|
958
|
+
|
|
959
|
+
```python
|
|
960
|
+
import semantic_kernel as sk
|
|
961
|
+
from agent_evaluator.decorators import agent_eval
|
|
962
|
+
|
|
963
|
+
kernel = sk.Kernel()
|
|
964
|
+
|
|
965
|
+
# inner_content → tokens_used (OpenAI/Anthropic 백엔드 자동 감지)
|
|
966
|
+
@agent_eval(monitor, task_type="tool_use", framework="semantic_kernel")
|
|
967
|
+
async def sk_agent(question: str, ground_truth: str = "") -> str:
|
|
968
|
+
result = await kernel.invoke(plugin_name, function_name, input=question)
|
|
969
|
+
return str(result)
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
#### HuggingFace smolagents
|
|
973
|
+
|
|
974
|
+
`ToolCall` 스텝 목록에서 성공/실패 여부와 입력값을 정규화해 `tool_calls` + `chain_steps`로 추출합니다.
|
|
975
|
+
주의: smolagents는 async 미지원입니다.
|
|
976
|
+
|
|
977
|
+
```python
|
|
978
|
+
from smolagents import CodeAgent, HfApiModel
|
|
979
|
+
from agent_evaluator.decorators import agent_eval
|
|
980
|
+
|
|
981
|
+
model = HfApiModel()
|
|
982
|
+
agent = CodeAgent(tools=[...], model=model)
|
|
983
|
+
|
|
984
|
+
@agent_eval(monitor, task_type="tool_use", framework="smolagents")
|
|
985
|
+
def smol_agent(question: str, ground_truth: str = "") -> str:
|
|
986
|
+
return agent.run(question)
|
|
987
|
+
```
|
|
988
|
+
|
|
989
|
+
#### vLLM
|
|
990
|
+
|
|
991
|
+
OpenAI 호환 API — `choices[0].message.tool_calls`와 `usage.total_tokens`를 추출합니다.
|
|
992
|
+
|
|
993
|
+
```python
|
|
994
|
+
from openai import OpenAI # vLLM은 OpenAI 호환 클라이언트 사용
|
|
995
|
+
from agent_evaluator.decorators import agent_eval
|
|
996
|
+
|
|
997
|
+
client = OpenAI(base_url="http://localhost:8000/v1", api_key="vllm")
|
|
998
|
+
|
|
999
|
+
@agent_eval(monitor, task_type="qa", framework="vllm")
|
|
1000
|
+
def vllm_agent(question: str, ground_truth: str = "") -> str:
|
|
1001
|
+
return client.chat.completions.create(
|
|
1002
|
+
model="meta-llama/Llama-3.2-3B-Instruct",
|
|
1003
|
+
messages=[{"role": "user", "content": question}],
|
|
1004
|
+
)
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
#### HuggingFace
|
|
1008
|
+
|
|
1009
|
+
`pipeline()` 결과의 `generated_text`에서 체인 단계를, `actions` / `tool_calls` 필드에서 툴 호출을 추출합니다.
|
|
1010
|
+
주의: HuggingFace는 async 미지원입니다.
|
|
1011
|
+
|
|
1012
|
+
```python
|
|
1013
|
+
from transformers import pipeline
|
|
1014
|
+
from agent_evaluator.decorators import agent_eval
|
|
1015
|
+
|
|
1016
|
+
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-1.5B-Instruct")
|
|
1017
|
+
|
|
1018
|
+
@agent_eval(monitor, task_type="qa", framework="huggingface")
|
|
1019
|
+
def hf_agent(question: str, ground_truth: str = "") -> str:
|
|
1020
|
+
return pipe(question, max_new_tokens=200)
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
### 자동 감지 (`auto_detect_framework=True`)
|
|
1026
|
+
|
|
1027
|
+
`auto_detect_framework=True`(기본값)이면 반환 객체의 속성을 검사해 프레임워크를 자동 판별합니다.
|
|
1028
|
+
|
|
1029
|
+
| 감지 조건 | 판별 프레임워크 |
|
|
1030
|
+
|---------|--------------|
|
|
1031
|
+
| `stop_reason` 속성 존재 (choices 없음) | `anthropic` |
|
|
1032
|
+
| `choices` + `usage` 속성 존재 | `openai` |
|
|
1033
|
+
| `candidates` + `usage_metadata` 속성 존재 | `gemini` |
|
|
1034
|
+
| `meta.tokens` 속성 존재 (choices 없음) | `cohere` |
|
|
1035
|
+
| `x_groq` 속성 존재 | `groq` |
|
|
1036
|
+
| `choices[0].finish_reason` == `"stop"` + mistral 힌트 | `mistral` |
|
|
1037
|
+
| `ResponseMetadata` + `bedrock` 힌트 | `bedrock` |
|
|
1038
|
+
| `step_results` 속성 존재 | `smolagents` |
|
|
1039
|
+
| `completions` 속성 + DSPy 타입명 | `dspy` |
|
|
1040
|
+
| `all_messages` callable 존재 | `pydanticai` |
|
|
1041
|
+
|
|
1042
|
+
```python
|
|
1043
|
+
# framework= 생략 → 자동 감지 (기본값)
|
|
1044
|
+
@agent_eval(monitor, task_type="qa")
|
|
1045
|
+
def auto_agent(question: str, ground_truth: str = "") -> str:
|
|
1046
|
+
return client.chat.completions.create(...) # OpenAI → 자동 "openai" 판별
|
|
1047
|
+
|
|
1048
|
+
# 자동 감지 명시적 비활성화 (framework= 고정 우선)
|
|
1049
|
+
@agent_eval(monitor, task_type="qa", framework="openai", auto_detect_framework=False)
|
|
1050
|
+
def fixed_agent(question: str, ground_truth: str = "") -> str:
|
|
1051
|
+
return client.chat.completions.create(...)
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
---
|
|
1055
|
+
|
|
1056
|
+
## 25개 지표와 데코레이터 활성화 조건
|
|
1057
|
+
|
|
1058
|
+
### Layer 1 — 기초 지표 (기본 데코레이터로 자동 활성)
|
|
1059
|
+
|
|
1060
|
+
| 지표 | 클래스 | 데코레이터 자동화 | 주요 출력 |
|
|
1061
|
+
|------|--------|----------------|---------|
|
|
1062
|
+
| **Task Completion Rate** | `TaskCompletionTracker` | 항상 활성 | `tcr` · `full_success` · `partial_success` · `failures` |
|
|
1063
|
+
| **Accuracy** | `AccuracyEvaluator` | 항상 활성 (`score_fn` 없으면 기본 알고리즘) | `overall_accuracy` · `median_accuracy` · `std_accuracy` |
|
|
1064
|
+
| **Response Quality** | `ResponseQualityEvaluator` | response + request 있으면 자동 | `dimension_scores` · `total_score` (0–5) · `grade` |
|
|
1065
|
+
| **Latency** | `LatencyTracker` | 함수 실행 시간 자동 측정 | `mean` · `p50` · `p90` · `p95` · `p99` · `std` |
|
|
1066
|
+
| **Token Economy** | `TokenEconomyTracker` | 프레임워크 어댑터 자동 추출 | `total_tokens` · `total_cost` · `estimated_monthly_cost` |
|
|
1067
|
+
| **Hallucination** | `HallucinationDetector` | `rag_mode=True` 또는 `enable_hallucination=True` | `hallucination_rate` · `unsupported_claims_count` · `by_severity` |
|
|
1068
|
+
|
|
1069
|
+
Accuracy 계산 방식: Token Overlap(40%) + Jaccard Similarity(30%) + LCS(20%) + 문자 유사도(10%)
|
|
1070
|
+
|
|
1071
|
+
### Layer 2-A — 에이전틱 지표 (tool_calls · chain_steps 자동 추출 시 활성)
|
|
1072
|
+
|
|
1073
|
+
| 지표 | 클래스 | 활성화 조건 | 주요 출력 |
|
|
1074
|
+
|------|--------|-----------|---------|
|
|
1075
|
+
| **Tool Call Analysis** | `ToolCallAnalyzer` | `tool_calls` 자동 추출 또는 EvalMetadata | `efficiency_score` · `redundancy_rate` · `failure_rate` |
|
|
1076
|
+
| **Retry & Correction** | `RetryCorrectionTracker` | `max_retries` 파라미터 또는 `attempts` 필드 | `retry_rate` · `first_attempt_success_rate` · `correction_success_rate` |
|
|
1077
|
+
| **Tool Selection F1** | `ToolSelectionTracker` | `expected_tools_arg` 파라미터 지정 | `precision` · `recall` · `f1_score` |
|
|
1078
|
+
| **Agent Coordination** | `AgentCoordinationTracker` | `agent_interactions` 자동 추출 | `score` · `pattern_type` · `unique_agents` |
|
|
1079
|
+
| **Workflow Execution** | `WorkflowExecutionTracker` | `chain_steps` · `state_transitions` 자동 추출 | `step_success_rate` · `task_success_rate` · `bottlenecks` |
|
|
1080
|
+
|
|
1081
|
+
### Layer 2-B — 보안 지표 (`security_mode=True` 또는 Monitor 전역 설정)
|
|
1082
|
+
|
|
1083
|
+
| 지표 | 클래스 | 탐지 대상 | 주요 출력 |
|
|
1084
|
+
|------|--------|---------|---------|
|
|
1085
|
+
| **Input Sanitization** | `InputSanitizationTracker` | SQL Injection · Command Injection · XSS · Prompt Injection (40개 패턴) | `risk_level` · `threat_count` · `threat_rate` |
|
|
1086
|
+
| **Output Leakage** | `OutputLeakageDetector` | API 키 · 비밀번호 · 신용카드 · 개인정보 | `severity` · `leakage_count` · `leakage_rate` |
|
|
1087
|
+
| **Tool Authorization** | `ToolAuthorizationTracker` | 비인가 툴 사용 · 위험 파라미터 | `compliance_rate` · `violation_rate` · `unauthorized_calls` |
|
|
1088
|
+
| **Privilege Escalation** | `PrivilegeEscalationDetector` | guest→admin 권한 상승 체인 | `risk_score` (0–10) · `escalation_detected` · `escalation_path` |
|
|
1089
|
+
| **Tool Chain Attack** | `ToolChainAttackDetector` | 데이터 유출 · 횡적 이동 · 지속성 공격 체인 | `confidence` (0–1) · `attack_types` · `is_suspicious_chain` |
|
|
1090
|
+
|
|
1091
|
+
보안 지표 활성화 방법:
|
|
1092
|
+
|
|
1093
|
+
```python
|
|
1094
|
+
# 방법 A: 특정 함수에만 임시 활성 (이 호출만)
|
|
1095
|
+
@agent_eval(monitor, task_type="qa", security_mode=True)
|
|
1096
|
+
def secure_agent(question, ground_truth=""): ...
|
|
1097
|
+
|
|
1098
|
+
# 방법 B: Monitor 전역 설정 (모든 record_task에 적용)
|
|
1099
|
+
monitor = PerformanceMonitor("results/", enable_security_metrics=True)
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
### Layer 3 — 하이브리드 평가 (외부 라이브러리)
|
|
1103
|
+
|
|
1104
|
+
```python
|
|
1105
|
+
from agent_evaluator import HybridPerformanceMonitor
|
|
1106
|
+
|
|
1107
|
+
monitor = HybridPerformanceMonitor(
|
|
1108
|
+
use_deepeval=True, # pip install "agent-evaluator[eval]"
|
|
1109
|
+
use_ragas=True,
|
|
1110
|
+
output_dir="results/",
|
|
1111
|
+
)
|
|
1112
|
+
|
|
1113
|
+
# HybridPerformanceMonitor는 PerformanceMonitor 상속 — 3종 데코레이터 모두 동일하게 사용
|
|
1114
|
+
@agent_eval(monitor, task_type="information_retrieval", rag_mode=True, context_arg="context")
|
|
1115
|
+
def rag_agent(question, context="", ground_truth=""): ...
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
| 제공자 | 지표 | 조건 |
|
|
1119
|
+
|--------|------|------|
|
|
1120
|
+
| **DeepEval** | G-Eval · Hallucination · Toxicity · Bias · Answer Relevancy | `pip install "agent-evaluator[eval]"` |
|
|
1121
|
+
| **Ragas** | Faithfulness · Answer Relevancy · Context Precision · Context Recall | 동일 + `context` 필드 필요 |
|
|
1122
|
+
| **LangSmith** | Latency · Token · Feedback | `LANGSMITH_API_KEY` 환경변수 |
|
|
1123
|
+
|
|
1124
|
+
---
|
|
1125
|
+
|
|
1126
|
+
## CI/CD 품질 게이팅
|
|
1127
|
+
|
|
1128
|
+
### 코드에서 직접
|
|
1129
|
+
|
|
1130
|
+
```python
|
|
1131
|
+
eval = QuickEval("results/")
|
|
1132
|
+
|
|
1133
|
+
@eval.qa
|
|
1134
|
+
def agent(question, ground_truth=""): ...
|
|
1135
|
+
|
|
1136
|
+
# 평가 실행 후
|
|
1137
|
+
eval.gate(tcr=85, accuracy=70, quality=3.5, hallucination=5)
|
|
1138
|
+
# 임계값 미달 시 sys.exit(1) — CI 파이프라인 실패 처리
|
|
1139
|
+
```
|
|
1140
|
+
|
|
1141
|
+
### CLI (GitHub Actions)
|
|
1142
|
+
|
|
1143
|
+
```yaml
|
|
1144
|
+
- name: Run Evaluation
|
|
1145
|
+
run: python eval_suite.py --output results/ci.json
|
|
1146
|
+
|
|
1147
|
+
- name: Quality Gate
|
|
1148
|
+
run: |
|
|
1149
|
+
agent-eval gate results/ci.json \
|
|
1150
|
+
--tcr 85 --accuracy 70 --p95-latency 3.0 --hallucination 5
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
`agent-eval gate` 옵션:
|
|
1154
|
+
|
|
1155
|
+
| 옵션 | 설명 |
|
|
1156
|
+
|------|------|
|
|
1157
|
+
| `--tcr N` | Task Completion Rate 최소값 (%) |
|
|
1158
|
+
| `--accuracy N` | 정확도 최소값 (%) |
|
|
1159
|
+
| `--p95-latency N` | P95 지연시간 최대값 (초) |
|
|
1160
|
+
| `--hallucination N` | 환각 탐지율 최대값 (%) |
|
|
1161
|
+
| `--llm-judge N` | LLM Judge 종합 점수 최소값 (0–5) |
|
|
1162
|
+
| `--fail-on-regression N` | 이전 기준선 대비 허용 하락 비율 (%) |
|
|
1163
|
+
| `--junit-xml PATH` | JUnit XML 출력 (CI 연동) |
|
|
1164
|
+
|
|
1165
|
+
**종료 코드:** `0` = 전체 통과 / `1` = 임계값 미달 / `2` = 회귀 감지
|
|
1166
|
+
|
|
1167
|
+
---
|
|
1168
|
+
|
|
1169
|
+
## 조건부 알림
|
|
1170
|
+
|
|
1171
|
+
3종 데코레이터 모두 동일한 `alert_rules=` API를 지원합니다.
|
|
1172
|
+
|
|
1173
|
+
```python
|
|
1174
|
+
from agent_evaluator.decorators import AlertRuleBuilder
|
|
1175
|
+
|
|
1176
|
+
slow_rule = AlertRuleBuilder.when_latency_above(3.0, handler=lambda msg, tr: print(f"[SLOW] {msg}"))
|
|
1177
|
+
error_rule = AlertRuleBuilder.when_accuracy_below(0.7, handler=lambda msg, tr: send_slack(msg))
|
|
1178
|
+
fail_rule = AlertRuleBuilder.when_completion_below(0.8, handler=lambda msg, tr: send_alert(msg))
|
|
1179
|
+
|
|
1180
|
+
# 3종 데코레이터 모두 동일하게 적용
|
|
1181
|
+
@agent_eval(monitor, task_type="qa", alert_rules=[slow_rule, error_rule])
|
|
1182
|
+
def agent(question, ground_truth=""): ...
|
|
1183
|
+
|
|
1184
|
+
@batch_eval(monitor, task_type="qa", alert_rules=[slow_rule])
|
|
1185
|
+
def batch_agent(questions, ground_truths=None): ...
|
|
1186
|
+
|
|
1187
|
+
@conversation_eval(monitor, max_turns=5, alert_rules=[fail_rule])
|
|
1188
|
+
def chat(question, session_id="s1"): ...
|
|
1189
|
+
```
|
|
1190
|
+
|
|
1191
|
+
---
|
|
1192
|
+
|
|
1193
|
+
## 주기적 자동 저장 (`flush_every`)
|
|
1194
|
+
|
|
1195
|
+
프로세스가 중간에 종료되어도 결과가 보존됩니다. 3종 데코레이터 모두 지원합니다.
|
|
1196
|
+
|
|
1197
|
+
```python
|
|
1198
|
+
@agent_eval(monitor, task_type="qa", flush_every=10, flush_filename="checkpoint")
|
|
1199
|
+
def agent(question, ground_truth=""): ...
|
|
1200
|
+
|
|
1201
|
+
@batch_eval(monitor, task_type="qa", flush_every=5, flush_filename="batch_cp")
|
|
1202
|
+
def batch_agent(questions, ground_truths=None): ...
|
|
1203
|
+
|
|
1204
|
+
# QuickEval에서도 동일
|
|
1205
|
+
eval = QuickEval("results/", auto_save=True, auto_save_interval=10)
|
|
1206
|
+
```
|
|
1207
|
+
|
|
1208
|
+
---
|
|
1209
|
+
|
|
1210
|
+
## preset — 환경별 설정 묶음
|
|
1211
|
+
|
|
1212
|
+
3종 데코레이터 모두 동일한 `preset=` 파라미터를 지원합니다.
|
|
1213
|
+
|
|
1214
|
+
| preset | 자동 적용 설정 | 환경 |
|
|
1215
|
+
|--------|-------------|-----|
|
|
1216
|
+
| `"production"` | `flush_every=50` · `enable_anomaly_detection=True` · `sample_rate=0.1` | 운영 서버 |
|
|
1217
|
+
| `"development"` | `enable_llm_judge=True` · `auto_detect_framework=True` | 개발·디버깅 |
|
|
1218
|
+
| `"testing"` | `sample_rate=1.0` · `timeout=10.0` | 단위 테스트 |
|
|
1219
|
+
| `"canary"` | `sample_rate=0.01` · `flush_every=100` | 카나리 배포 |
|
|
1220
|
+
|
|
1221
|
+
```python
|
|
1222
|
+
@agent_eval(monitor, task_type="qa", preset="production")
|
|
1223
|
+
@batch_eval(monitor, task_type="qa", preset="testing")
|
|
1224
|
+
@conversation_eval(monitor, max_turns=5, preset="development")
|
|
1225
|
+
```
|
|
1226
|
+
|
|
1227
|
+
---
|
|
1228
|
+
|
|
1229
|
+
## CLI 명령어
|
|
1230
|
+
|
|
1231
|
+
| 명령어 | 설명 |
|
|
1232
|
+
|--------|------|
|
|
1233
|
+
| `agent-eval init` | 대화형 API 키 설정 마법사 |
|
|
1234
|
+
| `agent-eval check` | 현재 설정 상태 및 API 키 확인 |
|
|
1235
|
+
| `agent-eval dashboard [dir]` | FastAPI 대시보드 웹 서버 실행 |
|
|
1236
|
+
| `agent-eval gate <result.json>` | CI/CD 품질 게이팅 |
|
|
1237
|
+
| `agent-eval dataset build <dir>` | 운영 결과에서 골든 데이터셋 자동 추출 |
|
|
1238
|
+
| `agent-eval monitor` | Arize Phoenix + OTEL 실시간 모니터링 |
|
|
1239
|
+
| `agent-eval --version` | 패키지 버전 출력 |
|
|
1240
|
+
|
|
1241
|
+
---
|
|
1242
|
+
|
|
1243
|
+
## 평가 결과 시각화
|
|
1244
|
+
|
|
1245
|
+
### FastAPI 대시보드
|
|
1246
|
+
|
|
1247
|
+
```bash
|
|
1248
|
+
pip install "agent-evaluator[serve]"
|
|
1249
|
+
agent-eval dashboard results/ --watch # 파일 변경 시 자동 갱신
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
| URL | 내용 |
|
|
1253
|
+
|-----|------|
|
|
1254
|
+
| `http://localhost:8765` | 메인 대시보드 |
|
|
1255
|
+
| `http://localhost:8765/slides` | 발표용 슬라이드 뷰 |
|
|
1256
|
+
| `http://localhost:8765/api/docs` | Swagger API 문서 |
|
|
1257
|
+
|
|
1258
|
+
### Phoenix 실시간 모니터링
|
|
1259
|
+
|
|
1260
|
+
```bash
|
|
1261
|
+
pip install "agent-evaluator[otel]"
|
|
1262
|
+
agent-eval monitor # http://localhost:6006
|
|
1263
|
+
```
|
|
1264
|
+
|
|
1265
|
+
에이전트 실행 시 OTLP 스팬이 자동 전송됩니다. Tracing · Evaluators · Datasets · Prompts 4개 메뉴에서 실시간 확인 가능합니다.
|
|
1266
|
+
|
|
1267
|
+
---
|
|
1268
|
+
|
|
1269
|
+
## 공개 API
|
|
1270
|
+
|
|
1271
|
+
```python
|
|
1272
|
+
from agent_evaluator import (
|
|
1273
|
+
PerformanceMonitor, # 평가 오케스트레이터
|
|
1274
|
+
QuickEval, # 원스톱 Facade
|
|
1275
|
+
HybridPerformanceMonitor, # Layer 3 포함 모니터
|
|
1276
|
+
TaskResult, TaskType, EvaluationReport,
|
|
1277
|
+
create_taskresult,
|
|
1278
|
+
evaluation_session, async_evaluation_session,
|
|
1279
|
+
ConversationSession, ConversationMetrics, ConversationTurn,
|
|
1280
|
+
LLMJudge,
|
|
1281
|
+
SimpleTaskAlertRule, AlertRuleBuilder,
|
|
1282
|
+
)
|
|
1283
|
+
|
|
1284
|
+
from agent_evaluator.decorators import (
|
|
1285
|
+
# ── 3종 핵심 데코레이터 ──────────────────
|
|
1286
|
+
agent_eval, # 단일 태스크 (1호출 → 1 TaskResult)
|
|
1287
|
+
batch_eval, # 배치 평가 (1호출 → N TaskResult)
|
|
1288
|
+
conversation_eval, # 멀티턴 대화 (N호출 → 1 TaskResult)
|
|
1289
|
+
|
|
1290
|
+
# ── 통합 팩토리 & 탈출구 ─────────────────
|
|
1291
|
+
EvalDecorator, # 3종 공통 설정 팩토리
|
|
1292
|
+
eval_context, # 데코레이터 불가 시 컨텍스트 매니저
|
|
1293
|
+
|
|
1294
|
+
# ── 메타데이터 & 유틸리티 ────────────────
|
|
1295
|
+
EvalMetadata, # agent_eval / batch_eval 추가 메타데이터
|
|
1296
|
+
TurnMetadata, # conversation_eval 턴별 메타데이터
|
|
1297
|
+
get_eval_ctx, # 스레드 로컬 평가 컨텍스트 접근
|
|
1298
|
+
FrameworkLiteral, # 21개 프레임워크 타입 힌트
|
|
1299
|
+
get_framework_info, # 프레임워크 어댑터 정보 조회
|
|
1300
|
+
AlertRuleBuilder, # 알림 규칙 팩토리
|
|
1301
|
+
flush_conversation, # 대화 세션 수동 종료
|
|
1302
|
+
flush_all_conversations,
|
|
1303
|
+
)
|
|
1304
|
+
```
|
|
1305
|
+
|
|
1306
|
+
---
|
|
1307
|
+
|
|
1308
|
+
## 예제 가이드
|
|
1309
|
+
|
|
1310
|
+
```bash
|
|
1311
|
+
cd Evaluator_Examples
|
|
1312
|
+
|
|
1313
|
+
# ── 3종 데코레이터 핵심 예제 ─────────────────────────────────
|
|
1314
|
+
python 18_decorator_eval.py # @agent_eval 기본 예제
|
|
1315
|
+
python 19_decorator_coverage_expanded.py # 3종 데코레이터 커버리지 검증
|
|
1316
|
+
python 20_quickeval_demo.py # QuickEval 원스톱 Facade (7섹션)
|
|
1317
|
+
python 21_layer2_agentic_eval.py # Layer 2 Agentic 활성화 가이드
|
|
1318
|
+
|
|
1319
|
+
# ── Layer별 지표 검증 ─────────────────────────────────────────
|
|
1320
|
+
python 01_quality_eval.py # @agent_eval — Accuracy · Hallucination · Quality
|
|
1321
|
+
python 02_performance_eval.py # @agent_eval — TCR · Latency · Token Economy
|
|
1322
|
+
python 03_agentic_eval.py # @agent_eval — Tool · Coordination · Workflow
|
|
1323
|
+
python 04_security_eval.py # @agent_eval — 보안 5종
|
|
1324
|
+
python 05_hybrid_eval.py # @batch_eval + HybridPerformanceMonitor — DeepEval · Ragas
|
|
1325
|
+
|
|
1326
|
+
# ── 프레임워크별 어댑터 ──────────────────────────────────────
|
|
1327
|
+
python 06_langchain_eval.py # @agent_eval(framework="langchain")
|
|
1328
|
+
python 07_langgraph_eval.py # @agent_eval(framework="langgraph")
|
|
1329
|
+
python 08_crewai_eval.py # @agent_eval(framework="crewai")
|
|
1330
|
+
python 09_autogen_eval.py # @agent_eval(framework="autogen")
|
|
1331
|
+
python 10_cross_framework_eval.py # @batch_eval + 멀티 프레임워크 비교
|
|
1332
|
+
|
|
1333
|
+
# ── 고급 기능 ────────────────────────────────────────────────
|
|
1334
|
+
python 11_streaming_eval.py # StreamingEvaluator — 실시간 슬라이딩 윈도우 + ImplicitFeedback
|
|
1335
|
+
python 12_alerting_eval.py # @agent_eval(alert_rules=[...]) + AlertEngine 패턴 비교
|
|
1336
|
+
python 13_golden_set_build.py # @batch_eval — 골든 데이터셋 빌더
|
|
1337
|
+
python 14_anomaly_cost_eval.py # @agent_eval(flush_every=10) — 이상 감지 + 비용 추적
|
|
1338
|
+
python 15_conversation_eval.py # @conversation_eval
|
|
1339
|
+
python 16_dashboard_demo.py # save_to_file + Phoenix OTEL 대시보드 연동
|
|
1340
|
+
python 17_phoenix_verification.py # @agent_eval + Phoenix 4개 메뉴 통합 검증
|
|
1341
|
+
|
|
1342
|
+
# ── 인프라 ───────────────────────────────────────────────────
|
|
1343
|
+
agent-eval monitor # Phoenix 서버 기동 (http://localhost:6006)
|
|
1344
|
+
agent-eval dashboard --watch # 대시보드 (http://localhost:8765)
|
|
1345
|
+
```
|
|
1346
|
+
|
|
1347
|
+
---
|
|
1348
|
+
|
|
1349
|
+
## 프로젝트 구조
|
|
1350
|
+
|
|
1351
|
+
```
|
|
1352
|
+
agent-evaluator/
|
|
1353
|
+
├── agent_evaluator/
|
|
1354
|
+
│ ├── decorators.py # agent_eval · batch_eval · conversation_eval
|
|
1355
|
+
│ │ # EvalDecorator · eval_context · EvalMetadata · TurnMetadata
|
|
1356
|
+
│ ├── quick_eval.py # QuickEval — 원스톱 Facade
|
|
1357
|
+
│ ├── core/
|
|
1358
|
+
│ │ ├── trackers/
|
|
1359
|
+
│ │ │ ├── base.py # TaskResult · EvaluationReport · TaskType
|
|
1360
|
+
│ │ │ ├── layer1.py # Foundation 지표 6종
|
|
1361
|
+
│ │ │ ├── layer2.py # Agentic 지표 5종
|
|
1362
|
+
│ │ │ ├── security.py # 보안 지표 5종
|
|
1363
|
+
│ │ │ ├── monitor.py # PerformanceMonitor (오케스트레이터)
|
|
1364
|
+
│ │ │ ├── conversation.py # ConversationSession · ConversationMetrics
|
|
1365
|
+
│ │ │ └── feedback.py # ImplicitFeedbackTracker
|
|
1366
|
+
│ │ ├── otel/ # OpenTelemetry 통합 ([otel] extras)
|
|
1367
|
+
│ │ ├── hybrid_monitor.py # HybridPerformanceMonitor
|
|
1368
|
+
│ │ └── monitor_context.py # evaluation_session · async_evaluation_session
|
|
1369
|
+
│ ├── integrations/
|
|
1370
|
+
│ │ ├── llm_judge.py # LLMJudge
|
|
1371
|
+
│ │ └── metric_adapters.py # DeepEval · Ragas · LangSmith 어댑터
|
|
1372
|
+
│ ├── serve/ # FastAPI 대시보드 ([serve] extras)
|
|
1373
|
+
│ ├── cli/ # agent-eval CLI
|
|
1374
|
+
│ ├── alerts/ # AlertEngine · SimpleTaskAlertRule
|
|
1375
|
+
│ ├── anomaly/ # AnomalyDetector
|
|
1376
|
+
│ ├── cost/ # CostTracker · AdaptivePolicy
|
|
1377
|
+
│ └── datasets/ # GoldenSetBuilder
|
|
1378
|
+
│
|
|
1379
|
+
├── Evaluator_Examples/ # 예제 21개
|
|
1380
|
+
├── tests/ # 1,823개 테스트 함수, 59개 파일
|
|
1381
|
+
└── pyproject.toml
|
|
1382
|
+
```
|
|
1383
|
+
|
|
1384
|
+
---
|
|
1385
|
+
|
|
1386
|
+
## 요구사항
|
|
1387
|
+
|
|
1388
|
+
| 패키지 | 버전 | 용도 |
|
|
1389
|
+
|--------|------|------|
|
|
1390
|
+
| `numpy` | >=1.20.0, <3.0.0 | 수치 연산 |
|
|
1391
|
+
| `pandas` | >=1.3.0, <4.0.0 | 지표 집계 |
|
|
1392
|
+
| `python-dotenv` | >=0.19.0, <2.0.0 | 환경변수 관리 |
|
|
1393
|
+
|
|
1394
|
+
| Extra | 패키지 | 속도 |
|
|
1395
|
+
|-------|--------|------|
|
|
1396
|
+
| `[llm]` | openai · anthropic | 빠름 |
|
|
1397
|
+
| `[langchain]` | langchain ≥1.0 · langgraph ≥1.0 | 중간 |
|
|
1398
|
+
| `[crewai]` | crewai ≥1.0 | 무거움 (단독 격리) |
|
|
1399
|
+
| `[autogen]` | pyautogen ≥0.3 | 무거움 (단독 격리) |
|
|
1400
|
+
| `[eval]` | deepeval · ragas ≥0.4 · datasets ≥4.0 | 무거움 |
|
|
1401
|
+
| `[serve]` | fastapi · uvicorn · jinja2 | 빠름 |
|
|
1402
|
+
| `[otel]` | opentelemetry-sdk · arize-phoenix | 중간 |
|
|
1403
|
+
| `[all]` | llm + langchain + eval + serve (권장) | 중간 |
|
|
1404
|
+
| `[full]` | 전체 ⚠️ 10분+ | 매우 무거움 |
|
|
1405
|
+
|
|
1406
|
+
---
|
|
1407
|
+
|
|
1408
|
+
## 개발 환경
|
|
1409
|
+
|
|
1410
|
+
```bash
|
|
1411
|
+
git clone https://github.com/bullpeng72/Agent-Evaluator.git
|
|
1412
|
+
cd Agent-Evaluator
|
|
1413
|
+
pip install -e ".[dev]"
|
|
1414
|
+
|
|
1415
|
+
pytest # 테스트 실행 (1,823개)
|
|
1416
|
+
ruff check agent_evaluator/ # 린트
|
|
1417
|
+
ruff format agent_evaluator/ # 포맷
|
|
1418
|
+
mypy agent_evaluator/ # 타입 검사
|
|
1419
|
+
```
|
|
1420
|
+
|
|
1421
|
+
---
|
|
1422
|
+
|
|
1423
|
+
## 변경 이력
|
|
1424
|
+
|
|
1425
|
+
### v0.7.4 (2026-04-08) — 전체 예제 데코레이터 적용 완료 · layer1 버그 수정 · 문서 현행화
|
|
1426
|
+
|
|
1427
|
+
- ✨ 예제 19/21 `@agent_eval` / `@batch_eval` / `@conversation_eval` 전면 적용 (02, 03, 17 추가 완성)
|
|
1428
|
+
- 🐛 `layer1.py` 성능 지표 계산 버그 수정
|
|
1429
|
+
- 🔧 대시보드 템플릿(`dashboard.html.j2` 등) 마이너 개선
|
|
1430
|
+
- 📝 테스트 파일 수 60→59 반영, Docs/ 버전·날짜 갱신
|
|
1431
|
+
- ✅ 21개 예제 전수 실행 검증 완료
|
|
1432
|
+
|
|
1433
|
+
### v0.7.3 (2026-04-07) — 보안 트래커 실동작 · 커버리지 전면 확대 · Phoenix 통합 완성
|
|
1434
|
+
|
|
1435
|
+
- **보안 메트릭 실동작** — `record_task()`에서 5개 보안 트래커 누락 호출 버그 수정 (CRITICAL)
|
|
1436
|
+
- **프레임워크 어댑터 확대** — AutoGen `agent_interactions`/`state_transitions`; Haystack/SK `tool_calls`; PydanticAI/LlamaIndex `tool_calls`; CrewAI `state_transitions`
|
|
1437
|
+
- **Phoenix 통합 완성** — Prompts 탭(`llm.prompts`) + Datasets 탭(`dataset.id`) + `ae.tool_names` span 속성 추가
|
|
1438
|
+
- **대시보드 API** — `security_incidents_count` · `has_multimodal` · `multimodal_task_count` 목록뷰 노출
|
|
1439
|
+
|
|
1440
|
+
### v0.7.2 (2026-04-05) — 3종 데코레이터 API 완성 · 21개 프레임워크 어댑터 · 대시보드 API 확장
|
|
1441
|
+
|
|
1442
|
+
- **3종 데코레이터 API 완성** — `agent_eval` / `batch_eval` / `conversation_eval` / `EvalDecorator` 파라미터 일관성 확보; `alert_rules` · `flush_every` · `preset` 3종 공통 적용
|
|
1443
|
+
- **21개 프레임워크 어댑터** — `auto_detect_framework=True` 기본 활성; `FrameworkLiteral` 타입 힌트; `_FRAMEWORK_ADAPTER_META` 레지스트리
|
|
1444
|
+
- **`preset` 파라미터** — `production` / `development` / `testing` / `canary` 3종 데코레이터 공통 지원
|
|
1445
|
+
- **`AlertRuleBuilder`** — `when_accuracy_below()` · `when_latency_above()` · `when_completion_below()` · `when_error()` · `when_tool_calls_exceed()` 5개 팩토리 메서드
|
|
1446
|
+
- **대시보드 API 확장** — 50+ 엔드포인트 (필터링 · 집계 · 시계열 · 비교 · 랭킹)
|
|
1447
|
+
|
|
1448
|
+
### v0.7.1 (2026-04-03) — QuickEval · SimpleTaskAlertRule · DSPy/PydanticAI 통합
|
|
1449
|
+
|
|
1450
|
+
- **`QuickEval`** — 3종 데코레이터 원스톱 Facade; `for_rag()` · `for_security()` · `for_llm_judge()` 팩토리
|
|
1451
|
+
- **`SimpleTaskAlertRule`** — StreamingEvaluator 없이 동작하는 경량 알림; 3종 데코레이터에 `alert_rules=` 통합
|
|
1452
|
+
- **`flush_every`** — 3종 데코레이터 공통 N건마다 `save_to_file()` 자동 실행
|
|
1453
|
+
- **DSPy / PydanticAI 통합** — `[dspy]` · `[pydanticai]` extras 추가
|
|
1454
|
+
|
|
1455
|
+
### v0.7.0 (2026-04-01) — Phoenix + OTEL 실시간 모니터링
|
|
1456
|
+
|
|
1457
|
+
- **`agent-eval monitor`** CLI — Arize Phoenix 서버 기동 + OTLP 스팬 수신
|
|
1458
|
+
- **`setup_otel()`** 공개 API; `[otel]` extras 신규
|
|
1459
|
+
|
|
1460
|
+
### v0.6.x (2026-03-21 ~ 04-01) — SDK 안정화 · 프레임워크 통합 · 대시보드
|
|
1461
|
+
|
|
1462
|
+
- LangChain / LangGraph / CrewAI / AutoGen 4개 완전 지원
|
|
1463
|
+
- FastAPI 대시보드 · LLMJudge · ConversationSession · Ragas 0.4.x 지원
|
|
1464
|
+
|
|
1465
|
+
### v0.2.x – v0.5.x — 초기 구현
|
|
1466
|
+
|
|
1467
|
+
- Layer 1/2/3 트래커 25개 · `ConversationSession` · `evaluation_session` 초기 구현
|