mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-03 01:54:44 +00:00
style:fmt
This commit is contained in:
@@ -155,7 +155,7 @@ class BaseOutputParser(ABC):
|
|||||||
if i < 0:
|
if i < 0:
|
||||||
return None
|
return None
|
||||||
count = 1
|
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 == "]":
|
if c == "]":
|
||||||
count -= 1
|
count -= 1
|
||||||
elif c == "[":
|
elif c == "[":
|
||||||
@@ -163,13 +163,13 @@ class BaseOutputParser(ABC):
|
|||||||
if count == 0:
|
if count == 0:
|
||||||
break
|
break
|
||||||
assert count == 0
|
assert count == 0
|
||||||
return s[i: j + 1]
|
return s[i : j + 1]
|
||||||
else:
|
else:
|
||||||
i = s.find("{")
|
i = s.find("{")
|
||||||
if i < 0:
|
if i < 0:
|
||||||
return None
|
return None
|
||||||
count = 1
|
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 == "}":
|
if c == "}":
|
||||||
count -= 1
|
count -= 1
|
||||||
elif c == "{":
|
elif c == "{":
|
||||||
@@ -177,7 +177,7 @@ class BaseOutputParser(ABC):
|
|||||||
if count == 0:
|
if count == 0:
|
||||||
break
|
break
|
||||||
assert count == 0
|
assert count == 0
|
||||||
return s[i: j + 1]
|
return s[i : j + 1]
|
||||||
|
|
||||||
def parse_prompt_response(self, model_out_text) -> T:
|
def parse_prompt_response(self, model_out_text) -> T:
|
||||||
"""
|
"""
|
||||||
@@ -194,9 +194,9 @@ class BaseOutputParser(ABC):
|
|||||||
# if "```" in cleaned_output:
|
# if "```" in cleaned_output:
|
||||||
# cleaned_output, _ = cleaned_output.split("```")
|
# cleaned_output, _ = cleaned_output.split("```")
|
||||||
if cleaned_output.startswith("```json"):
|
if cleaned_output.startswith("```json"):
|
||||||
cleaned_output = cleaned_output[len("```json"):]
|
cleaned_output = cleaned_output[len("```json") :]
|
||||||
if cleaned_output.startswith("```"):
|
if cleaned_output.startswith("```"):
|
||||||
cleaned_output = cleaned_output[len("```"):]
|
cleaned_output = cleaned_output[len("```") :]
|
||||||
if cleaned_output.endswith("```"):
|
if cleaned_output.endswith("```"):
|
||||||
cleaned_output = cleaned_output[: -len("```")]
|
cleaned_output = cleaned_output[: -len("```")]
|
||||||
cleaned_output = cleaned_output.strip()
|
cleaned_output = cleaned_output.strip()
|
||||||
|
Reference in New Issue
Block a user