Repository navigation
Expand file tree
/
Copy pathmlflow-suggest-hook.py
More file actions
executable file
·51 lines (38 loc) · 2.35 KB
/
Copy pathmlflow-suggest-hook.py
File metadata and controls
executable file
·51 lines (38 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
"""UserPromptSubmit hook: detects MLflow usage and suggests relevant skill."""
import json
import sys
import re
def main():
try:
data = json.load(sys.stdin)
except (json.JSONDecodeError, ValueError):
sys.exit(0)
prompt = data.get("prompt", "").lower()
suggestions = []
if any(k in prompt for k in ["trace", "tracing", "autolog", "span", "instrument"]):
suggestions.append("💡 Use the `mlflow-trace-instrumentation` skill to add MLflow tracing.")
if any(k in prompt for k in ["evaluat", "scorer", "judge", "dataset", "assess", "improve quality"]):
suggestions.append("💡 Use the `mlflow-evaluation` skill to evaluate your agent with MLflow.")
if any(k in prompt for k in ["trace id", "debug trace", "why did", "what went wrong", "analyze trace"]):
suggestions.append("💡 Use the `mlflow-trace-analysis` skill to debug this trace.")
if any(k in prompt for k in ["debug my agent", "debug this agent", "agent failure", "root cause my agent"]):
suggestions.append("💡 Use the `mlflow-trace-analysis` skill to root-cause the failure from MLflow traces.")
if any(k in prompt for k in ["session", "conversation", "chat history", "multi-turn"]):
suggestions.append("💡 Use the `mlflow-trace-analysis` skill to analyze chat sessions.")
if any(k in prompt for k in ["search traces", "find traces", "filter traces", "get trace"]):
suggestions.append("💡 Use the `mlflow-trace-retrieval` skill to search/filter traces.")
if any(k in prompt for k in ["metrics", "token usage", "latency", "cost", "usage trend"]):
suggestions.append("💡 Use the `mlflow-trace-metrics` skill to fetch aggregated metrics.")
if any(k in prompt for k in ["get started", "set up mlflow", "onboard", "quickstart"]):
suggestions.append("💡 Use the `mlflow-onboarding` skill to get started with MLflow.")
if any(k in prompt for k in ["mlflow docs", "mlflow api", "how to use mlflow"]):
suggestions.append("💡 Use the `mlflow-docs` skill to search MLflow documentation.")
if suggestions:
by_skill = {}
for suggestion in suggestions:
skill = re.search(r"`([^`]+)`", suggestion).group(1)
by_skill.setdefault(skill, suggestion)
print("\n".join(by_skill.values()))
if __name__ == "__main__":
main()