From c173bea936eda0660e2374d520710d84962565f0 Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Wed, 15 May 2024 01:26:29 +0100 Subject: [PATCH] fixed dynamic service imports --- .../Playground/Views/ParametersView.tsx | 11 ++-- .../components/Playground/Views/TestView.tsx | 62 +++++++++++-------- 2 files changed, 42 insertions(+), 31 deletions(-) diff --git a/agenta-web/src/components/Playground/Views/ParametersView.tsx b/agenta-web/src/components/Playground/Views/ParametersView.tsx index c110ac572c..b7f830e051 100644 --- a/agenta-web/src/components/Playground/Views/ParametersView.tsx +++ b/agenta-web/src/components/Playground/Views/ParametersView.tsx @@ -152,10 +152,13 @@ const ParametersView: React.FC = ({ setHistoryStatus({loading: true, error: false}) setIsDrawerOpen(true) try { - if (variant.variantId && isDemo()) { - const revisions = await promptVersioning(variant.variantId) - setPromptRevisions(revisions) - } + await promptVersioning.then(async (module: any) => { + if (!module) return + if (variant.variantId && isDemo()) { + const revisions = await module.fetchAllPromptVersioning(variant.variantId) + setPromptRevisions(revisions) + } + }) setHistoryStatus({loading: false, error: false}) } catch (error) { setHistoryStatus({loading: false, error: true}) diff --git a/agenta-web/src/components/Playground/Views/TestView.tsx b/agenta-web/src/components/Playground/Views/TestView.tsx index 6eb08e83f4..6922be2e78 100644 --- a/agenta-web/src/components/Playground/Views/TestView.tsx +++ b/agenta-web/src/components/Playground/Views/TestView.tsx @@ -347,36 +347,44 @@ const App: React.FC = ({ if (!revisionNum) return const fetchData = async () => { - const revision = await promptRevision(variant.variantId, parseInt(revisionNum)) - if (!revision) return + await promptRevision.then(async (module: any) => { + if (!module) return - setPromptOptParams((prevState: Parameter[] | null) => { - if (!prevState) { - return prevState - } + const revision = await module.fetchPromptRevision( + variant.variantId, + parseInt(revisionNum), + ) - const parameterNames = [ - "temperature", - "model", - "max_tokens", - "prompt_system", - "prompt_user", - "top_p", - "frequence_penalty", - "presence_penalty", - "inputs", - ] - - return prevState.map((param: Parameter) => { - if (parameterNames.includes(param.name)) { - const newValue = (revision?.config.parameters as Record)[ - param.name - ] - if (newValue !== undefined) { - param.default = newValue - } + if (!revision) return + + setPromptOptParams((prevState: Parameter[] | null) => { + if (!prevState) { + return prevState } - return param + + const parameterNames = [ + "temperature", + "model", + "max_tokens", + "prompt_system", + "prompt_user", + "top_p", + "frequence_penalty", + "presence_penalty", + "inputs", + ] + + return prevState.map((param: Parameter) => { + if (parameterNames.includes(param.name)) { + const newValue = (revision?.config.parameters as Record)[ + param.name + ] + if (newValue !== undefined) { + param.default = newValue + } + } + return param + }) }) }) }