Adding initial support for LLM Customisation #132
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_key
parameter with a more flexiblemodel_client_options
parameter. It also updates the documentation, configuration, initialization logic, and tests to reflect this enhancement.Core Changes for Custom LLM Support:
Configuration Updates:
model_api_key
withmodel_client_options
in theStagehandConfig
class, allowing users to specify multiple options such asapiKey
andbaseUrl
for custom LLMs. (stagehand/config.py
, [1] [2]Initialization Logic:
stagehand/main.py
to handlemodel_client_options
and extractapiKey
from it, falling back to theMODEL_API_KEY
environment variable if necessary. (stagehand/main.py
, stagehand/main.pyL71-R74)model_client_options
dynamically. (stagehand/main.py
, stagehand/main.pyL92-L96)LLM Client Enhancements:
stagehand/llm/client.py
to supportbaseURL
in addition toapi_base
for custom LLM configurations. (stagehand/llm/client.py
, stagehand/llm/client.pyL57-R57)Documentation Updates:
StagehandConfig
withmodel_client_options
for a custom LLM. (README.md
, README.mdR163-R178)Test Coverage:
model_api_key
withmodel_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)