Skip to content

Commit deeaaa5

Browse files
committed
feat(frontend#oso): populate initial marimo client config
1 parent dbfd001 commit deeaaa5

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

frontend/src/oso-extensions/wrapper.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { useCallback, useEffect, type PropsWithChildren } from "react";
33
import { useCellActions } from "@/core/cells/cells";
44
import { PyodideBridge } from "@/core/wasm/bridge";
55
import { useFragmentStore } from "./fragment-store";
6+
import { userConfigAtom } from "@/core/config/config";
7+
import { store } from "@/core/state/jotai";
68

79
const COMMAND_PREFIX = "oso_commands:";
810

@@ -73,6 +75,28 @@ export const OSOWrapper: React.FC<PropsWithChildren> = ({ children }) => {
7375
functionName: "__oso_initialize_env",
7476
namespace: "marimo.oso"
7577
});
78+
79+
const osoApiKey = envVars["OSO_API_KEY"];
80+
if (osoApiKey) {
81+
store.set(userConfigAtom, (prev) => ({
82+
...prev,
83+
ai: {
84+
...prev.ai,
85+
open_ai_compatible: {
86+
...prev.ai?.open_ai_compatible,
87+
api_key: osoApiKey,
88+
base_url: envVars["OSO_AI_API_BASE_URL"] || "https://opensource.observer/api/v1",
89+
},
90+
models: {
91+
...prev.ai?.models,
92+
chat_model: envVars["OSO_AI_MODEL"] || "oso/semantic",
93+
edit_model: envVars["OSO_AI_MODEL"] || "oso/semantic",
94+
custom_models: prev.ai?.models?.custom_models || [],
95+
displayed_models: prev.ai?.models?.displayed_models || [],
96+
},
97+
},
98+
}));
99+
}
76100
}
77101

78102
// Enable debug logging in pyodide. This could get crazy

0 commit comments

Comments
 (0)