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: non-requied model key (#2494)

Myles Scolnickf4fc33b623b8
diff --git a/frontend/src/components/editor/chrome/wrapper/copilot-status.tsx b/frontend/src/components/editor/chrome/wrapper/copilot-status.tsx
index adad1b0111..b3f7ff5839 100644
--- a/frontend/src/components/editor/chrome/wrapper/copilot-status.tsx
+++ b/frontend/src/components/editor/chrome/wrapper/copilot-status.tsx
@@ -17,7 +17,7 @@ import { settingDialogAtom } from "@/components/app-config/app-config-button";
export const AIStatusIcon: React.FC = () => {
const ai = useAtomValue(aiAtom);
const aiEnabled = useAtomValue(aiEnabledAtom);
- const model = ai.open_ai.model || "gpt-4-turbo";
+ const model = ai?.open_ai?.model || "gpt-4-turbo";
const { handleClick } = useOpenAISettings();
if (!aiEnabled) {
diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts
index ca9248a8c2..840a706855 100644
--- a/frontend/src/core/config/config-schema.ts
+++ b/frontend/src/core/config/config-schema.ts
@@ -134,6 +134,9 @@ export const UserConfigSchema = z
display: {},
experimental: {},
server: {},
+ ai: {
+ open_ai: {},
+ },
});
export type UserConfig = MarimoConfig;
export type SaveConfig = UserConfig["save"];
diff --git a/frontend/src/core/config/config.ts b/frontend/src/core/config/config.ts
index ebbb373753..00cbccd6f4 100644
--- a/frontend/src/core/config/config.ts
+++ b/frontend/src/core/config/config.ts
@@ -44,9 +44,9 @@ export const aiEnabledAtom = atom<boolean>((get) => {
export function isAiEnabled(config: UserConfig) {
return (
- Boolean(config.ai.open_ai?.api_key) ||
- Boolean(config.ai.anthropic?.api_key) ||
- Boolean(config.ai.google?.api_key)
+ Boolean(config.ai?.open_ai?.api_key) ||
+ Boolean(config.ai?.anthropic?.api_key) ||
+ Boolean(config.ai?.google?.api_key)
);
}