promptforest 0.1.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.
- promptforest/__init__.py +3 -0
- promptforest/cli.py +54 -0
- promptforest/config.py +77 -0
- promptforest/download.py +82 -0
- promptforest/lib.py +239 -0
- promptforest/llama_guard_86m_downloader.py +67 -0
- promptforest/server.py +86 -0
- promptforest/xgboost/xgb_model.pkl +0 -0
- promptforest-0.1.0.dist-info/METADATA +21 -0
- promptforest-0.1.0.dist-info/RECORD +15 -0
- promptforest-0.1.0.dist-info/WHEEL +5 -0
- promptforest-0.1.0.dist-info/entry_points.txt +2 -0
- promptforest-0.1.0.dist-info/licenses/LICENSE.txt +202 -0
- promptforest-0.1.0.dist-info/licenses/NOTICE.md +10 -0
- promptforest-0.1.0.dist-info/top_level.txt +1 -0
promptforest/__init__.py
ADDED
promptforest/cli.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
from .config import load_config
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
parser = argparse.ArgumentParser(description="PromptForest: Ensemble Prompt Injection Detection")
|
|
9
|
+
subparsers = parser.add_subparsers(dest="command")
|
|
10
|
+
|
|
11
|
+
# Serve Command
|
|
12
|
+
serve_parser = subparsers.add_parser("serve", help="Start the inference server")
|
|
13
|
+
serve_parser.add_argument("--port", type=int, default=8000, help="Port to listen on")
|
|
14
|
+
serve_parser.add_argument("--config", type=str, default=None, help="Path to configuration file")
|
|
15
|
+
|
|
16
|
+
# Check Command (One-off inference)
|
|
17
|
+
check_parser = subparsers.add_parser("check", help="Check a single prompt")
|
|
18
|
+
check_parser.add_argument("prompt", type=str, help="The prompt to analyze")
|
|
19
|
+
check_parser.add_argument("--config", type=str, default=None, help="Path to configuration file")
|
|
20
|
+
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
|
|
23
|
+
# helper to load config
|
|
24
|
+
def get_user_config(path):
|
|
25
|
+
if path:
|
|
26
|
+
print(f"Loading configuration from {path}...")
|
|
27
|
+
return load_config(path)
|
|
28
|
+
return load_config(None)
|
|
29
|
+
|
|
30
|
+
if args.command == "serve":
|
|
31
|
+
from .server import run_server
|
|
32
|
+
cfg = get_user_config(args.config)
|
|
33
|
+
run_server(port=args.port, config=cfg)
|
|
34
|
+
|
|
35
|
+
elif args.command == "check":
|
|
36
|
+
from .lib import EnsembleGuard
|
|
37
|
+
cfg = get_user_config(args.config)
|
|
38
|
+
try:
|
|
39
|
+
print(f"Loading PromptForest...")
|
|
40
|
+
guard = EnsembleGuard(config=cfg)
|
|
41
|
+
print(f"Device: {guard.device_used}")
|
|
42
|
+
result = guard.check_prompt(args.prompt)
|
|
43
|
+
print(json.dumps(result, indent=2))
|
|
44
|
+
except Exception as e:
|
|
45
|
+
print(f"Error: {e}")
|
|
46
|
+
import traceback
|
|
47
|
+
traceback.print_exc()
|
|
48
|
+
sys.exit(1)
|
|
49
|
+
|
|
50
|
+
else:
|
|
51
|
+
parser.print_help()
|
|
52
|
+
|
|
53
|
+
if __name__ == "__main__":
|
|
54
|
+
main()
|
promptforest/config.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import yaml # type: ignore
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
# Package-internal paths (for assets like the XGBoost classifier pickle)
|
|
6
|
+
PACKAGE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
7
|
+
XGB_MODEL_PATH = os.path.join(PACKAGE_DIR, 'xgboost', 'xgb_model.pkl')
|
|
8
|
+
|
|
9
|
+
# User data paths (for models)
|
|
10
|
+
USER_DATA_DIR = Path.home() / ".promptforest"
|
|
11
|
+
MODELS_DIR = USER_DATA_DIR / "models"
|
|
12
|
+
|
|
13
|
+
DEFAULT_CONFIG = {
|
|
14
|
+
"models": [
|
|
15
|
+
{"name": "llama_guard", "path": "llama_guard", "type": "hf", "enabled": True},
|
|
16
|
+
{"name": "protectai", "path": "protectai_deberta", "type": "hf", "enabled": True},
|
|
17
|
+
{"name": "deepset", "path": "deepset_deberta", "type": "hf", "enabled": True},
|
|
18
|
+
{"name": "katanemo", "path": "katanemo_arch", "type": "hf", "enabled": True},
|
|
19
|
+
{"name": "xgboost", "type": "xgboost", "enabled": True}
|
|
20
|
+
],
|
|
21
|
+
"settings": {
|
|
22
|
+
"device": "auto", # Options: auto, cuda, mps, cpu
|
|
23
|
+
"fp16": True # Use FP16 precision on GPU/MPS (only applies if device is GPU/MPS)
|
|
24
|
+
},
|
|
25
|
+
"logging": {
|
|
26
|
+
"stats": True
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def load_config(config_path=None):
|
|
31
|
+
"""
|
|
32
|
+
Load configuration from a YAML file, merging with defaults.
|
|
33
|
+
"""
|
|
34
|
+
# Start with a deep copy of the default config structure
|
|
35
|
+
config = {
|
|
36
|
+
"models": [m.copy() for m in DEFAULT_CONFIG["models"]],
|
|
37
|
+
"settings": DEFAULT_CONFIG["settings"].copy(),
|
|
38
|
+
"logging": DEFAULT_CONFIG["logging"].copy()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if config_path:
|
|
42
|
+
path = Path(config_path)
|
|
43
|
+
if path.exists():
|
|
44
|
+
try:
|
|
45
|
+
with open(path, 'r') as f:
|
|
46
|
+
user_config = yaml.safe_load(f)
|
|
47
|
+
if user_config:
|
|
48
|
+
# 1. Merge Settings
|
|
49
|
+
if "settings" in user_config:
|
|
50
|
+
config["settings"].update(user_config["settings"])
|
|
51
|
+
|
|
52
|
+
# 2. Merge Logging
|
|
53
|
+
if "logging" in user_config:
|
|
54
|
+
config["logging"].update(user_config["logging"])
|
|
55
|
+
|
|
56
|
+
# 3. Merge Models (Smart Merge)
|
|
57
|
+
if "models" in user_config:
|
|
58
|
+
user_models = user_config["models"]
|
|
59
|
+
if isinstance(user_models, list):
|
|
60
|
+
# Convert current models to dict for easy lookup by name
|
|
61
|
+
existing_model_map = {m["name"]: m for m in config["models"]}
|
|
62
|
+
|
|
63
|
+
for u_model in user_models:
|
|
64
|
+
name = u_model.get("name")
|
|
65
|
+
if name and name in existing_model_map:
|
|
66
|
+
# Update existing model configuration (e.g. enable/disable, change path)
|
|
67
|
+
existing_model_map[name].update(u_model)
|
|
68
|
+
else:
|
|
69
|
+
# Add new custom model
|
|
70
|
+
config["models"].append(u_model)
|
|
71
|
+
|
|
72
|
+
except Exception as e:
|
|
73
|
+
print(f"Warning: Failed to load config from {path}: {e}")
|
|
74
|
+
else:
|
|
75
|
+
print(f"Warning: Config file {path} not found. Using defaults.")
|
|
76
|
+
|
|
77
|
+
return config
|
promptforest/download.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Script to download and save ensemble models locally.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import threading
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
10
|
+
from sentence_transformers import SentenceTransformer
|
|
11
|
+
from .config import MODELS_DIR
|
|
12
|
+
from .llama_guard_86m_downloader import download_llama_guard
|
|
13
|
+
|
|
14
|
+
# Configuration
|
|
15
|
+
MODELS = {
|
|
16
|
+
"protectai_deberta": "protectai/deberta-v3-base-prompt-injection",
|
|
17
|
+
"deepset_deberta": "deepset/deberta-v3-base-injection",
|
|
18
|
+
"katanemo_arch": "katanemo/Arch-Guard"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
EMBEDDING_MODEL_NAME = 'all-MiniLM-L6-v2'
|
|
22
|
+
|
|
23
|
+
def _ensure_dir(path):
|
|
24
|
+
if not os.path.exists(path):
|
|
25
|
+
os.makedirs(path)
|
|
26
|
+
|
|
27
|
+
def _download_hf_model(name, model_id):
|
|
28
|
+
"""Download and save a Hugging Face model and tokenizer."""
|
|
29
|
+
save_path = MODELS_DIR / name
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
if save_path.exists():
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
|
36
|
+
model = AutoModelForSequenceClassification.from_pretrained(model_id)
|
|
37
|
+
|
|
38
|
+
tokenizer.save_pretrained(save_path)
|
|
39
|
+
model.save_pretrained(save_path)
|
|
40
|
+
|
|
41
|
+
except Exception as e:
|
|
42
|
+
print("Failed to download a model!")
|
|
43
|
+
|
|
44
|
+
def _download_sentence_transformer():
|
|
45
|
+
"""Download and save the SentenceTransformer model."""
|
|
46
|
+
# print(f"Downloading SentenceTransformer ({EMBEDDING_MODEL_NAME})...")
|
|
47
|
+
save_path = MODELS_DIR / 'sentence_transformer'
|
|
48
|
+
|
|
49
|
+
try:
|
|
50
|
+
if save_path.exists():
|
|
51
|
+
# print(f" - Model already exists at {save_path}. Skipping.")
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
model = SentenceTransformer(EMBEDDING_MODEL_NAME)
|
|
55
|
+
model.save(str(save_path))
|
|
56
|
+
#print(f" - Saved to {save_path}")
|
|
57
|
+
|
|
58
|
+
except Exception as e:
|
|
59
|
+
print(f"SentenceTransformer download failed: {e}")
|
|
60
|
+
|
|
61
|
+
def download_all():
|
|
62
|
+
print(f"Downloading models to {MODELS_DIR}...")
|
|
63
|
+
_ensure_dir(MODELS_DIR)
|
|
64
|
+
|
|
65
|
+
# Download Llama Guard in parallel (slowest download)
|
|
66
|
+
llama_guard_thread = threading.Thread(target=download_llama_guard, daemon=False)
|
|
67
|
+
llama_guard_thread.start()
|
|
68
|
+
|
|
69
|
+
# Download HF Classification Models
|
|
70
|
+
for name, model_id in MODELS.items():
|
|
71
|
+
_download_hf_model(name, model_id)
|
|
72
|
+
|
|
73
|
+
# Download Embedding Model for XGBoost
|
|
74
|
+
_download_sentence_transformer()
|
|
75
|
+
|
|
76
|
+
# Wait for Llama Guard to complete
|
|
77
|
+
llama_guard_thread.join()
|
|
78
|
+
|
|
79
|
+
print("All models downloaded.")
|
|
80
|
+
|
|
81
|
+
if __name__ == "__main__":
|
|
82
|
+
download_all()
|
promptforest/lib.py
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Ensemble Inference Library for PromptForest.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
import joblib
|
|
9
|
+
import torch
|
|
10
|
+
import numpy as np
|
|
11
|
+
import logging
|
|
12
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
13
|
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, logging as transformers_logging
|
|
14
|
+
from sentence_transformers import SentenceTransformer
|
|
15
|
+
from .config import MODELS_DIR, XGB_MODEL_PATH, load_config
|
|
16
|
+
|
|
17
|
+
# Suppress Warnings
|
|
18
|
+
transformers_logging.set_verbosity_error()
|
|
19
|
+
os.environ["TOKENIZERS_PARALLELISM"] = "false" # Prevent deadlocks/warnings
|
|
20
|
+
|
|
21
|
+
MALICIOUS_KEYWORDS = ['unsafe', 'malicious', 'injection', 'attack', 'jailbreak']
|
|
22
|
+
|
|
23
|
+
def get_device(device_setting):
|
|
24
|
+
if device_setting == 'auto':
|
|
25
|
+
return 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
|
26
|
+
return device_setting
|
|
27
|
+
|
|
28
|
+
class ModelInference:
|
|
29
|
+
def predict(self, prompt):
|
|
30
|
+
raise NotImplementedError
|
|
31
|
+
|
|
32
|
+
class HFModel(ModelInference):
|
|
33
|
+
def __init__(self, name, dirname, settings):
|
|
34
|
+
self.name = name
|
|
35
|
+
self.path = MODELS_DIR / dirname
|
|
36
|
+
self.settings = settings
|
|
37
|
+
self.model = None
|
|
38
|
+
self.tokenizer = None
|
|
39
|
+
self.malicious_idx = 1
|
|
40
|
+
|
|
41
|
+
self.device_name = get_device(settings.get('device', 'auto'))
|
|
42
|
+
self.fp16 = settings.get('fp16', True)
|
|
43
|
+
|
|
44
|
+
self._load()
|
|
45
|
+
|
|
46
|
+
def _load(self):
|
|
47
|
+
if not self.path.exists():
|
|
48
|
+
print(f"[WARN] Model path not found: {self.path}")
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
self.tokenizer = AutoTokenizer.from_pretrained(self.path)
|
|
53
|
+
self.model = AutoModelForSequenceClassification.from_pretrained(self.path)
|
|
54
|
+
|
|
55
|
+
self.model.to(self.device_name)
|
|
56
|
+
if self.device_name in ['cuda', 'mps'] and self.fp16:
|
|
57
|
+
print("Using FP16 precision for model " + self.model.config._name_or_path)
|
|
58
|
+
self.model.half()
|
|
59
|
+
self.device = self.device_name
|
|
60
|
+
|
|
61
|
+
self.model.eval()
|
|
62
|
+
self._determine_label_map()
|
|
63
|
+
except Exception as e:
|
|
64
|
+
print(f"[ERR] Failed to load {self.name}: {e}")
|
|
65
|
+
self.model = None
|
|
66
|
+
|
|
67
|
+
def _determine_label_map(self):
|
|
68
|
+
id2label = self.model.config.id2label
|
|
69
|
+
found = False
|
|
70
|
+
for idx, label in id2label.items():
|
|
71
|
+
if any(kw in label.lower() for kw in MALICIOUS_KEYWORDS):
|
|
72
|
+
self.malicious_idx = idx
|
|
73
|
+
found = True
|
|
74
|
+
break
|
|
75
|
+
if not found:
|
|
76
|
+
self.malicious_idx = 1
|
|
77
|
+
|
|
78
|
+
def predict(self, prompt):
|
|
79
|
+
if not self.model:
|
|
80
|
+
return 0.0
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
inputs = self.tokenizer(
|
|
84
|
+
prompt, return_tensors="pt", truncation=True, max_length=512
|
|
85
|
+
).to(self.device)
|
|
86
|
+
|
|
87
|
+
with torch.no_grad():
|
|
88
|
+
outputs = self.model(**inputs)
|
|
89
|
+
|
|
90
|
+
probs = torch.softmax(outputs.logits.float(), dim=-1).cpu().numpy()[0]
|
|
91
|
+
|
|
92
|
+
if self.malicious_idx < len(probs):
|
|
93
|
+
return float(probs[self.malicious_idx])
|
|
94
|
+
else:
|
|
95
|
+
return float(probs[-1])
|
|
96
|
+
|
|
97
|
+
except Exception:
|
|
98
|
+
return 0.0
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class XGBoostModel(ModelInference):
|
|
102
|
+
def __init__(self, settings):
|
|
103
|
+
self.name = "xgboost_custom"
|
|
104
|
+
self.settings = settings
|
|
105
|
+
self.model = None
|
|
106
|
+
self.embedder = None
|
|
107
|
+
|
|
108
|
+
self.device_name = get_device(settings.get('device', 'auto'))
|
|
109
|
+
self.fp16 = settings.get('fp16', True)
|
|
110
|
+
|
|
111
|
+
self._load()
|
|
112
|
+
|
|
113
|
+
def _load(self):
|
|
114
|
+
try:
|
|
115
|
+
if os.path.exists(XGB_MODEL_PATH):
|
|
116
|
+
self.model = joblib.load(XGB_MODEL_PATH)
|
|
117
|
+
|
|
118
|
+
ST_PATH = MODELS_DIR / 'sentence_transformer'
|
|
119
|
+
if ST_PATH.exists():
|
|
120
|
+
self.embedder = SentenceTransformer(str(ST_PATH))
|
|
121
|
+
else:
|
|
122
|
+
print("Cannot find local SentenceTransformer model. Downloading...")
|
|
123
|
+
# Fallback to download default if local cache missing
|
|
124
|
+
self.embedder = SentenceTransformer('all-MiniLM-L6-v2')
|
|
125
|
+
|
|
126
|
+
if self.device_name in ['cuda', 'mps']:
|
|
127
|
+
self.embedder.to(self.device_name)
|
|
128
|
+
if self.fp16:
|
|
129
|
+
try:
|
|
130
|
+
self.embedder[0].auto_model.half()
|
|
131
|
+
except:
|
|
132
|
+
pass
|
|
133
|
+
except Exception as e:
|
|
134
|
+
print(f"[ERR] Failed to load XGBoost: {e}")
|
|
135
|
+
self.model = None
|
|
136
|
+
|
|
137
|
+
def predict(self, prompt):
|
|
138
|
+
if not self.model or not self.embedder:
|
|
139
|
+
return 0.0
|
|
140
|
+
try:
|
|
141
|
+
emb = self.embedder.encode([prompt])
|
|
142
|
+
prob = self.model.predict_proba(emb)[0][1]
|
|
143
|
+
return float(prob)
|
|
144
|
+
except Exception:
|
|
145
|
+
return 0.0
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class EnsembleGuard:
|
|
149
|
+
def __init__(self, config=None):
|
|
150
|
+
"""
|
|
151
|
+
Initialize the EnsembleGuard.
|
|
152
|
+
:param config: Dictionary containing configuration. If None, loads default/user config.
|
|
153
|
+
"""
|
|
154
|
+
# Check if models need to be downloaded
|
|
155
|
+
self._ensure_models_available()
|
|
156
|
+
|
|
157
|
+
if config is None:
|
|
158
|
+
self.config = load_config()
|
|
159
|
+
else:
|
|
160
|
+
self.config = config
|
|
161
|
+
|
|
162
|
+
self.models = []
|
|
163
|
+
self._init_models()
|
|
164
|
+
self.device_used = get_device(self.config['settings'].get('device', 'auto'))
|
|
165
|
+
|
|
166
|
+
def _ensure_models_available(self):
|
|
167
|
+
"""Check if models are available, download if needed."""
|
|
168
|
+
from .config import MODELS_DIR
|
|
169
|
+
|
|
170
|
+
# Check if models directory exists and has content
|
|
171
|
+
if MODELS_DIR.exists() and any(MODELS_DIR.iterdir()):
|
|
172
|
+
return
|
|
173
|
+
|
|
174
|
+
# Models not found, download them
|
|
175
|
+
print("Models not found. Downloading...")
|
|
176
|
+
from .download import download_all
|
|
177
|
+
download_all()
|
|
178
|
+
|
|
179
|
+
def _init_models(self):
|
|
180
|
+
settings = self.config.get('settings', {})
|
|
181
|
+
model_configs = self.config.get('models', [])
|
|
182
|
+
|
|
183
|
+
for model_cfg in model_configs:
|
|
184
|
+
if not model_cfg.get('enabled', True):
|
|
185
|
+
continue
|
|
186
|
+
|
|
187
|
+
model_type = model_cfg.get('type')
|
|
188
|
+
|
|
189
|
+
if model_type == 'hf':
|
|
190
|
+
self.models.append(HFModel(model_cfg['name'], model_cfg['path'], settings))
|
|
191
|
+
elif model_type == 'xgboost':
|
|
192
|
+
self.models.append(XGBoostModel(settings))
|
|
193
|
+
else:
|
|
194
|
+
print(f"Unknown model type: {model_type}")
|
|
195
|
+
|
|
196
|
+
def check_prompt(self, prompt):
|
|
197
|
+
start_time = time.perf_counter()
|
|
198
|
+
results = {}
|
|
199
|
+
|
|
200
|
+
with ThreadPoolExecutor() as executor:
|
|
201
|
+
future_to_model = {executor.submit(model.predict, prompt): model for model in self.models}
|
|
202
|
+
for future in future_to_model:
|
|
203
|
+
model = future_to_model[future]
|
|
204
|
+
try:
|
|
205
|
+
prob = future.result()
|
|
206
|
+
results[model.name] = prob
|
|
207
|
+
except Exception:
|
|
208
|
+
results[model.name] = 0.0
|
|
209
|
+
|
|
210
|
+
end_time = time.perf_counter()
|
|
211
|
+
duration_ms = (end_time - start_time) * 1000
|
|
212
|
+
|
|
213
|
+
probs = list(results.values())
|
|
214
|
+
if not probs:
|
|
215
|
+
return {"error": "No models loaded"}
|
|
216
|
+
|
|
217
|
+
avg_prob = np.mean(probs)
|
|
218
|
+
max_prob = np.max(probs)
|
|
219
|
+
|
|
220
|
+
# Uncertainty
|
|
221
|
+
std_dev = np.std(probs)
|
|
222
|
+
uncertainty_score = min(std_dev * 2, 1.0)
|
|
223
|
+
|
|
224
|
+
is_malicious = avg_prob > 0.5
|
|
225
|
+
|
|
226
|
+
response = {
|
|
227
|
+
"is_malicious": bool(is_malicious),
|
|
228
|
+
"confidence": float(avg_prob if is_malicious else 1 - avg_prob),
|
|
229
|
+
"uncertainty": float(uncertainty_score),
|
|
230
|
+
"malicious_score": float(avg_prob),
|
|
231
|
+
"max_risk_score": float(max_prob)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
# Add stats if requested
|
|
235
|
+
if self.config.get('logging', {}).get('stats', True):
|
|
236
|
+
response["details"] = results
|
|
237
|
+
response["latency_ms"] = duration_ms
|
|
238
|
+
|
|
239
|
+
return response
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Script to download Llama Guard 2 86M from a custom GitHub repository.
|
|
3
|
+
Handles split safetensor files and combines them locally.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
import tempfile
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from .config import MODELS_DIR
|
|
12
|
+
|
|
13
|
+
LLAMA_GUARD_REPO = "https://github.com/appleroll-research/promptforest-model-ensemble.git"
|
|
14
|
+
|
|
15
|
+
def _download_llama_guard():
|
|
16
|
+
"""Download Llama Guard from custom repository and combine split files."""
|
|
17
|
+
save_path = MODELS_DIR / "llama_guard"
|
|
18
|
+
|
|
19
|
+
if save_path.exists():
|
|
20
|
+
return
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
# Use temporary directory for cloning
|
|
24
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
25
|
+
temp_path = Path(temp_dir)
|
|
26
|
+
|
|
27
|
+
# Clone repository silently
|
|
28
|
+
subprocess.run(
|
|
29
|
+
["git", "clone", "--depth", "1", LLAMA_GUARD_REPO, str(temp_path)],
|
|
30
|
+
stdout=subprocess.DEVNULL,
|
|
31
|
+
stderr=subprocess.DEVNULL,
|
|
32
|
+
check=True
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Get the llama_guard folder from the cloned repo
|
|
36
|
+
source_dir = temp_path / "llama_guard"
|
|
37
|
+
if not source_dir.exists():
|
|
38
|
+
raise FileNotFoundError(f"llama_guard folder not found in repository")
|
|
39
|
+
|
|
40
|
+
# Copy to models directory
|
|
41
|
+
save_path.parent.mkdir(parents=True, exist_ok=True)
|
|
42
|
+
shutil.copytree(source_dir, save_path)
|
|
43
|
+
|
|
44
|
+
# Combine split safetensor files
|
|
45
|
+
model_file = save_path / "model.safetensors"
|
|
46
|
+
if not model_file.exists():
|
|
47
|
+
# Find and combine c_* files
|
|
48
|
+
split_files = sorted(save_path.glob("c_*"))
|
|
49
|
+
if split_files:
|
|
50
|
+
with open(model_file, 'wb') as outfile:
|
|
51
|
+
for split_file in split_files:
|
|
52
|
+
with open(split_file, 'rb') as infile:
|
|
53
|
+
outfile.write(infile.read())
|
|
54
|
+
|
|
55
|
+
# Delete split files
|
|
56
|
+
for split_file in split_files:
|
|
57
|
+
split_file.unlink()
|
|
58
|
+
|
|
59
|
+
except Exception as e:
|
|
60
|
+
# Clean up on failure
|
|
61
|
+
if save_path.exists():
|
|
62
|
+
shutil.rmtree(save_path)
|
|
63
|
+
raise Exception(f"Failed to download Llama Guard: {e}")
|
|
64
|
+
|
|
65
|
+
def download_llama_guard():
|
|
66
|
+
"""Public interface for downloading Llama Guard."""
|
|
67
|
+
_download_llama_guard()
|
promptforest/server.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Simple HTTP Server for PromptForest.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import http.server
|
|
6
|
+
import socketserver
|
|
7
|
+
import json
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
from .lib import EnsembleGuard
|
|
11
|
+
|
|
12
|
+
PORT = 8000
|
|
13
|
+
ensemble = None
|
|
14
|
+
|
|
15
|
+
class GuardRequestHandler(http.server.BaseHTTPRequestHandler):
|
|
16
|
+
def do_POST(self):
|
|
17
|
+
"""Handle POST requests for inference."""
|
|
18
|
+
if self.path == '/analyze':
|
|
19
|
+
try:
|
|
20
|
+
content_length = int(self.headers.get('Content-Length', 0))
|
|
21
|
+
if content_length == 0:
|
|
22
|
+
self._send_json(400, {'error': 'Empty body'})
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
post_data = self.rfile.read(content_length)
|
|
26
|
+
data = json.loads(post_data)
|
|
27
|
+
prompt = data.get('prompt')
|
|
28
|
+
|
|
29
|
+
if not prompt:
|
|
30
|
+
self._send_json(400, {'error': 'Field "prompt" is required'})
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
print(f"{time.strftime('%Y-%m-%d %H:%M:%S')} Received prompt \"{prompt}\"")
|
|
34
|
+
|
|
35
|
+
result = ensemble.check_prompt(prompt)
|
|
36
|
+
self._send_json(200, result)
|
|
37
|
+
|
|
38
|
+
except json.JSONDecodeError:
|
|
39
|
+
self._send_json(400, {'error': 'Invalid JSON'})
|
|
40
|
+
except Exception as e:
|
|
41
|
+
import traceback
|
|
42
|
+
traceback.print_exc()
|
|
43
|
+
print(f"Server Error: {e}")
|
|
44
|
+
self._send_json(500, {'error': str(e)})
|
|
45
|
+
else:
|
|
46
|
+
self._send_json(404, {'error': 'Endpoint not found.'})
|
|
47
|
+
|
|
48
|
+
def do_GET(self):
|
|
49
|
+
if self.path == '/health':
|
|
50
|
+
device = ensemble.device_used if ensemble else "unknown"
|
|
51
|
+
self._send_json(200, {'status': 'ok', 'device': device})
|
|
52
|
+
else:
|
|
53
|
+
self._send_json(404, {'error': 'Not Found'})
|
|
54
|
+
|
|
55
|
+
def _send_json(self, code, data):
|
|
56
|
+
self.send_response(code)
|
|
57
|
+
self.send_header('Content-type', 'application/json')
|
|
58
|
+
self.end_headers()
|
|
59
|
+
self.wfile.write(json.dumps(data, indent=2).encode('utf-8'))
|
|
60
|
+
|
|
61
|
+
class ThreadedHTTPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
|
62
|
+
daemon_threads = True
|
|
63
|
+
|
|
64
|
+
def run_server(port=8000, config=None):
|
|
65
|
+
global ensemble
|
|
66
|
+
print(f"Initializing PromptForest...")
|
|
67
|
+
try:
|
|
68
|
+
ensemble = EnsembleGuard(config=config)
|
|
69
|
+
print(f"Device: {ensemble.device_used}")
|
|
70
|
+
print("Warming up...")
|
|
71
|
+
ensemble.check_prompt("warmup")
|
|
72
|
+
print("Ready.")
|
|
73
|
+
except Exception as e:
|
|
74
|
+
print(f"Failed to initialize model: {e}")
|
|
75
|
+
sys.exit(1)
|
|
76
|
+
|
|
77
|
+
print(f"\nListening on http://localhost:{port}")
|
|
78
|
+
socketserver.TCPServer.allow_reuse_address = True
|
|
79
|
+
|
|
80
|
+
with ThreadedHTTPServer(("", port), GuardRequestHandler) as httpd:
|
|
81
|
+
try:
|
|
82
|
+
httpd.serve_forever()
|
|
83
|
+
except KeyboardInterrupt:
|
|
84
|
+
print("\nShutting down. Goodbye...")
|
|
85
|
+
httpd.shutdown()
|
|
86
|
+
httpd.server_close()
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: promptforest
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Ensemble Prompt Injection Detection
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
License-File: LICENSE.txt
|
|
7
|
+
License-File: NOTICE.md
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: pandas
|
|
10
|
+
Requires-Dist: torch
|
|
11
|
+
Requires-Dist: transformers
|
|
12
|
+
Requires-Dist: sentence-transformers
|
|
13
|
+
Requires-Dist: xgboost
|
|
14
|
+
Requires-Dist: scikit-learn
|
|
15
|
+
Requires-Dist: pyyaml
|
|
16
|
+
Requires-Dist: joblib
|
|
17
|
+
Requires-Dist: protobuf
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
promptforest/__init__.py,sha256=cE1cQyRL4vUzseCwLYbI5wrZuZ-NRMVXIjAgwTLwIEs,54
|
|
2
|
+
promptforest/cli.py,sha256=LKsnbEQNQ9pP_Ww24Ql2Tb_uomO-StqHnk-IHONSKTM,1856
|
|
3
|
+
promptforest/config.py,sha256=bOFHlK0kI7c3fzccZrcjccNUfZJPzvLtKEAZ_loLvzE,3366
|
|
4
|
+
promptforest/download.py,sha256=3Ss1BX6kQatfhif1cbErUekPlSA2RCqtiatUzGi72zo,2454
|
|
5
|
+
promptforest/lib.py,sha256=LT8A1_veV9tB2DyrZ0JEOBW4EWEs9El5xOxF0zNHOAc,8042
|
|
6
|
+
promptforest/llama_guard_86m_downloader.py,sha256=ibFeeuDgMBVe-8aD0zl23xJKOPdKyw-4Bsf0iZJih4s,2412
|
|
7
|
+
promptforest/server.py,sha256=uF4Yj7yR_2vEx_7nQabGHGGw-6GWnT0iBZx3UPQK634,2905
|
|
8
|
+
promptforest/xgboost/xgb_model.pkl,sha256=97Y_Dfu8PwubkplRXJdNEuAj9te1v-nEJlXfPpEZWdM,748772
|
|
9
|
+
promptforest-0.1.0.dist-info/licenses/LICENSE.txt,sha256=GgVl4CdplCpCEssTcrmIRbz52zQc0fdcSETZp34uBF4,11349
|
|
10
|
+
promptforest-0.1.0.dist-info/licenses/NOTICE.md,sha256=XGjuV5VAWBinW6Jzu7-9h0Ph3xwCNzcJdbMH_EgU_g4,356
|
|
11
|
+
promptforest-0.1.0.dist-info/METADATA,sha256=OYvSPhnatbf97rur1W3zaY4FE0MFRE67j8QmC8hpz_M,509
|
|
12
|
+
promptforest-0.1.0.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
13
|
+
promptforest-0.1.0.dist-info/entry_points.txt,sha256=sVcjABvpA7P2fXca2KMZSYf0PNfDgLt1NHlYFMPO_eE,55
|
|
14
|
+
promptforest-0.1.0.dist-info/top_level.txt,sha256=NxasbbadJaf8w9zaRXo5KOdBqNA1oDe-2X7e6zdz3k0,13
|
|
15
|
+
promptforest-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Appleroll Research
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
PromptForest
|
|
2
|
+
|
|
3
|
+
This product includes software developed by:
|
|
4
|
+
- Meta Platforms, Inc. (“LLaMA 4”): LLaMA 4 Community License, Copyright © 2025 Meta Platforms, Inc.
|
|
5
|
+
https://llama.com/llama4
|
|
6
|
+
|
|
7
|
+
Additional notices:
|
|
8
|
+
- PromptForest core logic licensed under Apache-2.0
|
|
9
|
+
- See LICENSE for full Apache terms
|
|
10
|
+
- See COMMERCIAL_LICENSE.md for commercial usage terms
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
promptforest
|