Add the BQ job usage tracking from LangChain (#17123)

- **Description:**
Add the BQ job usage tracking from LangChain

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Ashley Xu
2024-02-13 14:47:57 -08:00
committed by GitHub
parent 5dca107621
commit f746a73e26
2 changed files with 31 additions and 2 deletions

View File

@@ -0,0 +1,25 @@
"""Utilities to use Google provided components."""
from importlib import metadata
from typing import Any, Optional
def get_client_info(module: Optional[str] = None) -> Any:
r"""Returns a custom user agent header.
Args:
module (Optional[str]):
Optional. The module for a custom user agent header.
Returns:
google.api_core.gapic_v1.client_info.ClientInfo
"""
from google.api_core.gapic_v1.client_info import ClientInfo
langchain_version = metadata.version("langchain")
client_library_version = (
f"{langchain_version}-{module}" if module else langchain_version
)
return ClientInfo(
client_library_version=client_library_version,
user_agent=f"langchain/{client_library_version}",
)