add max_version for deprecated imports #1227
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In OpenAI 1.92.0 some paths for imports were migrated. This change implements a max_version to prevent deprecated
betaimports which have migrated from being referenced on versions after.See issue: langfuse/langfuse#7533
Testing
I hacked changed lines on my end in the
2.60.8SDK. Seeing traces successfully populate in Langfuse and no more import errors on application start.Important
Adds
max_versiontoOpenAiDefinitionand updatesregister_tracingto prevent deprecated imports post version 1.91.0.max_versionattribute toOpenAiDefinitionclass inopenai.py.register_tracing()to skip imports withmax_versionless than currentopenaiversion.max_versionto1.91.0foropenai.resources.beta.chat.completionsinOPENAI_METHODS_V1.openai.resources.chat.completionswithmin_version1.92.0.This description was created by
for 20ddd24. You can customize this summary. It will automatically update as commits are pushed.
Greptile Summary
Disclaimer: Experimental PR review
Adds version control for OpenAI SDK path migrations in version 1.92.0, ensuring compatibility with the new module structure while maintaining support for older versions.
max_versionfield toOpenAiDefinitionclass inlangfuse/openai.pyto handle version-specific importsregister_tracingto prevent usage of deprecated beta paths after v1.92.0