diff --git a/frontend/src/components/input-output/add-source/AddSource.jsx b/frontend/src/components/input-output/add-source/AddSource.jsx
index ddaff0a34..96fb5d60a 100644
--- a/frontend/src/components/input-output/add-source/AddSource.jsx
+++ b/frontend/src/components/input-output/add-source/AddSource.jsx
@@ -1,6 +1,6 @@
import { Typography } from "antd";
import PropTypes from "prop-types";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { sourceTypes } from "../../../helpers/GetStaticData";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
@@ -14,6 +14,7 @@ let transformLlmWhispererJsonSchema;
let LLMW_V2_ID;
let PLAN_TYPES;
let unstractSubscriptionPlanStore;
+let llmWhipererAdapterSchema;
try {
transformLlmWhispererJsonSchema =
require("../../../plugins/unstract-subscription/helper/transformLlmWhispererJsonSchema").transformLlmWhispererJsonSchema;
@@ -22,6 +23,7 @@ try {
PLAN_TYPES =
require("../../../plugins/unstract-subscription/helper/constants").PLAN_TYPES;
unstractSubscriptionPlanStore = require("../../../plugins/store/unstract-subscription-plan-store");
+ llmWhipererAdapterSchema = require("../../../plugins/unstract-subscription/hooks/useLlmWhispererAdapterSchema.js");
} catch (err) {
// Ignore if not available
}
@@ -48,6 +50,15 @@ function AddSource({
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
+ let transformLlmWhispererFormData;
+ try {
+ transformLlmWhispererFormData =
+ llmWhipererAdapterSchema?.useLlmWhipererAdapterSchema()
+ ?.transformLlmWhispererFormData;
+ } catch {
+ // Ignore if not available
+ }
+
let planType;
if (unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore) {
planType = unstractSubscriptionPlanStore?.useUnstractSubscriptionPlanStore(
@@ -55,6 +66,32 @@ function AddSource({
);
}
+ const isLLMWPaidSchema = useMemo(() => {
+ return (
+ LLMW_V2_ID &&
+ transformLlmWhispererJsonSchema &&
+ PLAN_TYPES &&
+ selectedSourceId === LLMW_V2_ID &&
+ planType === PLAN_TYPES?.PAID
+ );
+ }, [
+ LLMW_V2_ID,
+ transformLlmWhispererJsonSchema,
+ PLAN_TYPES,
+ selectedSourceId,
+ planType,
+ ]);
+
+ useEffect(() => {
+ if (!isLLMWPaidSchema || !transformLlmWhispererFormData) return;
+
+ const modifiedFormData = transformLlmWhispererFormData(formData);
+
+ if (JSON.stringify(modifiedFormData) !== JSON.stringify(formData)) {
+ setFormData(modifiedFormData);
+ }
+ }, [isLLMWPaidSchema, formData]);
+
useEffect(() => {
if (!selectedSourceId) {
setSpec({});
@@ -80,13 +117,7 @@ function AddSource({
const data = res?.data;
setFormData(metadata || {});
- if (
- LLMW_V2_ID &&
- transformLlmWhispererJsonSchema &&
- PLAN_TYPES &&
- selectedSourceId === LLMW_V2_ID &&
- planType === PLAN_TYPES?.PAID
- ) {
+ if (isLLMWPaidSchema) {
setSpec(transformLlmWhispererJsonSchema(data?.json_schema || {}));
} else {
setSpec(data?.json_schema || {});
diff --git a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
index 7cf512ad4..1d7951849 100644
--- a/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
+++ b/frontend/src/components/navigations/top-nav-bar/TopNavBar.jsx
@@ -71,10 +71,13 @@ try {
let unstractSubscriptionPlan;
let unstractSubscriptionPlanStore;
let UNSTRACT_SUBSCRIPTION_PLANS;
+let UnstractPricingMenuLink;
try {
unstractSubscriptionPlanStore = require("../../../plugins/store/unstract-subscription-plan-store");
UNSTRACT_SUBSCRIPTION_PLANS =
require("../../../plugins/unstract-subscription/helper/constants").UNSTRACT_SUBSCRIPTION_PLANS;
+ UnstractPricingMenuLink =
+ require("../../../plugins/unstract-subscription/components/UnstractPricingMenuLink.jsx").UnstractPricingMenuLink;
} catch (err) {
// Plugin unavailable.
}
@@ -294,6 +297,13 @@ function TopNavBar({ isSimpleLayout, topNavBarOptions }) {
});
}
+ if (isUnstract && UnstractPricingMenuLink) {
+ menuItems.push({
+ key: "7",
+ label: