vocode-python icon indicating copy to clipboard operation
vocode-python copied to clipboard

538 upgrade openai dependency

Open arpagon opened this issue 1 year ago • 0 comments

Draft PR Text for Migration to OpenAI SDK v1.0

This PR outlines the steps and changes made during the migration of our project to the OpenAI SDK version 1.0. The migration aims to enhance our application's capabilities by leveraging the latest advancements in the OpenAI SDK.

Task List for Migration

  • [x] Review API Documentation: Ensured a thorough understanding of the changes and new features in the OpenAI SDK v1.0.0.
  • [x] Update Dependency in pyproject.toml: Updated the OpenAI SDK version using Poetry.
  • [x] Use Grit for Automatic Code Refactor (Optional): Applied Grit to automate some of the migration tasks.
  • [ ] Implement Mock Supports for Testing: Adapting the testing framework to incorporate mock supports for the depreciation of OpenAIObjects.
  • [ ] Refactor Test Utilities: Updating the test utilities to reflect changes in the API, especially those related to asynchronous operations and response handling.
  • [ ] Thorough Testing: Comprehensive testing to confirm that all parts of the application interact correctly with the updated SDK.
  • [ ] Documentation Update: Updating the project documentation to reflect the changes made during the migration.

Detailed Changes

  • Update OpenAI SDK Version: Changed the SDK version to "^1.28.0" as per the requirements.
  • Refactor Code to Use New API: Modified existing code to align with the new API structure, including:
    • Replacing global client usage with instantiated clients.
    • Updating method calls to match the new API.
    • Handling response objects as Pydantic models.
    • Using asynchronous methods with the async client.
  • Update Import Statements: Updated import statements in various files such as chat_gpt_agent.py, utils.py, and WhisperTranscriber to use the new OpenAI class instead of the openAI module.
  • Refactor Instantiation of OpenAI Clients: Modified the instantiation of OpenAI clients in classes like ChatGPTAgent and GoodbyeModel to use AsyncOpenAI for asynchronous operations.
  • Modify Method Calls: Updated method calls to use instance variables for OpenAI client interactions across different classes.
  • Ensure Proper Handling of API Keys: Updated the handling of API keys in classes like ChatGPTAgent and GoodbyeModel to ensure security and compliance with the new SDK.

Compatibility Checks

  • Ensured compatibility with the main branch and Python versions specified in the project requirements.
  • Updated optional status and versions of various dependencies as needed.

Testing and Documentation

  • Plan to perform manual and automated regression testing to ensure the application's stability and functionality.
  • Scheduled updates for the project documentation to include new usage examples and configuration details.

This PR is currently a draft and the listed tasks are in progress. Feedback and additional checks are welcome to ensure a smooth transition to the new SDK version.

arpagon avatar May 10 '24 22:05 arpagon