azure openai 模型名称问题 #324

Closed
opened 2026-02-21 17:26:48 -05:00 by yindo · 1 comment
Owner

Originally created by @liyehaha on GitHub (Jul 31, 2023).

Originally assigned to: @takatost on GitHub.

Dify version: Self Host

主要有两个问题:

  1. 代码里面写死了模型名称,这个要求在azure portal创建的时候就要保持一致才行,但是实际上大部分都不是一样的。建议前端增加模型名称的选项,因为不会前端,没法帮忙改。https://github.com/langgenius/dify/blob/main/api/core/llm/provider/azure_provider.py#L24

  2. 创建了一个翻译的模型,但是调用的时候一直在报错。实际模型是可用的。
    api_1 | Traceback (most recent call last):
    api_1 | File "/app/api/core/llm/wrappers/openai_wrapper.py", line 14, in wrapper
    api_1 | return func(*args, **kwargs)
    api_1 | File "/app/api/core/llm/streamable_azure_open_ai.py", line 65, in generate
    api_1 | return super().generate(prompts, stop, callbacks, **kwargs)
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 281, in generate
    api_1 | output = self._generate_helper(
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 225, in _generate_helper
    api_1 | raise e
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 212, in _generate_helper
    api_1 | self._generate(
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 307, in generate
    api_1 | for stream_resp in completion_with_retry(
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 89, in completion_with_retry
    api_1 | return completion_with_retry(**kwargs)
    api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init_
    .py", line 289, in wrapped_f
    api_1 | return self(f, *args, **kw)
    api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init_
    .py", line 379, in call
    api_1 | do = self.iter(retry_state=retry_state)
    api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 314, in iter
    api_1 | return fut.result()
    api_1 | File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result
    api_1 | return self.__get_result()
    api_1 | File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    api_1 | raise self.exception
    api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init_
    .py", line 382, in call
    api_1 | result = fn(*args, **kwargs)
    api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 87, in _completion_with_retry
    api_1 | return llm.client.create(**kwargs)
    api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_resources/completion.py", line 25, in create
    api_1 | return super().create(*args, **kwargs)
    api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    api_1 | response, _, api_key = requestor.request(
    api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 298, in request
    api_1 | resp, got_stream = self._interpret_response(result, stream)
    api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    api_1 | self._interpret_response_line(
    api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 763, in _interpret_response_line
    api_1 | raise self.handle_error_response(
    api_1 | openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.

Originally created by @liyehaha on GitHub (Jul 31, 2023). Originally assigned to: @takatost on GitHub. Dify version: Self Host 主要有两个问题: 1. 代码里面写死了模型名称,这个要求在azure portal创建的时候就要保持一致才行,但是实际上大部分都不是一样的。建议前端增加模型名称的选项,因为不会前端,没法帮忙改。https://github.com/langgenius/dify/blob/main/api/core/llm/provider/azure_provider.py#L24 2. 创建了一个翻译的模型,但是调用的时候一直在报错。实际模型是可用的。 api_1 | Traceback (most recent call last): api_1 | File "/app/api/core/llm/wrappers/openai_wrapper.py", line 14, in wrapper api_1 | return func(*args, **kwargs) api_1 | File "/app/api/core/llm/streamable_azure_open_ai.py", line 65, in generate api_1 | return super().generate(prompts, stop, callbacks, **kwargs) api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 281, in generate api_1 | output = self._generate_helper( api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 225, in _generate_helper api_1 | raise e api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/base.py", line 212, in _generate_helper api_1 | self._generate( api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 307, in _generate api_1 | for stream_resp in completion_with_retry( api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 89, in completion_with_retry api_1 | return _completion_with_retry(**kwargs) api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 289, in wrapped_f api_1 | return self(f, *args, **kw) api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 379, in __call__ api_1 | do = self.iter(retry_state=retry_state) api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 314, in iter api_1 | return fut.result() api_1 | File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 451, in result api_1 | return self.__get_result() api_1 | File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result api_1 | raise self._exception api_1 | File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 382, in __call__ api_1 | result = fn(*args, **kwargs) api_1 | File "/usr/local/lib/python3.10/site-packages/langchain/llms/openai.py", line 87, in _completion_with_retry api_1 | return llm.client.create(**kwargs) api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_resources/completion.py", line 25, in create api_1 | return super().create(*args, **kwargs) api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create api_1 | response, _, api_key = requestor.request( api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 298, in request api_1 | resp, got_stream = self._interpret_response(result, stream) api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 700, in _interpret_response api_1 | self._interpret_response_line( api_1 | File "/usr/local/lib/python3.10/site-packages/openai/api_requestor.py", line 763, in _interpret_response_line api_1 | raise self.handle_error_response( api_1 | openai.error.InvalidRequestError: The API deployment for this resource does not exist. If you created the deployment within the last 5 minutes, please wait a moment and try again.
yindo added the 💪 enhancement label 2026-02-21 17:26:48 -05:00
yindo closed this issue 2026-02-21 17:26:48 -05:00
Author
Owner

@crazywoola commented on GitHub (Aug 14, 2023):

Please see v0.3.13

@crazywoola commented on GitHub (Aug 14, 2023): Please see v0.3.13
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#324