gpt4 book ai didi

python - 在 Azure 认知服务上找不到资源

转载 作者:行者123 更新时间:2023-12-01 06:52:24 30 4
gpt4 key购买 nike

我已按照 the tutorial 1 创建了 Azure 认知服务资源

然后我创建了环境并运行以下代码(来自 tutorial 2 ):

# Import required modules.
from azure.cognitiveservices.search.websearch import WebSearchAPI
from azure.cognitiveservices.search.websearch.models import SafeSearch
from msrest.authentication import CognitiveServicesCredentials

# Replace with your subscription key.
subscription_key = "YOUR_SUBSCRIPTION_KEY"

# Instantiate the client and replace with your endpoint.
client = WebSearchAPI(CognitiveServicesCredentials(subscription_key), base_url = "YOUR_ENDPOINT")

# Make a request. Replace Yosemite if you'd like.
web_data = client.web.search(query="Yosemite")
print("\r\nSearched for Query# \" Yosemite \"")

但是,脚本似乎无法正确读取生成的订阅 key 端点,因为我收到以下错误:

File "azu_scrapper.py", line 17, in web_data = client.web.search(query="Yosemite") File "/home/user/.local/share/virtualenvs/linkedin-CHSAGU1d/lib/python3.7/site-packages/azure/cognitiveservices/search/websearch/operations/web_operations.py", line 365, in search raise models.ErrorResponseException(self._deserialize, response) azure.cognitiveservices.search.websearch.models.error_response_py3.ErrorResponseException: Operation returned an invalid status code 'Resource Not Found'

知道为什么它不起作用吗?

最佳答案

base_url 值应为:

https://<your endpoint>/bing/v7.0

我已经在我这边进行了测试,它对我有用:

enter image description here

关于python - 在 Azure 认知服务上找不到资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58937613/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com