Fix web search and template max tokens (#1564)

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
H
2024-07-17 14:19:14 +08:00
committed by GitHub
parent 83c9f1ed39
commit 1015436691
6 changed files with 19 additions and 16 deletions

View File

@ -43,7 +43,7 @@ class Baidu(ComponentBase, ABC):
ans = self.get_input()
ans = " - ".join(ans["content"]) if "content" in ans else ""
if not ans:
return Baidu.be_output(self._param.no)
return Baidu.be_output("")
url = 'https://www.baidu.com/s?wd=' + ans + '&rn=' + str(self._param.top_n)
headers = {
@ -56,8 +56,10 @@ class Baidu(ComponentBase, ABC):
baidu_res = [{"content": re.sub('<em>|</em>', '', '<a href="' + url + '">' + title + '</a> ' + body)} for url, title, body in zip(url_res, title_res, body_res)]
del body_res, url_res, title_res
df = pd.DataFrame(baidu_res)
print(df, ":::::::::::::::::::::::::::::::::")
if not baidu_res:
return Baidu.be_output("")
df = pd.DataFrame(baidu_res)
if DEBUG: print(df, ":::::::::::::::::::::::::::::::::")
return df