Spaces:
Paused
Paused
Download python/helpers/messages.py from OnyxMunk/GravityFalls: direct link, hf CLI and curl.
- Browser
- Download file 478 Bytes
-
https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/c425c4043529634171dcfbb3aa5a94de613d28a8/python/helpers/messages.py
- Command line
-
hf download hf://spaces/OnyxMunk/GravityFalls@c425c4043529634171dcfbb3aa5a94de613d28a8/python/helpers/messages.py
-
curl -L -o messages.py https://huggingface.co/spaces/OnyxMunk/GravityFalls/resolve/c425c4043529634171dcfbb3aa5a94de613d28a8/python/helpers/messages.py
478 Bytes
| from . import files | |
| def truncate_text(output, threshold=1000): | |
| if len(output) <= threshold: | |
| return output | |
| # Adjust the file path as needed | |
| placeholder = files.read_file("./prompts/fw.msg_truncated.md", removed_chars=(len(output) - threshold)) | |
| start_len = (threshold - len(placeholder)) // 2 | |
| end_len = threshold - len(placeholder) - start_len | |
| truncated_output = output[:start_len] + placeholder + output[-end_len:] | |
| return truncated_output |