Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/belligerent-gharial-of-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stagehand": patch
---

Pass sdk version number to API for debugging
10 changes: 10 additions & 0 deletions stagehand/api.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -63,13 +64,22 @@ 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,
"x-model-api-key": self.model_api_key,
"Content-Type": "application/json",
"x-sent-at": datetime.now().isoformat(),
"x-language": "python",
"x-sdk-version": get_version("stagehand"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@the-roaring should I have a more null safe check here?

}

# async with self._client:
Expand Down