Skip to content

Commit d0983da

Browse files
pass sdk version number to api for debug (#146)
* pass sdk version number to api for debug * add exception catch * add missing import * fix lint * just make it null Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com> --------- Co-authored-by: Roaring <216452114+the-roaring@users.noreply.github.com>
1 parent 0732268 commit d0983da

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stagehand": patch
3+
---
4+
5+
Pass sdk version number to API for debugging

stagehand/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from datetime import datetime
3+
from importlib.metadata import PackageNotFoundError, version
34
from typing import Any
45

56
from .utils import convert_dict_keys_to_camel_case
@@ -63,13 +64,22 @@ async def _create_session(self):
6364
if hasattr(self, "model_client_options") and self.model_client_options:
6465
payload["modelClientOptions"] = self.model_client_options
6566

67+
def get_version(package_str):
68+
try:
69+
result = version(package_str)
70+
except PackageNotFoundError:
71+
self.logger.error(package_str + " not installed")
72+
result = None
73+
return result
74+
6675
headers = {
6776
"x-bb-api-key": self.browserbase_api_key,
6877
"x-bb-project-id": self.browserbase_project_id,
6978
"x-model-api-key": self.model_api_key,
7079
"Content-Type": "application/json",
7180
"x-sent-at": datetime.now().isoformat(),
7281
"x-language": "python",
82+
"x-sdk-version": get_version("stagehand"),
7383
}
7484

7585
# async with self._client:

0 commit comments

Comments
 (0)