Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 9 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 version, PackageNotFoundError
from typing import Any

from .utils import convert_dict_keys_to_camel_case
Expand Down Expand Up @@ -63,13 +64,21 @@ 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:
result = package_str + " not installed"
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
Loading