Spaces:
Paused
Paused
Download python/extensions/reasoning_stream_end/_10_mask_end.py from OnyxMunk/GravityFalls: direct link, hf CLI and curl.
- Browser
- Download file 913 Bytes
-
https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/extensions/reasoning_stream_end/_10_mask_end.py
- Command line
-
hf download hf://spaces/OnyxMunk/GravityFalls/python/extensions/reasoning_stream_end/_10_mask_end.py
-
curl -L -o _10_mask_end.py https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/main/python/extensions/reasoning_stream_end/_10_mask_end.py
913 Bytes
| from python.helpers.extension import Extension | |
| class MaskReasoningStreamEnd(Extension): | |
| async def execute(self, **kwargs): | |
| # Get agent and finalize the streaming filter | |
| agent = kwargs.get("agent") | |
| if not agent: | |
| return | |
| try: | |
| # Finalize the reasoning stream filter if it exists | |
| filter_key = "_reason_stream_filter" | |
| filter_instance = agent.get_data(filter_key) | |
| if filter_instance: | |
| tail = filter_instance.finalize() | |
| # Print any remaining masked content | |
| if tail: | |
| from python.helpers.print_style import PrintStyle | |
| PrintStyle().stream(tail) | |
| # Clean up the filter | |
| agent.set_data(filter_key, None) | |
| except Exception as e: | |
| # If masking fails, proceed without masking | |
| pass | |