Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Feat/add bing search (#2379)
Yeuoly6278ff0f3014
diff --git a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py b/api/core/tools/provider/builtin/bing/tools/bing_web_search.pyindex e13e538806b..490a9deee56 100644--- a/api/core/tools/provider/builtin/bing/tools/bing_web_search.py+++ b/api/core/tools/provider/builtin/bing/tools/bing_web_search.py@@ -28,6 +28,9 @@ class BingSearchTool(BuiltinTool):if not query:raise Exception('query is required')+ limit = min(tool_parameters.get('limit', 5), 10)+ result_type = tool_parameters.get('result_type', 'text') or 'text'+market = tool_parameters.get('market', 'US')lang = tool_parameters.get('language', 'en')@@ -49,13 +52,24 @@ class BingSearchTool(BuiltinTool):raise Exception(f'Error {response.status_code}: {response.text}')response = response.json()- # get the first 5 results- search_results = response['webPages']['value'][:5]- results = []- for result in search_results:- results.append(self.create_text_message(- text=f'{result["name"]}: {result["url"]}'- ))-- return results-\ No newline at end of file+ search_results = response['webPages']['value'][:limit]++ if result_type == 'link':+ results = []+ for result in search_results:+ results.append(self.create_text_message(+ text=f'{result["name"]}: {result["url"]}'+ ))++ return results+ else:+ # construct text+ text = ''+ for i, result in enumerate(search_results):+ text += f'{i+1}: {result["name"]} - {result["snippet"]}\n'++ text += '\n\nRelated Searches:\n'+ for related in response['relatedSearches']['value']:+ text += f'{related["displayText"]} - {related["webSearchUrl"]}\n'++ return self.create_text_message(text=self.summary(user_id=user_id, content=text))diff --git a/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml b/api/core/tools/provider/builtin/bing/tools/bing_web_search.yamlindex ebb67af48df..329a83f12fb 100644--- a/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml+++ b/api/core/tools/provider/builtin/bing/tools/bing_web_search.yaml@@ -15,6 +15,7 @@ parameters:- name: querytype: stringrequired: true+ form: llmlabel:en_US: Query stringzh_Hans: 查询语句@@ -24,7 +25,45 @@ parameters:zh_Hans: 用于搜索网页内容pt_BR: used for searchingllm_description: key words for searching- form: llm+ - name: limit+ type: number+ required: false+ form: form+ label:+ en_US: Limit for results length+ zh_Hans: 返回长度限制+ pt_BR: Limit for results length+ human_description:+ en_US: limit the number of results+ zh_Hans: 限制返回结果的数量+ pt_BR: limit the number of results+ min: 1+ max: 10+ default: 5+ - name: result_type+ type: select+ required: false+ label:+ en_US: result type+ zh_Hans: 结果类型+ pt_BR: result type+ human_description:+ en_US: return a list of links or texts+ zh_Hans: 返回一个连接列表还是纯文本内容+ pt_BR: return a list of links or texts+ default: text+ options:+ - value: link+ label:+ en_US: Link+ zh_Hans: 链接+ pt_BR: Link+ - value: text+ label:+ en_US: Text+ zh_Hans: 文本+ pt_BR: Text+ form: form- name: markettype: selectlabel: