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: Fix dep check for nested packages (#2492)
Myles Scolnick1e8e2b04fb91
diff --git a/docs/api/inputs/chat.md b/docs/api/inputs/chat.mdindex 746e30347c..203019d8c6 100644--- a/docs/api/inputs/chat.md+++ b/docs/api/inputs/chat.md@@ -145,7 +145,7 @@ import marimo as momo.ui.chat(mo.ai.llm.anthropic(- "claude-3-5-sonnet-20240602",+ "claude-3-5-sonnet-20240620",system_message="You are a helpful assistant.",api_key="sk-ant-...",),@@ -179,7 +179,7 @@ mo.ui.chat(Chatbots can be implemented with a function that receives a list of[`ChatMessage`](#marimo.ai.ChatMessage) objects and a-[`ChatModelConfig`](#marimo.ai.ChatModelConfig).+[`ChatModelConfig`](#marimo.ai.ChatModelConfig).```{eval-rst}.. autoclass:: marimo.ai.ChatMessagediff --git a/examples/ai/chat/README.md b/examples/ai/chat/README.mdindex 518f3706f9..a40afe28fe 100644--- a/examples/ai/chat/README.md+++ b/examples/ai/chat/README.md@@ -3,9 +3,9 @@These examples show how to make chatbots with marimo, using [`mo.ui.chat`](https://docs.marimo.io/api/inputs/chat.html#marimo.ui.chat).- `custom.py` shows how to make a custom chatbot-- `openai.py` shows how to make a chatbot powered by OpenAI models-- `anthropic.py` shows how to make a chatbot powered by Anthropic models-- `google.py` shows how to make a chatbot powered by Google models like Gemini+- `openai_example.py` shows how to make a chatbot powered by OpenAI models+- `anthropic_example.py` shows how to make a chatbot powered by Anthropic models+- `gemini.py` shows how to make a chatbot powered by Google models like GeminiChatbot's in marimo are _reactive_: when the chatbot responds with a message,all other cells referencing the chatbot are automatically run or markeddiff --git a/examples/ai/chat/anthropic.py b/examples/ai/chat/anthropic_example.pysimilarity index 95%rename from examples/ai/chat/anthropic.pyrename to examples/ai/chat/anthropic_example.pyindex 8d73258bc3..3e9f056295 100644--- a/examples/ai/chat/anthropic.py+++ b/examples/ai/chat/anthropic_example.py@@ -7,7 +7,7 @@import marimo-__generated_with = "0.8.22"+__generated_with = "0.9.0"app = marimo.App(width="medium")@@ -54,7 +54,7 @@ def __(input_key, mo, os_key):def __(key, mo):chatbot = mo.ui.chat(mo.ai.llm.anthropic(- "claude-3-5-sonnet-20240602",+ "claude-3-5-sonnet-20240620",system_message="You are a helpful assistant.",api_key=key,),diff --git a/examples/ai/chat/openai.py b/examples/ai/chat/openai_example.pysimilarity index 100%rename from examples/ai/chat/openai.pyrename to examples/ai/chat/openai_example.pydiff --git a/marimo/_dependencies/dependencies.py b/marimo/_dependencies/dependencies.pyindex 982ca09015..9102939caf 100644--- a/marimo/_dependencies/dependencies.py+++ b/marimo/_dependencies/dependencies.py@@ -18,9 +18,13 @@ class Dependency:def has(self) -> bool:"""Return True if the dependency is installed."""- for pkg in self.pkg.split("."):- if importlib.util.find_spec(pkg) is None:+ try:+ has_dep = importlib.util.find_spec(self.pkg) is not None+ if not has_dep:return False+ except ModuleNotFoundError:+ # Could happen for nested imports (e.g. foo.bar)+ return Falseif self.min_version or self.max_version:self.warn_if_mismatch_version(self.min_version, self.max_version)@@ -51,8 +55,7 @@ class Dependency:"""if not self.has():raise ModuleNotFoundError(- f"{self.pkg} is required {why}. "- + f"You can install it with 'pip install {self.pkg}'."+ f"{self.pkg} is required {why}.") from Nonedef require_at_version(