当我尝试使用Azure Open AI运行Semantic-kernel时,出现以下错误
Error: (<ErrorCodes.ServiceError: 6>, 'OpenAI service failed to complete the chat', InvalidRequestError(message='Resource not found', param=None, code='404', http_status=404, request_id=None))
我使用以下代码,参考https://github.com/microsoft/semantic-kernel/blob/main/python/README.md
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
kernel = sk.Kernel()
deployment, api_key, endpoint = "<MY_DEPLOYMENT_NAME>","<MY_API_KEY>", "<MY_ENDPOINT>"
# print(f'kernel.add_chat_service("dv", AzureChatCompletion(deployment_name=deployment, endpoint=endpoint, api_key=api_key))')
kernel.add_chat_service("dv", AzureChatCompletion(deployment_name=deployment, endpoint=endpoint, api_key=api_key))
# Wrap your prompt in a function
prompt = kernel.create_semantic_function("""
Write a simple hello-world python program.
""")
# Run your prompt
print(prompt())
当我试图找到解决方案时,我在kerrnel.add_chat_service上运行print(f“)语句,得到以下错误
Traceback (most recent call last):
File "C:\Users\yashroop.rai\Desktop\semantic-kernel\semantic-kernel.py", line 10, in <module>
prompt = kernel.create_semantic_function("""
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yashroop.rai\AppData\Local\Programs\Python\Python311\Lib\site-packages\semantic_kernel\kernel.py", line 851, in create_semantic_function
return self.register_semantic_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yashroop.rai\AppData\Local\Programs\Python\Python311\Lib\site-packages\semantic_kernel\kernel.py", line 129, in register_semantic_function
function = self._create_semantic_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yashroop.rai\AppData\Local\Programs\Python\Python311\Lib\site-packages\semantic_kernel\kernel.py", line 692, in _create_semantic_function
service = self.get_ai_service(
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\yashroop.rai\AppData\Local\Programs\Python\Python311\Lib\site-packages\semantic_kernel\kernel.py", line 429, in get_ai_service
raise ValueError(
ValueError: TextCompletionClientBase service with service_id 'None' not found
有什么办法吗?端点和API_key是正确的,因为我一直在使用它作为一个正常的POST请求通过API调用,这工作正常。
1条答案
按热度按时间7y4bm7vi1#
运行Microsoft semantic-kernel时出现资源未找到错误
当您在代码中传递不正确的部署名称或API_key或终结点时,会发生上述错误。
我创建了Azure Open AI服务,并部署了名为**
deploymentname1
的gpt-35-turbo
**模型。入口:
现在使用下面的代码,我可以使用Python在Azure open ai中运行语义内核。
验证码:
输出:
word = input("Enter a word: ")
if word == word[::-1]:
print("The word is a palindrome!")
else:
print("The word is not a palindrome.")
参考:
向语义内核添加AI服务|微软学习