pylint: multi model for gp4all (#138)

This commit is contained in:
csunny
2023-06-14 10:17:53 +08:00
parent 3927c26dea
commit ff6d3a7035
25 changed files with 154 additions and 111 deletions

View File

@@ -121,17 +121,17 @@ class BaseOutputParser(ABC):
raise ValueError("Model server error!code=" + respObj_ex["error_code"])
def __extract_json(slef, s):
i = s.index('{')
i = s.index("{")
count = 1 # 当前所在嵌套深度,即还没闭合的'{'个数
for j, c in enumerate(s[i + 1:], start=i + 1):
if c == '}':
for j, c in enumerate(s[i + 1 :], start=i + 1):
if c == "}":
count -= 1
elif c == '{':
elif c == "{":
count += 1
if count == 0:
break
assert (count == 0) # 检查是否找到最后一个'}'
return s[i:j + 1]
assert count == 0 # 检查是否找到最后一个'}'
return s[i : j + 1]
def parse_prompt_response(self, model_out_text) -> T:
"""