Extract the feature vector for a prompt. Features are extracted from the user prompt plus the request-scoped system prompt when present. Context features (tools present, conversation depth, etc.) are passed separately and encoded as numerical signals — no keyword matching.
(
prompt: str,
system_prompt: str | None = None,
context_features: dict[str, float] | None = None,
)
| 75 | |
| 76 | |
| 77 | def extract_features( |
| 78 | prompt: str, |
| 79 | system_prompt: str | None = None, |
| 80 | context_features: dict[str, float] | None = None, |
| 81 | ) -> dict[str, float]: |
| 82 | """Extract the feature vector for a prompt. |
| 83 | |
| 84 | Features are extracted from the user prompt plus the request-scoped |
| 85 | system prompt when present. Context features (tools present, |
| 86 | conversation depth, etc.) are passed separately and encoded as |
| 87 | numerical signals — no keyword matching. |
| 88 | """ |
| 89 | _ensure_model_loaded() |
| 90 | return _extract_all_features( |
| 91 | prompt, |
| 92 | system_prompt=system_prompt, |
| 93 | context_features=context_features, |
| 94 | ) |
| 95 | |
| 96 | |
| 97 | def update_model(features: dict[str, float], correct_tier: str) -> bool: |