Adding initial support for LLM Customisation#132
Merged
miguelg719 merged 5 commits intobrowserbase:contrib/132from Aug 19, 2025
Merged
Adding initial support for LLM Customisation#132miguelg719 merged 5 commits intobrowserbase:contrib/132from
miguelg719 merged 5 commits intobrowserbase:contrib/132from
Conversation
miguelg719
previously approved these changes
Jul 3, 2025
miguelg719
requested changes
Jul 3, 2025
Collaborator
miguelg719
left a comment
There was a problem hiding this comment.
let's address the comments, I made a branch contrib/132 that you can set as the target to merge to (to run full CI)
miguelg719
reviewed
Jul 10, 2025
Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com>
miguelg719
approved these changes
Jul 15, 2025
Comment on lines
-92
to
-96
| # Handle model-related settings | ||
| self.model_client_options = {} | ||
| if self.model_api_key and "apiKey" not in self.model_client_options: | ||
| self.model_client_options["apiKey"] = self.model_api_key | ||
|
|
|
LGTM |
miguelg719
reviewed
Aug 19, 2025
miguelg719
added a commit
that referenced
this pull request
Aug 19, 2025
* Adding initial support for LLM Customisation (#132) * Adding support for LLM Customisation * Added back model_api_key config * Fixed README * Update README.md Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com> * Update stagehand/llm/client.py --------- Co-authored-by: Miguel <36487034+miguelg719@users.noreply.github.com> * Update stagehand/config.py * minor updates * Apply suggestions from code review * changeset * accept apiKey in model_client_options * passthrough apiKey if none in model_api_key --------- Co-authored-by: Sanveer Singh Osahan <sanveer.singh@atlan.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for custom language models (LLMs) by replacing the
model_api_keyparameter with a more flexiblemodel_client_optionsparameter. It also updates the documentation, configuration, initialization logic, and tests to reflect this enhancement.Core Changes for Custom LLM Support:
Configuration Updates:
model_api_keywithmodel_client_optionsin theStagehandConfigclass, allowing users to specify multiple options such asapiKeyandbaseUrlfor custom LLMs. (stagehand/config.py, [1] [2]Initialization Logic:
stagehand/main.pyto handlemodel_client_optionsand extractapiKeyfrom it, falling back to theMODEL_API_KEYenvironment variable if necessary. (stagehand/main.py, stagehand/main.pyL71-R74)model_client_optionsdynamically. (stagehand/main.py, stagehand/main.pyL92-L96)LLM Client Enhancements:
stagehand/llm/client.pyto supportbaseURLin addition toapi_basefor custom LLM configurations. (stagehand/llm/client.py, stagehand/llm/client.pyL57-R57)Documentation Updates:
StagehandConfigwithmodel_client_optionsfor a custom LLM. (README.md, README.mdR163-R178)Test Coverage:
model_api_keywithmodel_client_options. (tests/unit/llm/test_llm_integration.py, [1];tests/unit/test_client_api.py, [2];tests/unit/test_client_initialization.py, [3]tests/unit/test_client_initialization.py, tests/unit/test_client_initialization.pyR206-R234)