Spaces:
Build error
Build error
Download utils.py from HuggingFaceH4/reward-modeling-chat-ui: direct link, hf CLI and curl.
- Browser
- Download file 364 Bytes
-
https://huggingface.co/spaces/HuggingFaceH4/reward-modeling-chat-ui/resolve/main/utils.py
- Command line
-
hf download hf://spaces/HuggingFaceH4/reward-modeling-chat-ui/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/HuggingFaceH4/reward-modeling-chat-ui/resolve/main/utils.py
364 Bytes
| import re | |
| def wrap_html_code(text): | |
| pattern = r"<.*?>" | |
| matches = re.findall(pattern, text) | |
| if len(matches) > 0: | |
| return f"```{text}```" | |
| else: | |
| return text | |
| def get_full_text(response): | |
| output = "" | |
| for resp in response: | |
| if resp.token.special: | |
| continue | |
| output += resp.token.text | |
| return output | |