diff --git a/.changeset/belligerent-gharial-of-attack.md b/.changeset/belligerent-gharial-of-attack.md new file mode 100644 index 00000000..f7393d44 --- /dev/null +++ b/.changeset/belligerent-gharial-of-attack.md @@ -0,0 +1,5 @@ +--- +"stagehand": patch +--- + +Pass sdk version number to API for debugging diff --git a/stagehand/api.py b/stagehand/api.py index 28eb2161..6639df29 100644 --- a/stagehand/api.py +++ b/stagehand/api.py @@ -1,5 +1,6 @@ import json from datetime import datetime +from importlib.metadata import PackageNotFoundError, version from typing import Any from .utils import convert_dict_keys_to_camel_case @@ -63,6 +64,14 @@ async def _create_session(self): if hasattr(self, "model_client_options") and self.model_client_options: payload["modelClientOptions"] = self.model_client_options + def get_version(package_str): + try: + result = version(package_str) + except PackageNotFoundError: + self.logger.error(package_str + " not installed") + result = None + return result + headers = { "x-bb-api-key": self.browserbase_api_key, "x-bb-project-id": self.browserbase_project_id, @@ -70,6 +79,7 @@ async def _create_session(self): "Content-Type": "application/json", "x-sent-at": datetime.now().isoformat(), "x-language": "python", + "x-sdk-version": get_version("stagehand"), } # async with self._client: