Spaces:
Sleeping
Sleeping
Download src/vision_contract.py from toecm/PureVersation: direct link, hf CLI and curl.
- Browser
- Download file 2.52 kB
-
https://huggingface.co/spaces/toecm/PureVersation/resolve/main/src/vision_contract.py
- Command line
-
hf download hf://spaces/toecm/PureVersation/src/vision_contract.py
-
curl -L -o vision_contract.py https://huggingface.co/spaces/toecm/PureVersation/resolve/main/src/vision_contract.py
2.52 kB
| """Versioned text-only visual elicitation metadata. Never accepts an image upload.""" | |
| VISION_METADATA_KEYS = frozenset({ | |
| 'vision_protocol_version', 'vision_image_origin', 'vision_image_transmitted', | |
| 'vision_transcript_confirmed', 'vision_meaning_equivalence', | |
| 'vision_final_confirmed', 'vision_paraphrase_edited', | |
| }) | |
| def validate_vision_review(record): | |
| metadata = record.metadata | |
| if not any(key in metadata for key in VISION_METADATA_KEYS): | |
| return record # Historical records retain their original contract. | |
| if metadata.get('vision_protocol_version') != 'local-image-meaning-v1': | |
| raise ValueError('Unsupported Vision Quest protocol') | |
| if record.game_id != 'vision_quest' or record.input_modality not in {'text', 'speech'}: | |
| raise ValueError('Vision Quest collects speech/text, not image or multimodal payloads') | |
| origin = metadata.get('vision_image_origin') | |
| if origin not in {'provided', 'device', 'camera'}: | |
| raise ValueError('Invalid visual stimulus origin') | |
| expected_asset = 'vision-original-market-v1' if origin == 'provided' else '' | |
| if (record.image_asset_id or '') != expected_asset: | |
| raise ValueError('Device image references must not leave the device') | |
| if metadata.get('vision_image_transmitted') is not False: | |
| raise ValueError('Images are not transmitted under this protocol') | |
| if metadata.get('vision_transcript_confirmed') is not True or metadata.get('vision_final_confirmed') is not True: | |
| raise ValueError('Separate transcript and meaning confirmations are required') | |
| if not (record.source_text or '').strip() or record.source_text != record.user_transcript_final: | |
| raise ValueError('The submitted source must be the user-confirmed transcript') | |
| initial, final = (record.machine_output_initial or '').strip(), (record.user_output_final or '').strip() | |
| if not initial or not final: | |
| raise ValueError('Keep the AI paraphrase and user-final wording separately') | |
| judgment = metadata.get('vision_meaning_equivalence') | |
| if judgment not in {'same', 'partly', 'different'}: | |
| raise ValueError('A speaker meaning-equivalence judgment is required') | |
| if judgment != 'same' and initial == final: | |
| raise ValueError('Correct a partly/differently understood paraphrase before contributing') | |
| if metadata.get('vision_paraphrase_edited') is not (initial != final): | |
| raise ValueError('Paraphrase edit flag does not match the recorded pair') | |
| return record | |