microsoft / generative-ai-for-beginners

18 Lessons, Get Started Building with Generative AI 🔗 https://microsoft.github.io/generative-ai-for-beginners/
https://microsoft.github.io/generative-ai-for-beginners/
MIT License
61.65k stars 31.29k forks source link

api_version is hard coded in *.py files and has different values among projects #541

Open bmerkle opened 1 month ago

bmerkle commented 1 month ago

Describe the bug Possible improvements for the handling of api_version in *.py files

  1. the variable is often hard coded in *.py files (instead of using the .env file for specifying)
  2. the variable has different values among the projects
  3. even sometimes if had different values in the same project (e.g. 08-building-search-applications)

I could contribute a patch to improve the handling of api_version. Open questions:

  1. on patch per project or a large ?
  2. what should be the default for the value ?

To Reproduce Please see the example report C:\work\microsoft\generative-ai-for-beginners\06-text-generation-apps\python\aoai-app-recipe.py (1 hit) Line 12: api_version = "2023-10-01-preview" C:\work\microsoft\generative-ai-for-beginners\06-text-generation-apps\python\aoai-app.py (1 hit) Line 13: api_version = "2023-05-15" C:\work\microsoft\generative-ai-for-beginners\06-text-generation-apps\python\aoai-history-bot.py (1 hit) Line 12: api_version = "2023-10-01-preview" C:\work\microsoft\generative-ai-for-beginners\06-text-generation-apps\python\aoai-study-buddy.py (1 hit) Line 12: api_version = "2023-10-01-preview" C:\work\microsoft\generative-ai-for-beginners\08-building-search-applications\scripts\transcript_enrich_embeddings.py (1 hit) Line 30: openai.api_version = "2023-05-15" C:\work\microsoft\generative-ai-for-beginners\08-building-search-applications\scripts\transcript_enrich_speaker.py (1 hit) Line 41: openai.api_version = "2023-07-01-preview" C:\work\microsoft\generative-ai-for-beginners\08-building-search-applications\scripts\transcript_enrich_summaries.py (1 hit) Line 30: openai.api_version = "2023-07-01-preview" C:\work\microsoft\generative-ai-for-beginners\09-building-image-applications\python\aoai-app-variation.py (1 hit) Line 14: api_version = "2023-12-01-preview", C:\work\microsoft\generative-ai-for-beginners\09-building-image-applications\python\aoai-app.py (1 hit) Line 16: api_version = "2023-12-01-preview", C:\work\microsoft\generative-ai-for-beginners\09-building-image-applications\python\aoai-solution.py (1 hit) Line 16: api_version = "2023-12-01-preview",

Expected behavior

  1. handling should be unified to use the .env files for api_version and no hardcoded values in *.py files
  2. api_version should be the most recent if possible
github-actions[bot] commented 1 month ago

👋 Thanks for contributing @bmerkle! We will review the issue and get back to you soon.

koreyspace commented 5 days ago

We have hardcoded some of these values to make sure the course is operational through any of the changes. Would need to investigate / test to see if just relying on the latest values has any effect on the code.