Spaces:
Running
Running
show line number on error
Browse files
app.py
CHANGED
|
@@ -1393,32 +1393,40 @@ You can freely edit and test GGUF chat template(s) (and are encouraged to do so)
|
|
| 1393 |
try:
|
| 1394 |
chat_output = tokenizer.apply_chat_template(messages, tools = tools, documents = documents, chat_template = template, tokenize = False, **chat_template_kwargs)
|
| 1395 |
except Exception as e:
|
|
|
|
|
|
|
| 1396 |
gr.Warning(
|
| 1397 |
-
message =
|
| 1398 |
duration = None,
|
| 1399 |
title = "Chat Template Error",
|
| 1400 |
)
|
| 1401 |
try:
|
| 1402 |
chat_tool_use_output = tokenizer.apply_chat_template(messages, tools = tools or [], chat_template = template_tool_use, tokenize = False, **chat_template_kwargs) if template_tool_use else None
|
| 1403 |
except Exception as e:
|
|
|
|
|
|
|
| 1404 |
gr.Warning(
|
| 1405 |
-
message =
|
| 1406 |
duration = None,
|
| 1407 |
title = "Tool Use Template Error",
|
| 1408 |
)
|
| 1409 |
try:
|
| 1410 |
chat_rag_output = tokenizer.apply_chat_template(messages, documents = documents or [], chat_template = template_rag, tokenize = False, **chat_template_kwargs) if template_rag else None
|
| 1411 |
except Exception as e:
|
|
|
|
|
|
|
| 1412 |
gr.Warning(
|
| 1413 |
-
message =
|
| 1414 |
duration = None,
|
| 1415 |
title = "RAG Template Error",
|
| 1416 |
)
|
| 1417 |
try:
|
| 1418 |
inverse_output = tokenizer.apply_inverse_template(messages, inverse_template = template_inverse, **chat_template_kwargs) if template_inverse else None
|
| 1419 |
except Exception as e:
|
|
|
|
|
|
|
| 1420 |
gr.Warning(
|
| 1421 |
-
message =
|
| 1422 |
duration = None,
|
| 1423 |
title = "Inverse Template Error",
|
| 1424 |
)
|
|
|
|
| 1393 |
try:
|
| 1394 |
chat_output = tokenizer.apply_chat_template(messages, tools = tools, documents = documents, chat_template = template, tokenize = False, **chat_template_kwargs)
|
| 1395 |
except Exception as e:
|
| 1396 |
+
emsg = f"Line {e.lineno}: " if hasattr(e, "lineno") else ""
|
| 1397 |
+
emsg += e.message if hasattr(e, "message") else str(e)
|
| 1398 |
gr.Warning(
|
| 1399 |
+
message = emsg,
|
| 1400 |
duration = None,
|
| 1401 |
title = "Chat Template Error",
|
| 1402 |
)
|
| 1403 |
try:
|
| 1404 |
chat_tool_use_output = tokenizer.apply_chat_template(messages, tools = tools or [], chat_template = template_tool_use, tokenize = False, **chat_template_kwargs) if template_tool_use else None
|
| 1405 |
except Exception as e:
|
| 1406 |
+
emsg = f"Line {e.lineno}: " if hasattr(e, "lineno") else ""
|
| 1407 |
+
emsg += e.message if hasattr(e, "message") else str(e)
|
| 1408 |
gr.Warning(
|
| 1409 |
+
message = emsg,
|
| 1410 |
duration = None,
|
| 1411 |
title = "Tool Use Template Error",
|
| 1412 |
)
|
| 1413 |
try:
|
| 1414 |
chat_rag_output = tokenizer.apply_chat_template(messages, documents = documents or [], chat_template = template_rag, tokenize = False, **chat_template_kwargs) if template_rag else None
|
| 1415 |
except Exception as e:
|
| 1416 |
+
emsg = f"Line {e.lineno}: " if hasattr(e, "lineno") else ""
|
| 1417 |
+
emsg += e.message if hasattr(e, "message") else str(e)
|
| 1418 |
gr.Warning(
|
| 1419 |
+
message = emsg,
|
| 1420 |
duration = None,
|
| 1421 |
title = "RAG Template Error",
|
| 1422 |
)
|
| 1423 |
try:
|
| 1424 |
inverse_output = tokenizer.apply_inverse_template(messages, inverse_template = template_inverse, **chat_template_kwargs) if template_inverse else None
|
| 1425 |
except Exception as e:
|
| 1426 |
+
emsg = f"Line {e.lineno}: " if hasattr(e, "lineno") else ""
|
| 1427 |
+
emsg += e.message if hasattr(e, "message") else str(e)
|
| 1428 |
gr.Warning(
|
| 1429 |
+
message = emsg,
|
| 1430 |
duration = None,
|
| 1431 |
title = "Inverse Template Error",
|
| 1432 |
)
|