Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

premai[patch]: Standardize premai params #21513

Merged
merged 10 commits into from
Aug 29, 2024
15 changes: 12 additions & 3 deletions libs/community/langchain_community/chat_models/premai.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,22 @@ class ChatPremAI(BaseChatModel, BaseModel):
If model name is other than default model then it will override the calls
from the model deployed from launchpad."""

temperature: Optional[float] = None
session_id: Optional[str] = None
"""The ID of the session to use. It helps to track the chat history."""

temperature: Optional[float] = Field(default=None)
"""Model temperature. Value should be >= 0 and <= 1.0"""

max_tokens: Optional[int] = None
top_p: Optional[float] = None
"""top_p adjusts the number of choices for each predicted tokens based on
cumulative probabilities. Value should be ranging between 0.0 and 1.0.
"""

max_tokens: Optional[int] = Field(default=None)

"""The maximum number of tokens to generate"""

max_retries: int = 1
max_retries: int = Field(default=1)
"""Max number of retries to call the API"""

system_prompt: Optional[str] = ""
Expand Down
3 changes: 3 additions & 0 deletions libs/community/tests/unit_tests/chat_models/test_premai.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ def test_premai_initialization() -> None:
ChatPremAI(model_name="prem-ai-model", api_key="xyz", project_id=8), # type: ignore[arg-type, call-arg]
]:
assert model.model == "prem-ai-model"
assert model.temperature is None
assert model.max_tokens is None
assert model.max_retries == 1
assert cast(SecretStr, model.premai_api_key).get_secret_value() == "xyz"
Loading