Skip to content

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.

fix(ai): allow DeepSeek custom provider configuration (#9969)

Shahmir Varqha5d24a895648a
diff --git a/frontend/src/components/app-config/ai-config.tsx b/frontend/src/components/app-config/ai-config.tsx
index 4a5e7415dc..d374ca9b65 100644
--- a/frontend/src/components/app-config/ai-config.tsx
+++ b/frontend/src/components/app-config/ai-config.tsx
@@ -103,6 +103,11 @@ interface CustomProviderConfig {
base_url?: string;
}
+const SUPPORTED_PROVIDERS_UI = new Set(KNOWN_PROVIDERS);
+// We use deepseek as an example of a custom provider in our docs, so we don't show it in the UI.
+// Else, we would need to wire up the UI and config for it. Consider if many users request.
+SUPPORTED_PROVIDERS_UI.delete("deepseek");
+
export const AiProviderTitle: React.FC<AiProviderTitleProps> = ({
provider,
children,
@@ -622,7 +627,7 @@ export const CustomProvidersConfig: React.FC<AiConfigProps> = ({
const normalizedName = newProviderName.toLowerCase().replaceAll(/\s+/g, "_");
const customProviders = form.watch("ai.custom_providers");
const isDuplicate =
- KNOWN_PROVIDERS.includes(normalizedName as KnownProviderId) ||
+ SUPPORTED_PROVIDERS_UI.has(normalizedName as KnownProviderId) ||
(customProviders && Object.keys(customProviders).includes(normalizedName));
const hasInvalidChars = normalizedName.includes(".");
diff --git a/marimo/_tracer.py b/marimo/_tracer.py
index 7f813be96a..3168915dce 100644
--- a/marimo/_tracer.py
+++ b/marimo/_tracer.py
@@ -250,7 +250,9 @@ def _instrument_ai(provider: trace.TracerProvider) -> None:
from pydantic_ai import Agent
from pydantic_ai.models.instrumented import InstrumentationSettings
- Agent.instrument_all(InstrumentationSettings(tracer_provider=provider))
+ Agent.instrument_all(
+ InstrumentationSettings(tracer_provider=provider, version=5)
+ )
LOGGER.debug("Enabled AI instrumentation")
except Exception as e:
LOGGER.debug("AI instrumentation failed: %s", e)
diff --git a/tests/test_tracer.py b/tests/test_tracer.py
index de3ef2ef82..d6af9f799c 100644
--- a/tests/test_tracer.py
+++ b/tests/test_tracer.py
@@ -432,6 +432,7 @@ class TestInstrumentAI:
mock_instrument.assert_called_once()
settings = mock_instrument.call_args.args[0]
assert isinstance(settings, InstrumentationSettings)
+ assert settings.version == 5
# InstrumentationSettings builds its tracer from the provider rather
# than storing the provider itself, so assert the provider was used.
assert settings.tracer is provider.get_tracer.return_value