Skip to content

Commit d0a08f7

Browse files
Add optional model document name field. When this field is provided, that is the document the library will connect to.
1 parent 509a0ef commit d0a08f7

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

validmind/api_client.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,15 @@ def get_api_model() -> Optional[str]:
6767

6868

6969
def _get_api_headers() -> Dict[str, str]:
70-
return {
70+
headers = {
7171
"X-API-KEY": _api_key,
7272
"X-API-SECRET": _api_secret,
7373
"X-MODEL-CUID": _model_cuid,
7474
"X-MONITORING": str(_monitoring),
7575
}
76+
if _model_document:
77+
headers["X-DOCUMENT-TYPE"] = _model_document
78+
return headers
7679

7780

7881
def _get_session() -> aiohttp.ClientSession:
@@ -194,6 +197,7 @@ def init(
194197
model: Optional[str] = None,
195198
monitoring: bool = False,
196199
generate_descriptions: Optional[bool] = None,
200+
model_document: Optional[str] = None,
197201
):
198202
"""
199203
Initializes the API client instances and calls the /ping endpoint to ensure
@@ -209,11 +213,12 @@ def init(
209213
api_secret (str, optional): The API secret. Defaults to None.
210214
api_host (str, optional): The API host. Defaults to None.
211215
monitoring (bool): The ongoing monitoring flag. Defaults to False.
212-
generate_descriptions (bool): Whether to use GenAI to generate test result descriptions. Defaults to True.
216+
generate_descriptions (bool, optional): Whether to use GenAI to generate test result descriptions. Defaults to True.
217+
model_document (str, optional): The name of the document.
213218
Raises:
214219
ValueError: If the API key and secret are not provided
215220
"""
216-
global _api_key, _api_secret, _api_host, _model_cuid, _monitoring
221+
global _api_key, _api_secret, _api_host, _model_cuid, _monitoring, _model_document
217222

218223
if api_key == "...":
219224
# special case to detect when running a notebook placeholder (...)
@@ -238,6 +243,7 @@ def init(
238243
if generate_descriptions is not None:
239244
os.environ["VALIDMIND_LLM_DESCRIPTIONS_ENABLED"] = str(generate_descriptions)
240245

246+
_model_document = model_document
241247
reload()
242248

243249

0 commit comments

Comments
 (0)