A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: use max_completion_tokens instead of max_tokens (#4328)
Myles Scolnickd45bbc895a71
diff --git a/examples/third_party/huggingface/chatbot.py b/examples/third_party/huggingface/chatbot.pyindex c57c0fadfe..3df0d3ba4b 100644--- a/examples/third_party/huggingface/chatbot.py+++ b/examples/third_party/huggingface/chatbot.py@@ -137,7 +137,7 @@ def __(client, mo):response = client.chat_completion(chat_messages,- max_tokens=max_tokens.value,+ max_completion_tokens=max_tokens.value,temperature=temperature.value,top_p=top_p.value,stream=False,diff --git a/marimo/_ai/llm/_impl.py b/marimo/_ai/llm/_impl.pyindex 1f26a4512b..b7a51dd337 100644--- a/marimo/_ai/llm/_impl.py+++ b/marimo/_ai/llm/_impl.py@@ -143,7 +143,7 @@ class openai(ChatModel):response = client.chat.completions.create(model=self.model,messages=cast(list[ChatCompletionMessageParam], openai_messages),- max_tokens=config.max_tokens,+ max_completion_tokens=config.max_tokens,temperature=config.temperature,top_p=config.top_p,frequency_penalty=config.frequency_penalty,diff --git a/marimo/_server/ai/providers.py b/marimo/_server/ai/providers.pyindex 228bee134f..091992f817 100644--- a/marimo/_server/ai/providers.py+++ b/marimo/_server/ai/providers.py@@ -356,7 +356,7 @@ class OpenAIProvider(+ messages),),- max_tokens=max_tokens,+ max_completion_tokens=max_tokens,stream=True,timeout=15,)diff --git a/tests/_ai/llm/test_impl.py b/tests/_ai/llm/test_impl.pyindex 360eb8d01f..4061c2fcfd 100644--- a/tests/_ai/llm/test_impl.py+++ b/tests/_ai/llm/test_impl.py@@ -260,7 +260,7 @@ class TestOpenAI:assert call_args["messages"][0]["content"] == DEFAULT_SYSTEM_MESSAGEassert call_args["messages"][1]["role"] == "user"assert call_args["messages"][1]["content"] == "Test prompt"- assert call_args["max_tokens"] == 100+ assert call_args["max_completion_tokens"] == 100# Use pytest.approx for floating point comparisonsassert call_args["temperature"] == pytest.approx(0.7)assert call_args["top_p"] == pytest.approx(0.9)