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

fix: Azure OpenAI o1 max_completion_token and get_num_token_from_messages error #9326

Merged
merged 8 commits into from
Oct 15, 2024

Conversation

somethingwentwell
Copy link
Contributor

@somethingwentwell somethingwentwell commented Oct 14, 2024

Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue. Close issue syntax: Fixes #<issue number>, see documentation for more details.

Fixes #9325
Fixes #9327

  • Upgrade openai to at least 1.45.0
  • Upgrade tiktoken to at least 0.8.0
  • Add validate_credentials for o1 in dify/api/core/model_runtime/model_providers/azure_openai/llm/llm.py

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Build the api image and run again. Add Azure OpenAI o1-preview and o1-mini and test with an agent
    Screenshot 2024-10-14 at 5 55 57 PM

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. dependencies Pull requests that update a dependency file 🐞 bug Something isn't working labels Oct 14, 2024
Copy link
Member

@laipz8200 laipz8200 left a comment

Choose a reason for hiding this comment

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

Please do not touch the files under /docker

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 14, 2024
@somethingwentwell
Copy link
Contributor Author

Please do not touch the files under /docker

Done

@crazywoola
Copy link
Member

crazywoola commented Oct 14, 2024

Please fix the tests

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Oct 15, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Oct 15, 2024
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Oct 15, 2024
@somethingwentwell
Copy link
Contributor Author

Please fix the tests

Done, new version of openai moderations require category_applied_input_types and illicit & illicit/violent, so edited api/tests/integration_tests/model_runtime/__mock/openai_moderation.py

Copy link
Member

@laipz8200 laipz8200 left a comment

Choose a reason for hiding this comment

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

Thank you!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 15, 2024
@laipz8200 laipz8200 merged commit b597a0d into langgenius:main Oct 15, 2024
6 checks passed
@yanzu888
Copy link

Hello, if I am deploying using Docker, how can I handle this issue? Thank you for your answer.

@laipz8200
Copy link
Member

Hello, if I am deploying using Docker, how can I handle this issue? Thank you for your answer.

Just wait for our next release :)

@yanzu888
Copy link

Hello, if I am deploying using Docker, how can I handle this issue? Thank you for your answer.

Just wait for our next release :)

okay, thank you

@somethingwentwell
Copy link
Contributor Author

Hello, if I am deploying using Docker, how can I handle this issue? Thank you for your answer.

You can also build the api and web image and replace your custom image to the docker compose yml and run it

ZhouhaoJiang added a commit that referenced this pull request Oct 17, 2024
* main: (35 commits)
  fix #9409 (#9433)
  update dataset clean rule (#9426)
  add clean 7 days datasets (#9424)
  fix: resolve overlap issue with API Extension selector and modal (#9407)
  refactor: update the default values of top-k parameter in vdb to be consistent (#9367)
  fix: incorrect webapp image displayed (#9401)
  Fix/economical knowledge retrieval (#9396)
  feat: add timezone conversion for time tool (#9393)
  fix: Deprecated gemma2-9b model in Fireworks AI Provider (#9373)
  feat: storybook (#9324)
  fix: use gpt-4o-mini for validating credentials (#9387)
  feat: Enable baiduvector intergration test (#9369)
  fix: remove the stream option of zhipu and gemini (#9319)
  fix: add missing vikingdb param in docker .env.example (#9334)
  feat: add minimax abab6.5t support (#9365)
  fix: (#9336 followup) skip poetry preperation in style workflow when no change in api folder (#9362)
  feat: add glm-4-flashx, deprecated chatglm_turbo (#9357)
  fix: Azure OpenAI o1 max_completion_token and get_num_token_from_messages error (#9326)
  fix: In the output, the order of 'ta' is sometimes reversed as 'at'. #8015 (#8791)
  refactor: Add an enumeration type and use the factory pattern to obtain the corresponding class (#9356)
  ...
ZhouhaoJiang added a commit that referenced this pull request Oct 17, 2024
* feat/new-login: (30 commits)
  feat: add init login type
  fix #9409 (#9433)
  update dataset clean rule (#9426)
  add clean 7 days datasets (#9424)
  fix: resolve overlap issue with API Extension selector and modal (#9407)
  refactor: update the default values of top-k parameter in vdb to be consistent (#9367)
  fix: incorrect webapp image displayed (#9401)
  Fix/economical knowledge retrieval (#9396)
  feat: add timezone conversion for time tool (#9393)
  fix: Deprecated gemma2-9b model in Fireworks AI Provider (#9373)
  feat: storybook (#9324)
  fix: use gpt-4o-mini for validating credentials (#9387)
  feat: Enable baiduvector intergration test (#9369)
  fix: remove the stream option of zhipu and gemini (#9319)
  fix: add missing vikingdb param in docker .env.example (#9334)
  feat: add minimax abab6.5t support (#9365)
  fix: (#9336 followup) skip poetry preperation in style workflow when no change in api folder (#9362)
  feat: add glm-4-flashx, deprecated chatglm_turbo (#9357)
  fix: Azure OpenAI o1 max_completion_token and get_num_token_from_messages error (#9326)
  fix: In the output, the order of 'ta' is sometimes reversed as 'at'. #8015 (#8791)
  ...
lau-td pushed a commit to heydevs-io/dify that referenced this pull request Oct 23, 2024
idonotknow pushed a commit to AceDataCloud/Dify that referenced this pull request Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
5 participants