Skip to content

Commit 2bf3eba

Browse files
authored
Merge pull request #23 from Zipstack/fix/custom-header-support
header updated
2 parents 519f76a + 33cb154 commit 2bf3eba

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/unstract/llmwhisperer/client_v2.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from typing import IO
2626

2727
import requests
28+
from typing import Optional, Dict
2829

2930
BASE_URL_V2 = "https://llmwhisperer-api.us-central.unstract.com/api/v2"
3031

@@ -76,6 +77,7 @@ def __init__(
7677
base_url: str = "",
7778
api_key: str = "",
7879
logging_level: str = "",
80+
custom_headers: Optional[Dict[str, str]] = None,
7981
):
8082
"""Initializes the LLMWhispererClient with the given parameters.
8183
@@ -92,6 +94,12 @@ def __init__(
9294
value of the LLMWHISPERER_LOGGING_LEVEL
9395
environment variable, or "DEBUG" if the
9496
environment variable is not set.
97+
custom_headers (Optional[Dict[str, str]], optional): Custom headers to add to
98+
every request. These will
99+
be merged with default
100+
headers, with custom
101+
headers taking precedence.
102+
Defaults to None.
95103
"""
96104
if logging_level == "":
97105
logging_level = os.getenv("LLMWHISPERER_LOGGING_LEVEL", "DEBUG")
@@ -117,6 +125,8 @@ def __init__(
117125
self.api_key = api_key
118126

119127
self.headers = {"unstract-key": self.api_key}
128+
if custom_headers:
129+
self.headers.update(custom_headers)
120130
# For test purpose
121131
# self.headers = {
122132
# "Subscription-Id": "python-client",

tests/integration/client_v2_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_whisper_v2_url_in_post(client_v2, data_dir, output_mode, mode, url, inp
174174
"url,token,webhook_name",
175175
[
176176
(
177-
"https://webhook.site/b76ecc5f-8320-4410-b24f-66525d2c92cb",
177+
"https://webhook.site/62bb38ac-408c-4fcf-b8f1-cb22adbf3f96", # need to find a clean solution
178178
"",
179179
"client_v2_test",
180180
),

0 commit comments

Comments
 (0)