Download agent/evolution/pattern_extractor.py from Dani12po/zevora: direct link, hf CLI and curl.
- Browser
- Download file 745 Bytes
-
https://huggingface.co/Dani12po/zevora/resolve/main/agent/evolution/pattern_extractor.py
- Command line
-
hf download hf://Dani12po/zevora/agent/evolution/pattern_extractor.py
-
curl -L -o pattern_extractor.py https://huggingface.co/Dani12po/zevora/resolve/main/agent/evolution/pattern_extractor.py
745 Bytes
| """Compact pattern extraction without retaining raw prompts or conversations.""" | |
| import hashlib | |
| import json | |
| def extract_pattern(experience: dict) -> dict: | |
| pattern = { | |
| 'task_class': str(experience.get('task_class') or 'unknown'), | |
| 'route': str(experience.get('route') or ''), | |
| 'provider': str(experience.get('provider') or ''), | |
| 'model': str(experience.get('model') or ''), | |
| 'skill_ids': sorted(set(experience.get('skill_ids') or [])), | |
| 'result': str(experience.get('result') or 'unknown'), | |
| 'verified': bool(experience.get('verified', False)), | |
| } | |
| pattern['content_hash'] = hashlib.sha256(json.dumps(pattern, sort_keys=True).encode()).hexdigest() | |
| return pattern | |