diff --git a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx index ad80fa9ce..86394eb07 100644 --- a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx +++ b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx @@ -103,6 +103,7 @@ export type AIConfigCallbacks = { ) => Promise<{ aiconfig: AIConfig }>; clearOutputs: () => Promise<{ aiconfig: AIConfig }>; deletePrompt: (promptName: string) => Promise; + download?: () => Promise; getModels: (search: string) => Promise; getServerStatus?: () => Promise<{ status: "OK" | "ERROR" }>; logEventHandler?: (event: LogEvent, data?: LogEventData) => void; @@ -150,6 +151,23 @@ export default function AIConfigEditor({ const logEventHandler = callbacks?.logEventHandler; + const downloadCallback = callbacks?.download; + const onDownload = useCallback(async () => { + if (!downloadCallback) { + return; + } + try { + await downloadCallback(); + } catch (err: unknown) { + const message = (err as RequestCallbackError).message ?? null; + showNotification({ + title: "Error downloading AIConfig", + message, + color: "red", + }); + } + }, [downloadCallback]); + const shareCallback = callbacks?.share; const onShare = useCallback(async () => { if (!shareCallback) { @@ -962,6 +980,9 @@ export default function AIConfigEditor({ {!readOnly && ( + {downloadCallback && ( + + )} {shareCallback && } {onClearOutputs && ( + ); +});