Skip to content

Added 'max_completion_tokens' params in ChatWatsonx #96

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion libs/ibm/langchain_ibm/chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ class ChatWatsonx(BaseChatModel):
from ibm_watsonx_ai.foundation_models.schema import TextChatParameters

parameters = TextChatParameters(
max_tokens=100,
max_completion_tokens=100,
temperature=0.5,
top_p=1,
)
Expand Down Expand Up @@ -513,6 +513,12 @@ class ChatWatsonx(BaseChatModel):
max_tokens: Optional[int] = None
"""The maximum number of tokens that can be generated in the chat completion.
The total length of input tokens and generated tokens is limited by the
model's context length.
This value is now deprecated in favor of 'max_completion_tokens' parameter."""

max_completion_tokens: Optional[int] = None
"""The maximum number of tokens that can be generated in the chat completion.
The total length of input tokens and generated tokens is limited by the
model's context length."""

n: Optional[int] = None
Expand Down Expand Up @@ -1018,6 +1024,7 @@ def _get_supported_chat_params() -> list[str]:
"logprobs",
"top_logprobs",
"max_tokens",
"max_completion_tokens",
"n",
"presence_penalty",
"response_format",
Expand Down
2 changes: 1 addition & 1 deletion libs/ibm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ license = "MIT"
[tool.poetry.dependencies]
python = ">=3.10,<3.14"
langchain-core = "^0.3.39"
ibm-watsonx-ai = "^1.3.28"
ibm-watsonx-ai = "^1.3.33"

[tool.poetry.group.test]
optional = true
Expand Down
Loading