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(openai): Lazy initialize tiktoken to avoid http at import time #3287

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

colin-sentry
Copy link
Member

tiktoken.get_encoding makes a HTTP connection if the encoding doesn't already exist.

If a user has OpenAI, sentry, and tiktoken all installed, this line would make a HTTP request at import time.

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.36%. Comparing base (ae034ab) to head (4b63cf0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3287      +/-   ##
==========================================
- Coverage   79.41%   79.36%   -0.05%     
==========================================
  Files         132      132              
  Lines       14279    14281       +2     
  Branches     2998     2999       +1     
==========================================
- Hits        11339    11334       -5     
- Misses       2094     2096       +2     
- Partials      846      851       +5     
Files Coverage Δ
sentry_sdk/integrations/openai.py 78.52% <100.00%> (+0.26%) ⬆️

... and 4 files with indirect coverage changes

@colin-sentry colin-sentry merged commit 301c4b8 into master Jul 12, 2024
122 checks passed
@colin-sentry colin-sentry deleted the lazy_init_tiktoken branch July 12, 2024 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants