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

538 upgrade openai dependency #543

Closed

Conversation

arpagon
Copy link
Contributor

@arpagon arpagon commented May 10, 2024

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

  • Review API Documentation: Ensured a thorough understanding of the changes and new features in the OpenAI SDK v1.0.0.
  • Update Dependency in pyproject.toml: Updated the OpenAI SDK version using Poetry.
  • 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 arpagon requested a review from ajar98 May 10, 2024 22:00
return np.array(
(await openai.Embedding.acreate(**params))["data"][0]["embedding"]
# Create the embedding using the OpenAI API
response = await self.async_openai_client.embeddings.create(
Copy link
Contributor

Choose a reason for hiding this comment

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

think this will break unless we switch on Azure in the constructor

@arpagon arpagon added enhancement New feature or request help wanted Extra attention is needed labels May 18, 2024
@ajar98
Copy link
Contributor

ajar98 commented Jun 14, 2024

has been subsumed by the latest changes!

@ajar98 ajar98 closed this Jun 14, 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 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants