mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-30 12:39:27 +08:00
fix(aimlapi): send attribution headers on every aimlapi.com request (#17491)
### Summary The **aimlapi.com** provider added in #17311 does not identify itself on any of its outgoing requests, so its traffic cannot be attributed to the integration. This PR adds the two headers AIMLAPI expects — `X-AIMLAPI-Source` and `X-AIMLAPI-Partner-ID` — to every request the provider makes.
This commit is contained in:
32
test/unit_test/common/test_aimlapi_utils.py
Normal file
32
test/unit_test/common/test_aimlapi_utils.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from common.aimlapi_utils import DEFAULT_PARTNER_ID, DEFAULT_SOURCE, attribution_headers, partner_id, source
|
||||
|
||||
|
||||
def test_defaults(monkeypatch):
|
||||
monkeypatch.delenv("AIMLAPI_SOURCE", raising=False)
|
||||
monkeypatch.delenv("AIMLAPI_PARTNER_ID", raising=False)
|
||||
|
||||
assert source() == DEFAULT_SOURCE
|
||||
assert attribution_headers() == {
|
||||
"X-AIMLAPI-Source": DEFAULT_SOURCE,
|
||||
"X-AIMLAPI-Partner-ID": DEFAULT_PARTNER_ID,
|
||||
}
|
||||
|
||||
|
||||
def test_environment_overrides(monkeypatch):
|
||||
monkeypatch.setenv("AIMLAPI_SOURCE", " agent/custom ")
|
||||
monkeypatch.setenv("AIMLAPI_PARTNER_ID", " part_custom ")
|
||||
|
||||
assert source() == "agent/custom"
|
||||
assert partner_id() == "part_custom"
|
||||
assert attribution_headers() == {
|
||||
"X-AIMLAPI-Source": "agent/custom",
|
||||
"X-AIMLAPI-Partner-ID": "part_custom",
|
||||
}
|
||||
|
||||
|
||||
def test_blank_partner_id_is_omitted(monkeypatch):
|
||||
monkeypatch.delenv("AIMLAPI_SOURCE", raising=False)
|
||||
monkeypatch.setenv("AIMLAPI_PARTNER_ID", " ")
|
||||
|
||||
headers = attribution_headers()
|
||||
assert headers == {"X-AIMLAPI-Source": DEFAULT_SOURCE}
|
||||
Reference in New Issue
Block a user