in promptflow/code/append_site_to_search_query.py [0:0]
def web_search(conn:CustomConnection, organization_urls: list, query: str):
sites = organization_urls
count = 3
search_results = []
search_url = "https://api.bing.microsoft.com/v7.0/search"
subscription_key = conn.secrets['bingapikey']
for site in sites:
#search_term = 'site:'+site+ ' ' + query
search_term = query+' site:'+site
headers = {"Ocp-Apim-Subscription-Key": subscription_key}
params = {"q": search_term, "count": count}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results.append(response.json()['webPages']['value'])
# search_results.append(response.json())
return search_results