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

@ -44,7 +44,7 @@ class DuckDuckGo(ComponentBase, ABC):
ans = self.get_input()
ans = " - ".join(ans["content"]) if "content" in ans else ""
if not ans:
return DuckDuckGo.be_output(self._param.no)
return DuckDuckGo.be_output("")
if self._param.channel == "text":
with DDGS() as ddgs:
@ -57,6 +57,9 @@ class DuckDuckGo(ComponentBase, ABC):
duck_res = [{"content": '<a href="' + i["url"] + '">' + i["title"] + '</a> ' + i["body"]} for i in
ddgs.news(ans, max_results=self._param.top_n)]
if not duck_res:
return DuckDuckGo.be_output("")
df = pd.DataFrame(duck_res)
print(df, ":::::::::::::::::::::::::::::::::")
if DEBUG: print(df, ":::::::::::::::::::::::::::::::::")
return df