diff --git a/python/src/aiconfig/editor/client/src/LocalEditor.tsx b/python/src/aiconfig/editor/client/src/LocalEditor.tsx index 80fa8bc5f..69bcef269 100644 --- a/python/src/aiconfig/editor/client/src/LocalEditor.tsx +++ b/python/src/aiconfig/editor/client/src/LocalEditor.tsx @@ -5,7 +5,13 @@ import AIConfigEditor, { RunPromptStreamErrorEvent, } from "./components/AIConfigEditor"; import { Flex, Loader, MantineProvider, Image } from "@mantine/core"; -import { AIConfig, InferenceSettings, JSONObject, Output, Prompt } from "aiconfig"; +import { + AIConfig, + InferenceSettings, + JSONObject, + Output, + Prompt, +} from "aiconfig"; import { useCallback, useEffect, useMemo, useState } from "react"; import { ufetch } from "ufetch"; import { ROUTE_TABLE } from "./utils/api"; @@ -27,12 +33,12 @@ export default function Editor() { const setupTelemetryIfAllowed = useCallback(async () => { const isDev = (process.env.NODE_ENV ?? "development") === "development"; - - // Don't enable telemetry in dev mode because hot reload will spam the logs. + + // Don't enable telemetry in dev mode because hot reload will spam the logs. if (isDev) { return; } - + const res = await ufetch.get(ROUTE_TABLE.GET_AICONFIGRC, {}); const enableTelemetry = res.allow_usage_data_sharing; diff --git a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx index 9d7280953..96bd36f53 100644 --- a/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx +++ b/python/src/aiconfig/editor/client/src/components/AIConfigEditor.tsx @@ -63,6 +63,7 @@ import CopyButton from "./CopyButton"; type Props = { aiconfig: AIConfig; callbacks: AIConfigCallbacks; + readOnly?: boolean; }; export type RunPromptStreamEvent = @@ -163,6 +164,7 @@ const useStyles = createStyles((theme) => ({ export default function EditorContainer({ aiconfig: initialAIConfig, callbacks, + readOnly = false, }: Props) { const [isSaving, setIsSaving] = useState(false); const [serverStatus, setServerStatus] = useState<"OK" | "ERROR">("OK"); @@ -785,8 +787,9 @@ export default function EditorContainer({ () => ({ getState, logEvent: logEventCallback, + readOnly, }), - [getState, logEventCallback] + [getState, logEventCallback, readOnly] ); const isDirty = aiconfigState._ui.isDirty !== false; diff --git a/python/src/aiconfig/editor/client/src/components/prompt/RunPromptButton.tsx b/python/src/aiconfig/editor/client/src/components/prompt/RunPromptButton.tsx index 1e55e889f..efbe43f59 100644 --- a/python/src/aiconfig/editor/client/src/components/prompt/RunPromptButton.tsx +++ b/python/src/aiconfig/editor/client/src/components/prompt/RunPromptButton.tsx @@ -1,6 +1,7 @@ import { Button, Flex, Loader, Tooltip } from "@mantine/core"; import { IconPlayerPlayFilled, IconPlayerStop } from "@tabler/icons-react"; -import { memo } from "react"; +import { memo, useContext } from "react"; +import AIConfigContext from "../../contexts/AIConfigContext"; type Props = { cancel: () => Promise; @@ -15,6 +16,9 @@ export default memo(function RunPromptButton({ isRunning = false, disabled = false, }: Props) { + const { readOnly } = useContext(AIConfigContext); + const disabledOrReadOnly = disabled || readOnly; + const onClick = async () => { if (isRunning) { return await cancel(); @@ -22,10 +26,11 @@ export default memo(function RunPromptButton({ return await runPrompt(); } }; + const button = (