agentra 0.3.0__py3-none-any.whl
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.
- agentra/__init__.py +149 -0
- agentra/cli.py +596 -0
- agentra/compliance/__init__.py +4 -0
- agentra/compliance/reporter.py +344 -0
- agentra/db.py +316 -0
- agentra/eval/__init__.py +15 -0
- agentra/eval/compare.py +230 -0
- agentra/eval/dataset.py +143 -0
- agentra/eval/experiment.py +288 -0
- agentra/eval/scorers.py +199 -0
- agentra/git_tracker.py +212 -0
- agentra/guard/__init__.py +35 -0
- agentra/guard/agent.py +239 -0
- agentra/guard/attacks.py +188 -0
- agentra/guard/auto_dataset.py +113 -0
- agentra/guard/fingerprint.py +213 -0
- agentra/guard/mcp_scanner.py +559 -0
- agentra/guard/mcp_static.py +252 -0
- agentra/guard/multilingual.py +349 -0
- agentra/guard/mutations.py +95 -0
- agentra/guard/prompt_leakage.py +319 -0
- agentra/guard/rag_scanner.py +217 -0
- agentra/guard/red_team.py +570 -0
- agentra/guard/swarm.py +422 -0
- agentra/guard/toolchain.py +340 -0
- agentra/interceptor.py +119 -0
- agentra/monitor/__init__.py +5 -0
- agentra/monitor/daemon.py +132 -0
- agentra/monitor/drift.py +249 -0
- agentra/monitor/tracer.py +178 -0
- agentra/plugins/__init__.py +4 -0
- agentra/plugins/registry.py +138 -0
- agentra/pricing.py +103 -0
- agentra/providers.py +157 -0
- agentra/review/__init__.py +4 -0
- agentra/review/annotations.py +193 -0
- agentra/server/__init__.py +1 -0
- agentra/server/app.py +434 -0
- agentra-0.3.0.dist-info/METADATA +485 -0
- agentra-0.3.0.dist-info/RECORD +42 -0
- agentra-0.3.0.dist-info/WHEEL +4 -0
- agentra-0.3.0.dist-info/entry_points.txt +2 -0
agentra/__init__.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agentra — Red-team, eval, and monitor your LLMs. Security-first, Python-native.
|
|
3
|
+
|
|
4
|
+
Quick start:
|
|
5
|
+
import agentra
|
|
6
|
+
agentra.init()
|
|
7
|
+
|
|
8
|
+
# Red team your chatbot
|
|
9
|
+
report = agentra.red_team(my_chatbot, plugins=["jailbreak", "pii"])
|
|
10
|
+
report.summary()
|
|
11
|
+
|
|
12
|
+
# Attack heatmap across models
|
|
13
|
+
fp = agentra.guard.fingerprint({"gpt-4o-mini": fn1, "claude-haiku": fn2})
|
|
14
|
+
fp.heatmap()
|
|
15
|
+
|
|
16
|
+
# Auto-generate test cases
|
|
17
|
+
ds = agentra.auto_dataset(my_chatbot, n=50, focus="adversarial")
|
|
18
|
+
"""
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
__version__ = "0.3.0"
|
|
22
|
+
__author__ = "agentra"
|
|
23
|
+
|
|
24
|
+
# Guard (primary — security)
|
|
25
|
+
from agentra.guard.red_team import red_team, RedTeamReport
|
|
26
|
+
from agentra.guard.fingerprint import fingerprint, ModelFingerprint
|
|
27
|
+
from agentra.guard.auto_dataset import auto_dataset
|
|
28
|
+
from agentra.guard.swarm import scan_swarm, SwarmScanReport
|
|
29
|
+
from agentra.guard.toolchain import scan_toolchain, ToolchainReport
|
|
30
|
+
from agentra.guard.prompt_leakage import prompt_leakage_score, LeakageReport
|
|
31
|
+
from agentra.guard.multilingual import scan_multilingual, MultilingualReport
|
|
32
|
+
from agentra.guard.mcp_scanner import scan_mcp, MCPScanReport
|
|
33
|
+
from agentra.guard.mcp_static import analyze_mcp_tools, ToolRiskReport
|
|
34
|
+
|
|
35
|
+
# Eval
|
|
36
|
+
from agentra.eval.dataset import Dataset, DatasetItem
|
|
37
|
+
from agentra.eval.experiment import Experiment, ExperimentResults
|
|
38
|
+
from agentra.eval import scorers
|
|
39
|
+
from agentra.eval.compare import compare_models, prompt_ab_test
|
|
40
|
+
|
|
41
|
+
# Monitor
|
|
42
|
+
from agentra.monitor.tracer import trace, span
|
|
43
|
+
from agentra.monitor.drift import DriftDetector, DriftReport
|
|
44
|
+
|
|
45
|
+
# Sub-packages
|
|
46
|
+
from agentra import guard, eval, monitor
|
|
47
|
+
|
|
48
|
+
__all__ = [
|
|
49
|
+
# Core
|
|
50
|
+
"init",
|
|
51
|
+
"dataset",
|
|
52
|
+
"experiment",
|
|
53
|
+
# Guard
|
|
54
|
+
"red_team",
|
|
55
|
+
"RedTeamReport",
|
|
56
|
+
"fingerprint",
|
|
57
|
+
"ModelFingerprint",
|
|
58
|
+
"auto_dataset",
|
|
59
|
+
"scan_swarm",
|
|
60
|
+
"SwarmScanReport",
|
|
61
|
+
"scan_toolchain",
|
|
62
|
+
"ToolchainReport",
|
|
63
|
+
"prompt_leakage_score",
|
|
64
|
+
"LeakageReport",
|
|
65
|
+
"scan_multilingual",
|
|
66
|
+
"MultilingualReport",
|
|
67
|
+
"scan_mcp",
|
|
68
|
+
"MCPScanReport",
|
|
69
|
+
"analyze_mcp_tools",
|
|
70
|
+
"ToolRiskReport",
|
|
71
|
+
"guard",
|
|
72
|
+
# Eval
|
|
73
|
+
"Dataset",
|
|
74
|
+
"DatasetItem",
|
|
75
|
+
"Experiment",
|
|
76
|
+
"ExperimentResults",
|
|
77
|
+
"scorers",
|
|
78
|
+
"compare_models",
|
|
79
|
+
"prompt_ab_test",
|
|
80
|
+
"eval",
|
|
81
|
+
# Monitor
|
|
82
|
+
"trace",
|
|
83
|
+
"span",
|
|
84
|
+
"DriftDetector",
|
|
85
|
+
"DriftReport",
|
|
86
|
+
"monitor",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def init(
|
|
91
|
+
persist: bool = True,
|
|
92
|
+
db_path: str | None = None,
|
|
93
|
+
offline: bool = False,
|
|
94
|
+
local_judge_model: str = "llama3",
|
|
95
|
+
judge_model: str = "gpt-4o-mini",
|
|
96
|
+
) -> None:
|
|
97
|
+
"""
|
|
98
|
+
Initialize agentra — enable persistence and activate SDK interceptors.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
persist: write results to SQLite (default True)
|
|
102
|
+
db_path: custom path for agentra.db (default: ~/.agentra/data.db)
|
|
103
|
+
offline: use local Ollama model for judging (no external API calls)
|
|
104
|
+
local_judge_model: Ollama model to use when offline=True
|
|
105
|
+
judge_model: default judge model when offline=False
|
|
106
|
+
|
|
107
|
+
Example:
|
|
108
|
+
agentra.init() # Standard
|
|
109
|
+
agentra.init(offline=True) # Fully offline with Ollama
|
|
110
|
+
agentra.init(db_path="/tmp/agentra.db") # Custom DB path
|
|
111
|
+
"""
|
|
112
|
+
from agentra import providers, db
|
|
113
|
+
|
|
114
|
+
# Configure providers
|
|
115
|
+
providers.configure(
|
|
116
|
+
offline=offline,
|
|
117
|
+
local_judge_model=local_judge_model,
|
|
118
|
+
judge_model=judge_model,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Configure DB path
|
|
122
|
+
if db_path:
|
|
123
|
+
db.set_db_path(db_path)
|
|
124
|
+
|
|
125
|
+
# Initialize DB schema
|
|
126
|
+
if persist:
|
|
127
|
+
db.init_db(db_path)
|
|
128
|
+
|
|
129
|
+
# Activate SDK interceptors
|
|
130
|
+
try:
|
|
131
|
+
from agentra import interceptor
|
|
132
|
+
interceptor.activate()
|
|
133
|
+
except Exception:
|
|
134
|
+
pass
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def dataset(name: str, description: str = "") -> Dataset:
|
|
138
|
+
"""Create or load a named dataset."""
|
|
139
|
+
return Dataset(name, description)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def experiment(
|
|
143
|
+
name: str,
|
|
144
|
+
dataset: Dataset | str,
|
|
145
|
+
fn,
|
|
146
|
+
scorers: list | None = None,
|
|
147
|
+
) -> Experiment:
|
|
148
|
+
"""Create an experiment."""
|
|
149
|
+
return Experiment(name=name, dataset=dataset, fn=fn, scorers=scorers or [])
|