Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,24 @@
|
|
| 1 |
# app.py
|
| 2 |
import re, spaces, gradio as gr, torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
-
import verifiers as vf
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
MODEL_NAME = "loocorez/reverse-text-warmup"
|
| 8 |
|
|
|
|
| 1 |
# app.py
|
| 2 |
import re, spaces, gradio as gr, torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 4 |
|
| 5 |
+
import re, types
|
| 6 |
+
try:
|
| 7 |
+
import verifiers as vf
|
| 8 |
+
_ = vf.XMLParser # raises AttributeError on v0.0.0
|
| 9 |
+
except (ImportError, AttributeError):
|
| 10 |
+
class _XMLParser:
|
| 11 |
+
def __init__(self, tags):
|
| 12 |
+
self.tags = tags
|
| 13 |
+
def get_format_str(self):
|
| 14 |
+
return "\n".join(f"<{t}>…</{t}>" for t in self.tags)
|
| 15 |
+
def extract(self, text):
|
| 16 |
+
out = {}
|
| 17 |
+
for tag in self.tags:
|
| 18 |
+
m = re.search(fr"<{tag}>(.*?)</{tag}>", text, re.S)
|
| 19 |
+
out[tag] = m.group(1).strip() if m else ""
|
| 20 |
+
return out
|
| 21 |
+
vf = types.SimpleNamespace(XMLParser=_XMLParser) # drop-in shim
|
| 22 |
|
| 23 |
MODEL_NAME = "loocorez/reverse-text-warmup"
|
| 24 |
|