|
4 | 4 | import inspect
|
5 | 5 | import logging
|
6 | 6 | import math
|
| 7 | +import re |
7 | 8 | from dataclasses import dataclass
|
8 | 9 | from functools import reduce
|
| 10 | +from typing import Callable |
9 | 11 |
|
10 | 12 | import yaml
|
11 | 13 | from examples import cai_helpers
|
12 | 14 | from pp_exceptions import TruncationError
|
13 |
| -from template_loaders import TemplateLoader |
14 | 15 | from template import Template
|
| 16 | +from template_loaders import TemplateLoader |
15 | 17 | from tokenizer import get_encode_func
|
16 |
| -from typing import Callable |
17 | 18 |
|
18 | 19 | SPACE_MARKER = "<|space|>"
|
19 | 20 |
|
@@ -97,12 +98,6 @@ def __init__(
|
97 | 98 | from_cache: bool = False,
|
98 | 99 | from_examples: bool = False,
|
99 | 100 | space_marker: str = SPACE_MARKER,
|
100 |
| - newline: str = "\n", |
101 |
| - escaped_newline: str = "\\n", |
102 |
| - carriage_return: str = "\r", |
103 |
| - escaped_carriage_return: str = "\\r", |
104 |
| - single_quote: str = "'", |
105 |
| - escaped_single_quote: str = "'", |
106 | 101 | allow_token_overrides: bool = False,
|
107 | 102 | ):
|
108 | 103 | """Initialize the prompt object."""
|
@@ -502,7 +497,6 @@ def _escape_special_characters(self, string: str) -> str:
|
502 | 497 |
|
503 | 498 | def _unescape_special_characters(self, string: str) -> str:
|
504 | 499 | """Unescape special characters."""
|
505 |
| - import re |
506 | 500 | string = re.sub(r'\\u([0-9a-fA-F]{4})', lambda m: chr(int(m.group(1), 16)), string)
|
507 | 501 |
|
508 | 502 | return (
|
|
0 commit comments