Spaces:
Sleeping
Sleeping
File size: 680 Bytes
e679d69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
from typing import Any
class StrParser:
def __init__(
self,
template: str = '',
**format_field,
):
self.template = template
self.format_field = format_field
def format_instruction(self) -> Any:
format_data = {
key: self.format_to_string(value)
for key, value in self.format_field.items()
}
return self.template.format(**format_data)
def format_to_string(self, format_model: Any) -> str:
return format_model
def format_response(self, parsed: dict) -> str:
raise NotImplementedError
def parse_response(self, data: str) -> str:
return data
|