feat(editor): Node Creator AI nodes improvements (#9484)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
||||
scaleReset,
|
||||
scaleSmaller,
|
||||
} from '@/utils/canvasUtils';
|
||||
import { START_NODE_TYPE } from '@/constants';
|
||||
import { MANUAL_TRIGGER_NODE_TYPE, START_NODE_TYPE } from '@/constants';
|
||||
import type {
|
||||
BeforeStartEventParams,
|
||||
BrowserJsPlumbInstance,
|
||||
@@ -61,6 +61,9 @@ export const useCanvasStore = defineStore('canvas', () => {
|
||||
(node) => node.type === START_NODE_TYPE || nodeTypesStore.isTriggerNode(node.type),
|
||||
),
|
||||
);
|
||||
const aiNodes = computed<INodeUi[]>(() =>
|
||||
nodes.value.filter((node) => node.type.includes('langchain')),
|
||||
);
|
||||
const isDemo = ref<boolean>(false);
|
||||
const nodeViewScale = ref<number>(1);
|
||||
const canvasAddButtonPosition = ref<XYPosition>([1, 1]);
|
||||
@@ -91,6 +94,23 @@ export const useCanvasStore = defineStore('canvas', () => {
|
||||
};
|
||||
};
|
||||
|
||||
const getAutoAddManualTriggerNode = (): INodeUi | null => {
|
||||
const manualTriggerNode = nodeTypesStore.getNodeType(MANUAL_TRIGGER_NODE_TYPE);
|
||||
|
||||
if (!manualTriggerNode) {
|
||||
console.error('Could not find the manual trigger node');
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
id: uuid(),
|
||||
name: manualTriggerNode.defaults.name?.toString() ?? manualTriggerNode.displayName,
|
||||
type: MANUAL_TRIGGER_NODE_TYPE,
|
||||
parameters: {},
|
||||
position: canvasAddButtonPosition.value,
|
||||
typeVersion: 1,
|
||||
};
|
||||
};
|
||||
|
||||
const getNodesWithPlaceholderNode = (): INodeUi[] =>
|
||||
triggerNodes.value.length > 0 ? nodes.value : [getPlaceholderTriggerNodeUI(), ...nodes.value];
|
||||
|
||||
@@ -298,6 +318,7 @@ export const useCanvasStore = defineStore('canvas', () => {
|
||||
newNodeInsertPosition,
|
||||
jsPlumbInstance,
|
||||
isLoading: loadingService.isLoading,
|
||||
aiNodes,
|
||||
startLoading: loadingService.startLoading,
|
||||
setLoadingText: loadingService.setLoadingText,
|
||||
stopLoading: loadingService.stopLoading,
|
||||
@@ -311,5 +332,6 @@ export const useCanvasStore = defineStore('canvas', () => {
|
||||
zoomToFit,
|
||||
wheelScroll,
|
||||
initInstance,
|
||||
getAutoAddManualTriggerNode,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||
* Constructs URLSearchParams object based on the default parameters for the template repository
|
||||
* and provided additional parameters
|
||||
*/
|
||||
websiteTemplateRepositoryParameters() {
|
||||
websiteTemplateRepositoryParameters(roleOverride?: string) {
|
||||
const rootStore = useRootStore();
|
||||
const userStore = useUsersStore();
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
@@ -133,6 +133,7 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||
};
|
||||
const userRole: string | undefined =
|
||||
userStore.currentUserCloudInfo?.role ?? userStore.currentUser?.personalizationAnswers?.role;
|
||||
|
||||
if (userRole) {
|
||||
defaultParameters.utm_user_role = userRole;
|
||||
}
|
||||
@@ -156,10 +157,15 @@ export const useTemplatesStore = defineStore(STORES.TEMPLATES, {
|
||||
* Construct the URL for the template category page on the website for a given category id
|
||||
*/
|
||||
getWebsiteCategoryURL() {
|
||||
return (id: string) => {
|
||||
return `${TEMPLATES_URLS.BASE_WEBSITE_URL}/?${this.websiteTemplateRepositoryParameters({
|
||||
categories: id,
|
||||
}).toString()}`;
|
||||
return (id?: string, roleOverride?: string) => {
|
||||
const payload: Record<string, string> = {};
|
||||
if (id) {
|
||||
payload.categories = id;
|
||||
}
|
||||
if (roleOverride) {
|
||||
payload.utm_user_role = roleOverride;
|
||||
}
|
||||
return `${TEMPLATES_URLS.BASE_WEBSITE_URL}/?${this.websiteTemplateRepositoryParameters(payload).toString()}`;
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user