Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(model): Add support for Azure openAI #1137

Merged
merged 6 commits into from
Feb 2, 2024

Conversation

likenamehaojie
Copy link
Contributor

@likenamehaojie likenamehaojie commented Jan 30, 2024

Support Azure OpenAI Proxy

  • Add API_AZURE_DEPLOYMENT environment variables to adapt to Azure openAI
  • Add variables to adapter to Azure OpenAI

Description

Added support for Azure openAI and added API_AZURE_DEPLOYMENT environment variables to adapt to Azure openAI

How Has This Been Tested?

The test translation has been completed

Snapshots:

Include snapshots for easier review.

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@likenamehaojie
Copy link
Contributor Author

LLM_MODEL=proxyllm
PROXY_API_KEY=xxxx
PROXY_API_BASE=https://xxxxxx.openai.azure.com/
PROXY_API_TYPE=azure
PROXY_SERVER_URL=xxxx
PROXY_API_VERSION=2023-05-15
PROXYLLM_BACKEND=gpt-35-turbo
API_AZURE_DEPLOYMENT=xxxx[deployment_name]

@csunny csunny changed the title Added support for Azure openAI and added API_AZURE_DEPLOYMENT environment variables to adapt to Azure openAI Added support for Azure openAI Jan 30, 2024
@csunny
Copy link
Collaborator

csunny commented Jan 30, 2024

@likenamehaojie Thanks for your PR, We will make a test and merge it.

@fangyinc
Copy link
Collaborator

@likenamehaojie Thank you for your contribution. But there is still a small problem, please use the following command to format the python code: make fmt.

Of course, we recommend that you install pre-commit hooks with following command: pre-commit install.

@likenamehaojie
Copy link
Contributor Author

I have adjusted the code format @fangyinc

@fangyinc
Copy link
Collaborator

OpeanAI LLM proxyllm can't work, error log:

2024-01-31 16:02:06 212eb64a67ea dbgpt.model.cluster.worker.default_worker[1] ERROR Model inference error, detail: Traceback (most recent call last):
  File "/app/dbgpt/model/cluster/worker/default_worker.py", line 246, in async_generate_stream
    async for output in generate_stream_func(
  File "/app/dbgpt/model/proxy/llms/chatgpt.py", line 41, in chatgpt_generate_stream
    async for r in client.generate_stream(request):
  File "/app/dbgpt/model/proxy/llms/chatgpt.py", line 188, in generate_stream
    async for r in self.generate_stream_v1(messages, payload):
  File "/app/dbgpt/model/proxy/llms/chatgpt.py", line 216, in generate_stream_v1
    chat_completion = await self.client.chat.completions.create(
  File "/app/dbgpt/model/proxy/llms/chatgpt.py", line 121, in client
    self._api_type, self._client = _build_openai_client(
  File "/app/dbgpt/model/utils/chatgpt_utils.py", line 152, in _build_openai_client
    return api_type, AsyncOpenAI(
TypeError: AsyncOpenAI.__init__() got an unexpected keyword argument 'api_azure_deployment'

2024-01-31 16:02:06 212eb64a67ea dbgpt.agent.agents.llm.llm_client[1] ERROR Call LLMClient error, Model server error!code=1, error msg is **LLMServer Generate Error, Please CheckErrorInfo.**: AsyncOpenAI.__init__() got an unexpected keyword argument 'api_azure_deployment', detail: Traceback (most recent call last):
  File "/app/dbgpt/agent/agents/llm/llm_client.py", line 184, in _completions_create
    parsed_output = self._output_parser.parse_model_nostream_resp(
  File "/app/dbgpt/core/interface/output_parser.py", line 109, in parse_model_nostream_resp
    raise ValueError(
ValueError: Model server error!code=1, error msg is **LLMServer Generate Error, Please CheckErrorInfo.**: AsyncOpenAI.__init__() got an unexpected keyword argument 'api_azure_deployment'

2024-01-31 16:02:06 212eb64a67ea dbgpt.agent.agents.base_agent[1] ERROR model:proxyllm generate Failed!LLM Chat Generrate Error!(Model server error!code=1, error msg is **LLMServer Generate Error, Please CheckErrorInfo.**: AsyncOpenAI.__init__() got an unexpected keyword argument 'api_azure_deployment')

@likenamehaojie
Copy link
Contributor Author

@fangyinc 最新版本的OPENAI是不是对这个方法做了修改?

@likenamehaojie
Copy link
Contributor Author

API_AZURE_DEPLOYMENT @fangyinc need add this environment variables,use main branch to test

@fangyinc
Copy link
Collaborator

API_AZURE_DEPLOYMENT @fangyinc need add this environment variables,use main branch to test

openai.AsyncOpenAI does not support the azure_deployment parameter and needs to be excluded from openai_params.

@likenamehaojie
Copy link
Contributor Author

PROXY_API_TYPE=azure .is add this ? @fangyinc

@likenamehaojie
Copy link
Contributor Author

likenamehaojie commented Jan 31, 2024

image This image shows that this parameter(azure_deployment) is present in the current version(main branch) @fangyinc

@fangyinc
Copy link
Collaborator

image This image shows that this parameter(azure_deployment) is present in the current version(main branch) @fangyinc

Aha, what I mean is not that Azure openAI cannot work, but that OpenAI cannot work~

@likenamehaojie
Copy link
Contributor Author

image This image shows that this parameter(azure_deployment) is present in the current version(main branch) @fangyinc

Aha, what I mean is not that Azure openAI cannot work, but that OpenAI cannot work~

OK,I will fix this bug!

@likenamehaojie
Copy link
Contributor Author

@fangyinc already fixed

Copy link
Collaborator

@csunny csunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR, LGTM

@fangyinc fangyinc changed the title Added support for Azure openAI feat(model): Add support for Azure openAI Feb 2, 2024
@github-actions github-actions bot added enhancement New feature or request model Module: model labels Feb 2, 2024
Copy link
Collaborator

@fangyinc fangyinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM.

@fangyinc fangyinc merged commit 3f70da4 into eosphoros-ai:main Feb 2, 2024
5 checks passed
@cxiaowen
Copy link

LLM_MODEL=proxyllm PROXY_API_KEY=xxxx PROXY_API_BASE=https://xxxxxx.openai.azure.com/ PROXY_API_TYPE=azure PROXY_SERVER_URL=xxxx PROXY_API_VERSION=2023-05-15 PROXYLLM_BACKEND=gpt-35-turbo API_AZURE_DEPLOYMENT=xxxx[deployment_name]

这个是怎么配置进DB-GPT的,也是这种azure模型,但是不知道怎么配置进DB-GPT

Hopshine pushed a commit to Hopshine/DB-GPT that referenced this pull request Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request model Module: model
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants