fireworks[patch]: fix api_key alias in Fireworks LLM (#23118)

Thank you for contributing to LangChain!

**Description**
The current code snippet for `Fireworks` had incorrect parameters. This
PR fixes those parameters.

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
shaunakgodbole 2024-06-19 14:14:42 -07:00 committed by GitHub
parent 1fcf875fe3
commit 7193634ae6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -90,7 +90,7 @@ class Fireworks(LLM):
) )
return values return values
@root_validator(pre=True) @root_validator(pre=False, skip_on_failure=True)
def validate_environment(cls, values: Dict) -> Dict: def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key exists in environment.""" """Validate that api key exists in environment."""
values["fireworks_api_key"] = convert_to_secret_str( values["fireworks_api_key"] = convert_to_secret_str(

View File

@ -18,6 +18,15 @@ def test_fireworks_api_key_is_secret_string() -> None:
) )
assert isinstance(llm.fireworks_api_key, SecretStr) assert isinstance(llm.fireworks_api_key, SecretStr)
# Test api_key alias
llm = Fireworks(
api_key="secret-api-key",
model="accounts/fireworks/models/mixtral-8x7b-instruct",
temperature=0.2,
max_tokens=250,
)
assert isinstance(llm.fireworks_api_key, SecretStr)
def test_fireworks_api_key_masked_when_passed_from_env( def test_fireworks_api_key_masked_when_passed_from_env(
monkeypatch: MonkeyPatch, capsys: CaptureFixture monkeypatch: MonkeyPatch, capsys: CaptureFixture