File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 RequestOptions ,
2121 not_given ,
2222)
23- from ._utils import is_given , get_async_library
23+ from ._utils import (
24+ is_given ,
25+ is_mapping_t ,
26+ get_async_library ,
27+ )
2428from ._compat import cached_property
2529from ._version import __version__
2630from ._streaming import Stream as Stream , AsyncStream as AsyncStream
@@ -96,6 +100,15 @@ def __init__(
96100 if base_url is None :
97101 base_url = f"https://api.mobilerun.ai/v1"
98102
103+ custom_headers_env = os .environ .get ("MOBILERUN_CUSTOM_HEADERS" )
104+ if custom_headers_env is not None :
105+ parsed : dict [str , str ] = {}
106+ for line in custom_headers_env .split ("\n " ):
107+ colon = line .find (":" )
108+ if colon >= 0 :
109+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
110+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
111+
99112 super ().__init__ (
100113 version = __version__ ,
101114 base_url = base_url ,
@@ -334,6 +347,15 @@ def __init__(
334347 if base_url is None :
335348 base_url = f"https://api.mobilerun.ai/v1"
336349
350+ custom_headers_env = os .environ .get ("MOBILERUN_CUSTOM_HEADERS" )
351+ if custom_headers_env is not None :
352+ parsed : dict [str , str ] = {}
353+ for line in custom_headers_env .split ("\n " ):
354+ colon = line .find (":" )
355+ if colon >= 0 :
356+ parsed [line [:colon ].strip ()] = line [colon + 1 :].strip ()
357+ default_headers = {** parsed , ** (default_headers if is_mapping_t (default_headers ) else {})}
358+
337359 super ().__init__ (
338360 version = __version__ ,
339361 base_url = base_url ,
You can’t perform that action at this time.
0 commit comments