-
Notifications
You must be signed in to change notification settings - Fork 262
feat(client): allow passing async httpx client #1557
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 2 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 |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ def __new__( | |
| flush_at: Optional[int] = None, | ||
| flush_interval: Optional[float] = None, | ||
| httpx_client: Optional[httpx.Client] = None, | ||
| async_httpx_client: Optional[httpx.AsyncClient] = None, | ||
| media_upload_thread_count: Optional[int] = None, | ||
| sample_rate: Optional[float] = None, | ||
| mask: Optional[MaskFunction] = None, | ||
|
|
@@ -123,6 +124,7 @@ def __new__( | |
| flush_at=flush_at, | ||
| flush_interval=flush_interval, | ||
| httpx_client=httpx_client, | ||
| async_httpx_client=async_httpx_client, | ||
| media_upload_thread_count=media_upload_thread_count, | ||
| sample_rate=sample_rate, | ||
| mask=mask, | ||
|
|
@@ -152,6 +154,7 @@ def _initialize_instance( | |
| flush_interval: Optional[float] = None, | ||
| media_upload_thread_count: Optional[int] = None, | ||
| httpx_client: Optional[httpx.Client] = None, | ||
| async_httpx_client: Optional[httpx.AsyncClient] = None, | ||
| sample_rate: Optional[float] = None, | ||
| mask: Optional[MaskFunction] = None, | ||
| tracing_enabled: bool = True, | ||
|
|
@@ -218,6 +221,15 @@ def _initialize_instance( | |
| client_headers = additional_headers if additional_headers else {} | ||
| self.httpx_client = httpx.Client(timeout=timeout, headers=client_headers) | ||
|
|
||
| if async_httpx_client is not None: | ||
| self.async_httpx_client = async_httpx_client | ||
| else: | ||
| async_client_headers = additional_headers if additional_headers else {} | ||
| self.async_httpx_client = httpx.AsyncClient( | ||
| timeout=timeout, | ||
| headers=async_client_headers, | ||
| ) | ||
|
|
||
| self.api = LangfuseAPI( | ||
| base_url=base_url, | ||
| username=self.public_key, | ||
|
|
@@ -235,6 +247,7 @@ def _initialize_instance( | |
| x_langfuse_sdk_name="python", | ||
| x_langfuse_sdk_version=langfuse_version, | ||
| x_langfuse_public_key=self.public_key, | ||
| httpx_client=self.async_httpx_client, | ||
| timeout=timeout, | ||
|
Comment on lines
+250
to
251
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.
When a caller provides Useful? React with 👍 / 👎. |
||
| ) | ||
| score_ingestion_client = LangfuseClient( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.