File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727)
2828from ._utils import (
2929 is_given ,
30+ is_mapping_t ,
3031 maybe_transform ,
3132 get_async_library ,
3233 async_maybe_transform ,
@@ -114,6 +115,15 @@ def __init__(
114115 if base_url is None :
115116 base_url = f"https://api.supermemory.ai"
116117
118+ custom_headers_env = os .environ .get ("SUPERMEMORY_CUSTOM_HEADERS" )
119+ if custom_headers_env is not None :
120+ parsed : dict [str , str ] = {}
121+ for line in custom_headers_env .split ("\n " ):
122+ colon = line .find (":" )
123+ if colon >= 0 :
124+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
125+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
126+
117127 super ().__init__ (
118128 version = __version__ ,
119129 base_url = base_url ,
@@ -440,6 +450,15 @@ def __init__(
440450 if base_url is None :
441451 base_url = f"https://api.supermemory.ai"
442452
453+ custom_headers_env = os .environ .get ("SUPERMEMORY_CUSTOM_HEADERS" )
454+ if custom_headers_env is not None :
455+ parsed : dict [str , str ] = {}
456+ for line in custom_headers_env .split ("\n " ):
457+ colon = line .find (":" )
458+ if colon >= 0 :
459+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
460+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
461+
443462 super ().__init__ (
444463 version = __version__ ,
445464 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments