Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Removed onload patch call in prompt studio (#475)

jagadeeswaran-zipstackedaac16db33c
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
index 6a67d9939..cb8313163 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
@@ -123,13 +123,6 @@ function PromptCard({
if (isSinglePassExtractLoading) {
return;
}
- if (selectedLlmProfileId !== promptDetails?.profile_id) {
- handleChange(
- selectedLlmProfileId,
- promptDetails?.prompt_id,
- "profile_manager"
- );
- }
}, [
selectedLlmProfileId,
selectedDoc,
@@ -173,7 +166,7 @@ function PromptCard({
useEffect(() => {
const isProfilePresent = llmProfiles?.some(
- (profile) => profile?.profile_id === selectedLlmProfileId
+ (profile) => profile?.profile_id === defaultLlmProfile
);
// If selectedLlmProfileId is not present, set it to null
@@ -192,6 +185,7 @@ function PromptCard({
const handleSelectDefaultLLM = (llmProfileId) => {
setSelectedLlmProfileId(llmProfileId);
+ handleChange(llmProfileId, promptDetails?.prompt_id, "profile_manager");
};
const handleTypeChange = (value) => {
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
index 4bc10fd7a..e6f800183 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCardItems.jsx
@@ -36,12 +36,8 @@ import { TokenUsage } from "../token-usage/TokenUsage";
import { useCustomToolStore } from "../../../store/custom-tool-store";
import { Header } from "./Header";
import CheckableTag from "antd/es/tag/CheckableTag";
-import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
-import { useSessionStore } from "../../../store/session-store";
import { motion, AnimatePresence } from "framer-motion";
import { OutputForIndex } from "./OutputForIndex";
-import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
-import { useAlertStore } from "../../../store/alert-store";
import { useWindowDimensions } from "../../../hooks/useWindowDimensions";
const EvalBtn = null;
@@ -80,6 +76,7 @@ function PromptCardItems({
isSinglePassExtractLoading,
indexDocs,
isSimplePromptStudio,
+ adapters,
} = useCustomToolStore();
const [isEditingPrompt, setIsEditingPrompt] = useState(false);
const [isEditingTitle, setIsEditingTitle] = useState(false);
@@ -91,11 +88,7 @@ function PromptCardItems({
);
const [expandedProfiles, setExpandedProfiles] = useState([]); // New state for expanded profiles
const [isIndexOpen, setIsIndexOpen] = useState(false);
- const privateAxios = useAxiosPrivate();
- const { sessionDetails } = useSessionStore();
const { width: windowWidth } = useWindowDimensions();
- const handleException = useExceptionHandler();
- const { setAlertDetails } = useAlertStore();
const componentWidth = windowWidth * 0.4;
const divRef = useRef(null);
@@ -123,35 +116,26 @@ function PromptCardItems({
return result;
};
- const getAdapterInfo = async () => {
- privateAxios
- .get(`/api/v1/unstract/${sessionDetails?.orgId}/adapter/`)
- .then((res) => {
- const adapterData = res?.data;
-
- // Update llmProfiles with additional fields
- const updatedProfiles = llmProfiles?.map((profile) => {
- return { ...getModelOrAdapterId(profile, adapterData), ...profile };
- });
- setLlmProfileDetails(
- updatedProfiles
- .map((profile) => ({
- ...profile,
- isDefault: profile?.profile_id === selectedLlmProfileId,
- isEnabled: enabledProfiles.includes(profile?.profile_id),
- }))
- .sort((a, b) => {
- if (a?.isDefault) return -1; // Default profile comes first
- if (b?.isDefault) return 1;
- if (a?.isEnabled && !b?.isEnabled) return -1; // Enabled profiles come before disabled
- if (!a?.isEnabled && b?.isEnabled) return 1;
- return 0;
- })
- );
- })
- .catch((err) => {
- setAlertDetails(handleException(err));
- });
+ const getAdapterInfo = async (adapterData) => {
+ // Update llmProfiles with additional fields
+ const updatedProfiles = llmProfiles?.map((profile) => {
+ return { ...getModelOrAdapterId(profile, adapterData), ...profile };
+ });
+ setLlmProfileDetails(
+ updatedProfiles
+ .map((profile) => ({
+ ...profile,
+ isDefault: profile?.profile_id === selectedLlmProfileId,
+ isEnabled: enabledProfiles.includes(profile?.profile_id),
+ }))
+ .sort((a, b) => {
+ if (a?.isDefault) return -1; // Default profile comes first
+ if (b?.isDefault) return 1;
+ if (a?.isEnabled && !b?.isEnabled) return -1; // Enabled profiles come before disabled
+ if (!a?.isEnabled && b?.isEnabled) return 1;
+ return 0;
+ })
+ );
};
const tooltipContent = (adapterConf) => (
@@ -247,7 +231,7 @@ function PromptCardItems({
}, [singlePassExtractMode]);
useEffect(() => {
- getAdapterInfo();
+ getAdapterInfo(adapters);
}, [llmProfiles, selectedLlmProfileId, enabledProfiles]);
return (
<Card className="prompt-card">
diff --git a/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js b/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js
index 53f835ae7..d9e61bb1e 100644
--- a/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js
+++ b/frontend/src/components/helpers/custom-tools/CustomToolsHelper.js
@@ -29,6 +29,7 @@ function CustomToolsHelper() {
defaultLlmProfile: "",
llmProfiles: [],
selectedDoc: null,
+ adapters: [],
};
const reqOpsPromptStudio = {
@@ -81,6 +82,16 @@ function CustomToolsHelper() {
.then((res) => {
const data = res?.data;
updatedCusTool["llmProfiles"] = data;
+ const reqOpsLlmProfiles = {
+ method: "GET",
+ url: `/api/v1/unstract/${sessionDetails?.orgId}/adapter/`,
+ };
+
+ return handleApiRequest(reqOpsLlmProfiles);
+ })
+ .then((res) => {
+ const data = res?.data;
+ updatedCusTool["adapters"] = data;
})
.catch((err) => {
setAlertDetails(handleException(err, "Failed to load the custom tool"));
diff --git a/frontend/src/store/custom-tool-store.js b/frontend/src/store/custom-tool-store.js
index f7b94e1c3..ba3019fa4 100644
--- a/frontend/src/store/custom-tool-store.js
+++ b/frontend/src/store/custom-tool-store.js
@@ -16,6 +16,7 @@ const defaultState = {
singlePassExtractMode: false,
isSinglePassExtractLoading: false,
isSimplePromptStudio: false,
+ adapters: [],
};
const defaultPromptInstance = {