Repository navigation
fix(openai): default upload_base64_image to None and support sync uploaders #4692
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,16 @@ | ||
| from typing import Callable, Optional | ||
|
|
||
| from opentelemetry._logs import Logger | ||
| from typing_extensions import Coroutine | ||
|
|
||
|
|
||
| class Config: | ||
| enrich_assistant = False | ||
| exception_logger = None | ||
| get_common_metrics_attributes: Callable[[], dict] = lambda: {} | ||
| upload_base64_image: Callable[[str, str, str, str], str] = ( | ||
| lambda trace_id, span_id, image_name, base64_string: str | ||
| ) | ||
| upload_base64_image: Optional[ | ||
| Callable[[str, str, str, str], Coroutine[None, None, str]] | ||
|
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Include synchronous uploaders in the callback type. The changed annotation requires a coroutine result, but
|
||
| ] = None | ||
| enable_trace_context_propagation: bool = True | ||
| use_legacy_attributes = True | ||
| event_logger: Optional[Logger] = None | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run synchronous uploaders outside the event-loop thread.
If a synchronous uploader performs network I/O, this call blocks the event loop until the upload finishes.
achat_wrapperawaits request handling before it starts the OpenAI request, so concurrent async requests on that loop also stall. Run synchronous callbacks in a worker thread, then await the result if the callback returns an awaitable. (raw.githubusercontent.com)