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

support AZure Openai #572

Merged
merged 3 commits into from
Aug 13, 2024
Merged

Conversation

Yimi81
Copy link
Contributor

@Yimi81 Yimi81 commented Aug 12, 2024

Change Summary

Support Azure openai, reference here

Related issue number

#243

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Run pre-commit install and pre-commit run --all-files before git commit, and passed lint check.
  • Some cases need DASHSCOPE_TOKEN_API to pass the Unit Tests, I have at least pass the Unit tests on local
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Please review @zzhangpurdue

messages=messages,
stop=stop,
stream=True,
stream_options=stream_options,
Copy link
Contributor

Choose a reason for hiding this comment

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

why azure api and openai api are processed differently, they should be identical in terms of api interfaces (for example, both support stream_options)

Copy link
Contributor Author

@Yimi81 Yimi81 Aug 13, 2024

Choose a reason for hiding this comment

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

  • This is because the Azure API is not always fully compatible with the OpenAI API. It depends on the api_version of the Azure instance being used, which in my case is 2024-06-01(latest version).
  • When I make a request, it results in an error: openai.BadRequestError: Error code: 400 - {'error': {'message': "Unknown parameter: 'stream_options'.", 'type': 'invalid_request_error', 'param': 'stream_options', 'code': 'unknown_parameter'}}.
  • I reviewed the official request body and did not find the 'stream_options' parameter.
  • Therefore, it is recommended to handle the request parameters for Azure OpenAI and OpenAI separately for better compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like it is ineed the case, openai/openai-python#1469

that is very unfortunate.

still, i would recommend putting stream_options into kwargs (only when using native openai api), which would make the code much cleaner: there is not need to duplicate the entire completions.create call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@yingdachen yingdachen left a comment

Choose a reason for hiding this comment

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

thanks. lgtm

@yingdachen yingdachen merged commit 10b1dbf into modelscope:master Aug 13, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants