Explorar el Código

fix: missing url field when searching special keywords (#3820)

tags/0.6.5
Yeuoly hace 1 año
padre
commit
2832adda88
No account linked to committer's email address
Se han modificado 1 ficheros con 15 adiciones y 8 borrados
  1. 15
    8
      api/core/tools/provider/builtin/bing/tools/bing_web_search.py

+ 15
- 8
api/core/tools/provider/builtin/bing/tools/bing_web_search.py Ver fichero

results = [] results = []
if search_results: if search_results:
for result in search_results: for result in search_results:
url = f': {result["url"]}' if "url" in result else ""
results.append(self.create_text_message( results.append(self.create_text_message(
text=f'{result["name"]}: {result["url"]}'
text=f'{result["name"]}{url}'
)) ))




if entities: if entities:
for entity in entities: for entity in entities:
url = f': {entity["url"]}' if "url" in entity else ""
results.append(self.create_text_message( results.append(self.create_text_message(
text=f'{entity["name"]}: {entity["url"]}'
text=f'{entity.get("name", "")}{url}'
)) ))


if news: if news:
for news_item in news: for news_item in news:
url = f': {news_item["url"]}' if "url" in news_item else ""
results.append(self.create_text_message( results.append(self.create_text_message(
text=f'{news_item["name"]}: {news_item["url"]}'
text=f'{news_item.get("name", "")}{url}'
)) ))


if related_searches: if related_searches:
for related in related_searches: for related in related_searches:
url = f': {related["displayText"]}' if "displayText" in related else ""
results.append(self.create_text_message( results.append(self.create_text_message(
text=f'{related["displayText"]}: {related["webSearchUrl"]}'
text=f'{related.get("displayText", "")}{url}'
)) ))
return results return results
text = '' text = ''
if search_results: if search_results:
for i, result in enumerate(search_results): for i, result in enumerate(search_results):
text += f'{i+1}: {result["name"]} - {result["snippet"]}\n'
text += f'{i+1}: {result.get("name", "")} - {result.get("snippet", "")}\n'


if computation and 'expression' in computation and 'value' in computation: if computation and 'expression' in computation and 'value' in computation:
text += '\nComputation:\n' text += '\nComputation:\n'
if entities: if entities:
text += '\nEntities:\n' text += '\nEntities:\n'
for entity in entities: for entity in entities:
text += f'{entity["name"]} - {entity["url"]}\n'
url = f'- {entity["url"]}' if "url" in entity else ""
text += f'{entity.get("name", "")}{url}\n'


if news: if news:
text += '\nNews:\n' text += '\nNews:\n'
for news_item in news: for news_item in news:
text += f'{news_item["name"]} - {news_item["url"]}\n'
url = f'- {news_item["url"]}' if "url" in news_item else ""
text += f'{news_item.get("name", "")}{url}\n'


if related_searches: if related_searches:
text += '\n\nRelated Searches:\n' text += '\n\nRelated Searches:\n'
for related in related_searches: for related in related_searches:
text += f'{related["displayText"]} - {related["webSearchUrl"]}\n'
url = f'- {related["webSearchUrl"]}' if "webSearchUrl" in related else ""
text += f'{related.get("displayText", "")}{url}\n'


return self.create_text_message(text=self.summary(user_id=user_id, content=text)) return self.create_text_message(text=self.summary(user_id=user_id, content=text))

Cargando…
Cancelar
Guardar