community[patch]: update apify integration to attribute API activity to langchain (#21909)

**Description:** Add `Origin/langchain` to Apify's client's user-agent
to attribute API activity to LangChain (at Apify, we aim to monitor our
integrations to evaluate whether we should invest more in the LangChain
integration regarding functionality and content)

**Issue:** None
**Dependencies:** None
**Twitter handle:** None
This commit is contained in:
Jiří Spilka
2024-05-20 23:49:23 +02:00
committed by GitHub
parent 711b8f1e52
commit 6499897c87
3 changed files with 18 additions and 4 deletions

View File

@@ -60,7 +60,11 @@ class ApifyDatasetLoader(BaseLoader, BaseModel):
try:
from apify_client import ApifyClient
values["apify_client"] = ApifyClient()
client = ApifyClient()
if httpx_client := getattr(client.http_client, "httpx_client"):
httpx_client.headers["user-agent"] += "; Origin/langchain"
values["apify_client"] = client
except ImportError:
raise ImportError(
"Could not import apify-client Python package. "