style:fmt

This commit is contained in:
aries_ckt
2023-08-29 20:28:16 +08:00
parent 71b9cd14a6
commit e70f05aea1
8 changed files with 42 additions and 42 deletions

View File

@@ -155,7 +155,7 @@ class BaseOutputParser(ABC):
if i < 0:
return None
count = 1
for j, c in enumerate(s[i + 1:], start=i + 1):
for j, c in enumerate(s[i + 1 :], start=i + 1):
if c == "]":
count -= 1
elif c == "[":
@@ -163,13 +163,13 @@ class BaseOutputParser(ABC):
if count == 0:
break
assert count == 0
return s[i: j + 1]
return s[i : j + 1]
else:
i = s.find("{")
if i < 0:
return None
count = 1
for j, c in enumerate(s[i + 1:], start=i + 1):
for j, c in enumerate(s[i + 1 :], start=i + 1):
if c == "}":
count -= 1
elif c == "{":
@@ -177,7 +177,7 @@ class BaseOutputParser(ABC):
if count == 0:
break
assert count == 0
return s[i: j + 1]
return s[i : j + 1]
def parse_prompt_response(self, model_out_text) -> T:
"""
@@ -194,9 +194,9 @@ class BaseOutputParser(ABC):
# if "```" in cleaned_output:
# cleaned_output, _ = cleaned_output.split("```")
if cleaned_output.startswith("```json"):
cleaned_output = cleaned_output[len("```json"):]
cleaned_output = cleaned_output[len("```json") :]
if cleaned_output.startswith("```"):
cleaned_output = cleaned_output[len("```"):]
cleaned_output = cleaned_output[len("```") :]
if cleaned_output.endswith("```"):
cleaned_output = cleaned_output[: -len("```")]
cleaned_output = cleaned_output.strip()