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.

feat: codium copilot (#1700)

Myles Scolnick7dddc7099192
diff --git a/docs/guides/ai_completion.md b/docs/guides/ai_completion.md
index 2c4dddc8b8..1d831c88b8 100644
--- a/docs/guides/ai_completion.md
+++ b/docs/guides/ai_completion.md
@@ -19,6 +19,28 @@ _Get started with Copilot_:
_Note_: Copilot is not yet available in our conda distribution; please install
marimo using `pip` if you need Copilot.
+## Codeium Copilot
+
+1. Go to the Codeium website and sign up for an account: <https://codeium.com/>
+2. Install the browser extension: <https://codeium.com/chrome_tutorial>
+3. Open the settings for the chrome extension and click on "Get Token"
+
+<img src="https://github.com/Exafunction/codeium.jupyter/raw/main/img/1-extension-token.png">
+
+4. Right click on the extension window and select "Inspect" to open the dev tools for the extension. Then click on "Network"
+5. Copy the token and paste it the input area, and then press "Enter Token"
+6. This should log a new API request in the network tab. Click on "Preview" to get the API key.
+
+<img src="https://github.com/Exafunction/codeium.jupyter/raw/main/img/2-api-key.png">
+
+7. Paste the API key in the marimo settings in the UI, or add it to your `~/.marimo.toml`:
+
+```toml
+[completion]
+copilot = "codeium"
+codeium_api_key = ""
+```
+
## Using AI to modify cells
This feature is currently experimental and is not enabled by default. To enable it:
diff --git a/frontend/package.json b/frontend/package.json
index ca790e27d6..9f2b40b328 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -76,6 +76,7 @@
"@uidotdev/usehooks": "^2.4.1",
"@uiw/codemirror-extensions-langs": "^4.22.1",
"@uiw/react-codemirror": "^4.22.1",
+ "@valtown/codemirror-codeium": "^1.0.1",
"ai": "^3.1.23",
"ansi_up": "^6.0.2",
"blob-polyfill": "^7.0.20220408",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index df5098cf00..14313a5e2b 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -194,6 +194,9 @@ dependencies:
'@uiw/react-codemirror':
specifier: ^4.22.1
+ '@valtown/codemirror-codeium':
+ specifier: ^1.0.1
+ version: 1.0.1(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])
ai:
specifier: ^3.1.23
@@ -1919,6 +1922,10 @@ packages:
resolution: {integrity: sha512-s3jaWicZd0pkP0jf5ysyHUI/RE7MHos6qlToFcGWXVp+ykHOy77OUMrfbgJ9it2C5bow7OIQwYYaHjk9XlBQ2A==}
dev: false
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==}
+ dev: false
+
resolution: {integrity: sha512-YstAqNb0MCN8PjdLCDfRsBcGVRN41f3vgLvaI0IrIcBp4AqILRSS0DeWNGkicC+f/zRIPJLc+9RURVSepwvfBw==}
hasBin: true
@@ -2271,6 +2278,24 @@ packages:
dev: true
optional: true
+ /@connectrpc/[email protected](@bufbuild/[email protected])(@connectrpc/[email protected]):
+ resolution: {integrity: sha512-13aO4psFbbm7rdOFGV0De2Za64DY/acMspgloDlcOKzLPPs0yZkhp1OOzAQeiAIr7BM/VOHIA3p8mF0inxCYTA==}
+ peerDependencies:
+ '@bufbuild/protobuf': ^1.4.2
+ '@connectrpc/connect': 1.4.0
+ dependencies:
+ '@bufbuild/protobuf': 1.10.0
+ '@connectrpc/connect': 1.4.0(@bufbuild/[email protected])
+ dev: false
+
+ /@connectrpc/[email protected](@bufbuild/[email protected]):
+ resolution: {integrity: sha512-vZeOkKaAjyV4+RH3+rJZIfDFJAfr+7fyYr6sLDKbYX3uuTVszhFe9/YKf5DNqrDb5cKdKVlYkGn6DTDqMitAnA==}
+ peerDependencies:
+ '@bufbuild/protobuf': ^1.4.2
+ dependencies:
+ '@bufbuild/protobuf': 1.10.0
+ dev: false
+
/@csstools/[email protected](@csstools/[email protected]):
resolution: {integrity: sha512-xI/tL2zxzEbESvnSxwFgwvy5HS00oCXxL4MLs6HUiDcYfwowsoQaABKxUElp1ARITrINzBnsECOc1q0eg2GOrA==}
engines: {node: ^14 || ^16 || >=18}
@@ -8933,6 +8958,21 @@ packages:
resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
+ /@valtown/[email protected](@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected]):
+ resolution: {integrity: sha512-/OEiRmErQKk9i37nENgtChvTqC+xX4KWiHDpwl5O8hLsW9nAgDOMRfeVH9K249+IRgdCWToT9RySLOtpkcX4sQ==}
+ peerDependencies:
+ '@codemirror/autocomplete': ^6
+ '@codemirror/state': ^6
+ '@codemirror/view': ^6
+ dependencies:
+ '@bufbuild/protobuf': 1.10.0
+ '@codemirror/autocomplete': 6.16.2(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@lezer/[email protected])
+ '@codemirror/state': 6.4.1
+ '@codemirror/view': 6.26.3
+ '@connectrpc/connect': 1.4.0(@bufbuild/[email protected])
+ '@connectrpc/connect-web': 1.4.0(@bufbuild/[email protected])(@connectrpc/[email protected])
+ dev: false
+
resolution: {integrity: sha512-yrknSb3Dci6svCd/qhHqhFPDSw0QtjumcqdKMoNNzmOl5lMXTTiqzjWtG4Qask2HdvvzaNgSunbQGet8/GrKdA==}
peerDependencies:
diff --git a/frontend/src/components/app-config/user-config-form.tsx b/frontend/src/components/app-config/user-config-form.tsx
index 81040c4b90..26bc074b97 100644
--- a/frontend/src/components/app-config/user-config-form.tsx
+++ b/frontend/src/components/app-config/user-config-form.tsx
@@ -22,7 +22,6 @@ import { useUserConfig } from "../../core/config/config";
import { NativeSelect } from "../ui/native-select";
import { KEYMAP_PRESETS } from "@/core/codemirror/keymaps/keymaps";
import { CopilotConfig } from "@/core/codemirror/copilot/copilot-config";
-import { Switch } from "../ui/switch";
import { SettingTitle, SettingDescription, SettingSubtitle } from "./common";
import { THEMES } from "@/theme/useTheme";
import { isPyodide } from "@/core/pyodide/utils";
@@ -55,6 +54,53 @@ export const UserConfigForm: React.FC = () => {
const isWasm = isPyodide();
+ const renderCopilotProvider = () => {
+ const copilot = form.getValues("completion.copilot");
+ if (copilot === false) {
+ return null;
+ }
+ if (copilot === "codeium") {
+ return (
+ <>
+ <p className="text-sm text-muted-secondary">
+ To get a Codeium API key, follow{" "}
+ <a
+ className="text-link hover:underline"
+ href="https://docs.marimo.io/guides/ai_completion.html#codeium-copilot"
+ target="_blank"
+ rel="noreferrer"
+ >
+ these instructions
+ </a>
+ .
+ </p>
+ <FormField
+ control={form.control}
+ name="completion.codeium_api_key"
+ render={({ field }) => (
+ <FormItem className={formItemClasses}>
+ <FormLabel>API Key</FormLabel>
+ <FormControl>
+ <Input
+ data-testid="codeium-api-key-input"
+ className="m-0 inline-flex"
+ placeholder="key"
+ {...field}
+ value={field.value || ""}
+ />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </>
+ );
+ }
+ if (copilot === "github") {
+ return <CopilotConfig />;
+ }
+ };
+
return (
<Form {...form}>
<form
@@ -68,29 +114,26 @@ export const UserConfigForm: React.FC = () => {
Settings applied to all marimo notebooks
</SettingDescription>
</div>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>Editor</SettingSubtitle>
- <div>
- <FormField
- control={form.control}
- name="save.autosave"
- render={({ field }) => (
- <FormItem className={formItemClasses}>
- <FormLabel className="font-normal">Autosave</FormLabel>
- <FormControl>
- <Checkbox
- data-testid="autosave-checkbox"
- checked={field.value === "after_delay"}
- disabled={field.disabled}
- onCheckedChange={(checked) => {
- field.onChange(checked ? "after_delay" : "off");
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
+ <SettingGroup title="Editor">
+ <FormField
+ control={form.control}
+ name="save.autosave"
+ render={({ field }) => (
+ <FormItem className={formItemClasses}>
+ <FormLabel className="font-normal">Autosave</FormLabel>
+ <FormControl>
+ <Checkbox
+ data-testid="autosave-checkbox"
+ checked={field.value === "after_delay"}
+ disabled={field.disabled}
+ onCheckedChange={(checked) => {
+ field.onChange(checked ? "after_delay" : "off");
+ }}
+ />
+ </FormControl>
+ </FormItem>
+ )}
+ />
<FormField
control={form.control}
name="save.autosave_delay"
@@ -119,27 +162,25 @@ export const UserConfigForm: React.FC = () => {
</FormItem>
)}
/>
- <div>
- <FormField
- control={form.control}
- name="save.format_on_save"
- render={({ field }) => (
- <FormItem className={formItemClasses}>
- <FormLabel className="font-normal">Format on save</FormLabel>
- <FormControl>
- <Checkbox
- data-testid="format-on-save-checkbox"
- checked={field.value}
- disabled={field.disabled}
- onCheckedChange={(checked) => {
- field.onChange(checked);
- }}
- />
- </FormControl>
- </FormItem>
- )}
- />
- </div>
+ <FormField
+ control={form.control}
+ name="save.format_on_save"
+ render={({ field }) => (
+ <FormItem className={formItemClasses}>
+ <FormLabel className="font-normal">Format on save</FormLabel>
+ <FormControl>
+ <Checkbox
+ data-testid="format-on-save-checkbox"
+ checked={field.value}
+ disabled={field.disabled}
+ onCheckedChange={(checked) => {
+ field.onChange(checked);
+ }}
+ />
+ </FormControl>
+ </FormItem>
+ )}
+ />
<FormField
control={form.control}
name="formatting.line_length"
@@ -240,9 +281,8 @@ export const UserConfigForm: React.FC = () => {
</div>
)}
/>
- </div>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>Display</SettingSubtitle>
+ </SettingGroup>
+ <SettingGroup title="Display">
<FormField
control={form.control}
name="display.default_width"
@@ -357,10 +397,9 @@ export const UserConfigForm: React.FC = () => {
</div>
)}
/>
- </div>
+ </SettingGroup>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>Package Management</SettingSubtitle>
+ <SettingGroup title="Package Management">
<FormField
control={form.control}
disabled={isWasm}
@@ -387,9 +426,8 @@ export const UserConfigForm: React.FC = () => {
</FormItem>
)}
/>
- </div>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>Runtime</SettingSubtitle>
+ </SettingGroup>
+ <SettingGroup title="Runtime">
<FormField
control={form.control}
name="runtime.auto_instantiate"
@@ -475,9 +513,8 @@ export const UserConfigForm: React.FC = () => {
</div>
)}
/>
- </div>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>AI Assist</SettingSubtitle>
+ </SettingGroup>
+ <SettingGroup title="AI Assist">
<p className="text-sm text-muted-secondary">
Add an API key to <Kbd className="inline">~/.marimo.toml</Kbd> to
activate marimo's AI assistant; see{" "}
@@ -500,12 +537,10 @@ export const UserConfigForm: React.FC = () => {
<FormLabel>Base URL</FormLabel>
<FormControl>
<Input
- data-testid="code-editor-font-size-input"
+ data-testid="ai-base-url-input"
className="m-0 inline-flex"
- {...field}
- value={field.value}
placeholder="https://api.openai.com"
- onChange={(e) => field.onChange(e.target.value)}
+ {...field}
/>
</FormControl>
<FormMessage />
@@ -516,52 +551,82 @@ export const UserConfigForm: React.FC = () => {
control={form.control}
disabled={isWasm}
name="ai.open_ai.model"
- render={({ field: { value, onChange, ...field } }) => (
+ render={({ field }) => (
<FormItem className={formItemClasses}>
<FormLabel>Model</FormLabel>
<FormControl>
<Input
- data-testid="code-editor-font-size-input"
+ data-testid="ai-model-input"
className="m-0 inline-flex"
- {...field}
- defaultValue={value}
placeholder="gpt-3.5-turbo"
- onBlur={(e) => onChange(e.target.value)}
+ {...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
- </div>
- <div className="flex flex-col gap-3">
- <SettingSubtitle>GitHub Copilot</SettingSubtitle>
+ </SettingGroup>
+ <SettingGroup title="AI Code Completion">
+ <p className="text-sm text-muted-secondary">
+ You may use GitHub Copilot or Codeium for AI code completion.
+ </p>
+
<FormField
control={form.control}
- disabled={isWasm}
name="completion.copilot"
render={({ field }) => (
- <div className="flex flex-col gap-2">
- <FormItem className="flex flex-row items-center space-x-2 space-y-0">
+ <div className="flex flex-col space-y-1">
+ <FormItem className={formItemClasses}>
+ <FormLabel>Provider</FormLabel>
<FormControl>
- <Switch
- data-testid="copilot-switch"
- size={"sm"}
- checked={field.value}
- disabled={field.disabled}
- onCheckedChange={(checked) => {
- field.onChange(Boolean(checked));
+ <NativeSelect
+ data-testid="copilot-select"
+ onChange={(e) => {
+ if (e.target.value === "none") {
+ field.onChange(false);
+ } else {
+ field.onChange(e.target.value);
+ }
}}
- />
+ value={
+ field.value === true
+ ? "github"
+ : field.value === false
+ ? "none"
+ : field.value
+ }
+ disabled={field.disabled}
+ className="inline-flex mr-2"
+ >
+ {["none", "github", "codeium"].map((option) => (
+ <option value={option} key={option}>
+ {option}
+ </option>
+ ))}
+ </NativeSelect>
</FormControl>
- <FormLabel className="font-normal flex">Enable</FormLabel>
+ <FormMessage />
</FormItem>
- {field.value && <CopilotConfig />}
</div>
)}
/>
- </div>
+
+ {renderCopilotProvider()}
+ </SettingGroup>
</form>
</Form>
);
};
+
+const SettingGroup = ({
+ title,
+ children,
+}: { title: string; children: React.ReactNode }) => {
+ return (
+ <div className="flex flex-col gap-3">
+ <SettingSubtitle>{title}</SettingSubtitle>
+ {children}
+ </div>
+ );
+};
diff --git a/frontend/src/components/editor/actions/useConfigActions.tsx b/frontend/src/components/editor/actions/useConfigActions.tsx
index 8cd09d9ef6..f9f1ab7189 100644
--- a/frontend/src/components/editor/actions/useConfigActions.tsx
+++ b/frontend/src/components/editor/actions/useConfigActions.tsx
@@ -74,18 +74,30 @@ export function useConfigActions() {
},
},
{
- label: config.completion.copilot
- ? "Config > Disable GitHub Copilot"
- : "Config > Enable GitHub Copilot",
+ label: "Config > Disable GitHub Copilot",
handle: () => {
handleUserConfig({
...config,
completion: {
...config.completion,
- copilot: !config.completion.copilot,
+ copilot: false,
},
});
},
+ hidden: config.completion.copilot !== "github",
+ },
+ {
+ label: "Config > Enable GitHub Copilot",
+ handle: () => {
+ handleUserConfig({
+ ...config,
+ completion: {
+ ...config.completion,
+ copilot: "github",
+ },
+ });
+ },
+ hidden: config.completion.copilot === "github",
},
];
diff --git a/frontend/src/core/codemirror/cm.ts b/frontend/src/core/codemirror/cm.ts
index 5bf9d066bc..f3a969e26c 100644
--- a/frontend/src/core/codemirror/cm.ts
+++ b/frontend/src/core/codemirror/cm.ts
@@ -110,7 +110,7 @@ const startCompletionAtEndOfLine = (cm: EditorView): boolean => {
// Based on codemirror's basicSetup extension
export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
- const { theme, hotkeys } = opts;
+ const { theme, hotkeys, completionConfig } = opts;
return [
///// View
@@ -134,7 +134,7 @@ export const basicBundle = (opts: CodeMirrorSetupOpts): Extension[] => {
theme === "dark" ? oneDark : [],
hintTooltip(),
- copilotBundle(),
+ copilotBundle(completionConfig),
foldGutter(),
closeBrackets(),
// to avoid clash with charDeleteBackward keymap
diff --git a/frontend/src/core/codemirror/copilot/extension.ts b/frontend/src/core/codemirror/copilot/extension.ts
index dc05e037c2..e9465d1cea 100644
--- a/frontend/src/core/codemirror/copilot/extension.ts
+++ b/frontend/src/core/codemirror/copilot/extension.ts
@@ -7,57 +7,94 @@ import {
getCopilotClient,
} from "./client";
import { inlineSuggestion } from "codemirror-extension-inline-suggestion";
+import {
+ copilotPlugin as codeiumCopilotPlugin,
+ Language,
+ codeiumOtherDocumentsConfig,
+} from "@valtown/codemirror-codeium";
import { isCopilotEnabled } from "./state";
import { getCodes } from "./getCodes";
+import { CompletionConfig } from "@/core/config/config-schema";
-export const copilotBundle = (): Extension => {
+export const copilotBundle = (config: CompletionConfig): Extension => {
if (process.env.NODE_ENV === "test") {
return [];
}
- return [
- inlineSuggestion({
- delay: 500, // default is 500ms
- fetchFn: async (view) => {
- if (!isCopilotEnabled()) {
- return "";
- }
+ const extensions: Extension[] = [];
+
+ if (config.copilot === "codeium" && config.codeium_api_key) {
+ extensions.push(
+ codeiumCopilotPlugin({
+ apiKey: config.codeium_api_key,
+ language: Language.PYTHON,
+ }),
+ codeiumOtherDocumentsConfig.of({
+ override: async () => {
+ return [
+ {
+ text: getCodes(""),
+ language: Language.PYTHON,
+ editorLanguage: "python",
+ },
+ ];
+ },
+ }),
+ );
+ }
- // If no text, don't fetch
- if (view.doc.length === 0) {
- return "";
- }
+ if (config.copilot === "github") {
+ extensions.push(
+ inlineSuggestion({
+ delay: 200, // default is 500ms
+ fetchFn: async (view) => {
+ if (config.codeium_api_key) {
+ return "";
+ }
+ if (!isCopilotEnabled()) {
+ return "";
+ }
- // wait 10ms so that the view is updated first
- await new Promise((resolve) => setTimeout(resolve, 10));
+ // If no text, don't fetch
+ if (view.doc.length === 0) {
+ return "";
+ }
- // We need to update the position of the cursor because added newlines
- // from appending the other code
- const currentCode = view.doc.toString();
- const allCode = getCodes(currentCode);
- const numberOfNewLines =
- allCode.split("\n").length - currentCode.split("\n").length;
+ // wait 10ms so that the view is updated first
+ await new Promise((resolve) => setTimeout(resolve, 10));
- const position = offsetToPos(view.doc, view.selection.main.head);
- position.line += numberOfNewLines;
+ // We need to update the position of the cursor because added newlines
+ // from appending the other code
+ const currentCode = view.doc.toString();
+ const allCode = getCodes(currentCode);
+ const numberOfNewLines =
+ allCode.split("\n").length - currentCode.split("\n").length;
- const response = await getCopilotClient().getCompletion({
- doc: {
- source: allCode,
- tabSize: view.tabSize,
- indentSize: 1,
- insertSpaces: true,
- path: COPILOT_FILENAME,
- version: 0,
- uri: `file://${COPILOT_FILENAME}`,
- relativePath: COPILOT_FILENAME,
- languageId: LANGUAGE_ID,
- position: position,
- },
- });
- return response.completions.map((c) => c.displayText)[0] ?? "";
- },
- }),
+ const position = offsetToPos(view.doc, view.selection.main.head);
+ position.line += numberOfNewLines;
+
+ const response = await getCopilotClient().getCompletion({
+ doc: {
+ source: allCode,
+ tabSize: view.tabSize,
+ indentSize: 1,
+ insertSpaces: true,
+ path: COPILOT_FILENAME,
+ version: 0,
+ uri: `file://${COPILOT_FILENAME}`,
+ relativePath: COPILOT_FILENAME,
+ languageId: LANGUAGE_ID,
+ position: position,
+ },
+ });
+ return response.completions.map((c) => c.displayText)[0] ?? "";
+ },
+ }),
+ );
+ }
+
+ return [
+ ...extensions,
// pop off last 2 elements of the array which are tooltip and autocompletion
copilotServer().slice(0, -2),
];
diff --git a/frontend/src/core/codemirror/copilot/state.ts b/frontend/src/core/codemirror/copilot/state.ts
index 67198385a2..1bcfda8675 100644
--- a/frontend/src/core/codemirror/copilot/state.ts
+++ b/frontend/src/core/codemirror/copilot/state.ts
@@ -22,11 +22,11 @@ function getIsLastSignedIn() {
export function isCopilotEnabled() {
const copilot = getIsLastSignedIn();
const userConfig = getUserConfig();
- return copilot && userConfig.completion.copilot;
+ return copilot && userConfig.completion.copilot === "github";
}
export function waitForEnabledCopilot() {
return waitFor(userConfigAtom, (value) => {
- return value.completion.copilot;
+ return value.completion.copilot === "github";
});
}
diff --git a/frontend/src/core/config/config-schema.ts b/frontend/src/core/config/config-schema.ts
index f0c4982f4a..cb4674e953 100644
--- a/frontend/src/core/config/config-schema.ts
+++ b/frontend/src/core/config/config-schema.ts
@@ -24,7 +24,16 @@ export const UserConfigSchema = z
completion: z
.object({
activate_on_typing: z.boolean().default(true),
- copilot: z.boolean().default(false),
+ copilot: z
+ .union([z.boolean(), z.enum(["github", "codeium"])])
+ .default(false)
+ .transform((copilot) => {
+ if (copilot === true) {
+ return "github";
+ }
+ return copilot;
+ }),
+ codeium_api_key: z.string().nullish(),
})
.default({}),
save: z
diff --git a/frontend/src/css/app/codemirror.css b/frontend/src/css/app/codemirror.css
index 64c00bb15e..546c09e188 100644
--- a/frontend/src/css/app/codemirror.css
+++ b/frontend/src/css/app/codemirror.css
@@ -137,3 +137,43 @@
@apply text-xs;
}
+
+.cm-ghostText,
+.cm-ghostText * {
+ opacity: 0.6;
+ filter: grayscale(20%);
+ cursor: pointer;
+}
+
+.cm-ghostText:hover {
+ background: var(--gray-3);
+}
+
+.cm-codeium-cycle {
+ font-size: 9px;
+ background-color: var(--sky-3);
+ padding: 2px;
+ border-radius: 2px;
+ display: inline-block;
+}
+
+.cm-codeium-cycle-key {
+ font-size: 9px;
+ font-family: monospace;
+ display: inline-block;
+ padding: 2px;
+ border-radius: 2px;
+ border: none;
+ background-color: var(--sky-7);
+ margin-left: 5px;
+}
+
+.cm-codeium-cycle-key:hover {
+ background-color: var(--sky-9);
+}
+
+.cm-codeium-cycle-explanation {
+ font-family: monospace;
+ display: inline-block;
+ padding: 2px;
+}
diff --git a/frontend/src/stories/editor.stories.tsx b/frontend/src/stories/editor.stories.tsx
index d9b42fe8d3..e6f2e24377 100644
--- a/frontend/src/stories/editor.stories.tsx
+++ b/frontend/src/stories/editor.stories.tsx
@@ -74,7 +74,15 @@ export const Primary: Story = {
export const DefaultPython: Story = {
render: () => (
<div className="m-20 w-[60%] overflow-hidden">
- <CodeMirror extensions={[python(), copilotBundle()]} />
+ <CodeMirror
+ extensions={[
+ python(),
+ copilotBundle({
+ activate_on_typing: true,
+ copilot: false,
+ }),
+ ]}
+ />
<CopilotConfig />
</div>
),
diff --git a/marimo/_config/config.py b/marimo/_config/config.py
index 21cf2af1f5..7c64350408 100644
--- a/marimo/_config/config.py
+++ b/marimo/_config/config.py
@@ -9,7 +9,7 @@ if sys.version_info < (3, 11):
else:
from typing import NotRequired
-from typing import Any, Dict, Literal, TypedDict, Union, cast
+from typing import Any, Dict, Literal, Optional, TypedDict, Union, cast
from marimo._output.rich_help import mddoc
from marimo._utils.deep_merge import deep_merge
@@ -31,7 +31,8 @@ class CompletionConfig(TypedDict):
"""
activate_on_typing: bool
- copilot: bool
+ copilot: Union[bool, Literal["github", "codeium"]]
+ codeium_api_key: NotRequired[Optional[str]]
@mddoc
diff --git a/openapi/api.yaml b/openapi/api.yaml
index 3e1789022f..ad31917f72 100644
--- a/openapi/api.yaml
+++ b/openapi/api.yaml
@@ -941,8 +941,16 @@ components:
properties:
activate_on_typing:
type: boolean
+ codeium_api_key:
+ nullable: true
+ type: string
copilot:
- type: boolean
+ oneOf:
+ - type: boolean
+ - enum:
+ - github
+ - codeium
+ type: string
required:
- activate_on_typing
- copilot
@@ -1664,7 +1672,7 @@ components:
type: object
info:
title: marimo API
- version: 0.6.23
+ version: 0.6.24
openapi: 3.1.0
paths:
/@file/{filename_and_length}:
diff --git a/openapi/src/api.ts b/openapi/src/api.ts
index 0b91b608a4..90a20e9997 100644
--- a/openapi/src/api.ts
+++ b/openapi/src/api.ts
@@ -1117,7 +1117,8 @@ export interface components {
};
completion: {
activate_on_typing: boolean;
- copilot: boolean;
+ codeium_api_key?: string | null;
+ copilot: boolean | ("github" | "codeium");
};
display: {
/** @enum {string} */