mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat(OpenAI Node): Overhaul (#8335)
This commit is contained in:
@@ -13,6 +13,8 @@ import {
|
||||
REGULAR_NODE_CREATOR_VIEW,
|
||||
TRIGGER_NODE_CREATOR_VIEW,
|
||||
CUSTOM_API_CALL_KEY,
|
||||
OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE,
|
||||
OPEN_AI_NODE_TYPE,
|
||||
} from '@/constants';
|
||||
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
@@ -24,6 +26,7 @@ import { useViewStacks } from '../composables/useViewStacks';
|
||||
|
||||
import ItemsRenderer from '../Renderers/ItemsRenderer.vue';
|
||||
import CategorizedItemsRenderer from '../Renderers/CategorizedItemsRenderer.vue';
|
||||
import type { IDataObject } from 'n8n-workflow';
|
||||
|
||||
const emit = defineEmits({
|
||||
nodeTypeSelected: (nodeTypes: string[]) => true,
|
||||
@@ -145,6 +148,12 @@ function onSelected(actionCreateElement: INodeCreateElement) {
|
||||
const actionNode = actions.value[0].key;
|
||||
|
||||
emit('nodeTypeSelected', [actionData.key as string, actionNode]);
|
||||
} else if (
|
||||
actionData.key === OPEN_AI_NODE_TYPE &&
|
||||
(actionData?.value as IDataObject)?.resource === 'assistant' &&
|
||||
(actionData?.value as IDataObject)?.operation === 'message'
|
||||
) {
|
||||
emit('nodeTypeSelected', [OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE]);
|
||||
} else {
|
||||
emit('nodeTypeSelected', [actionData.key as string]);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
NODE_CREATOR_OPEN_SOURCES,
|
||||
NO_OP_NODE_TYPE,
|
||||
OPEN_AI_ASSISTANT_NODE_TYPE,
|
||||
OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE,
|
||||
OPEN_AI_NODE_TYPE,
|
||||
QA_CHAIN_NODE_TYPE,
|
||||
SCHEDULE_TRIGGER_NODE_TYPE,
|
||||
SPLIT_IN_BATCHES_NODE_TYPE,
|
||||
@@ -188,6 +190,7 @@ export const useActions = () => {
|
||||
AGENT_NODE_TYPE,
|
||||
BASIC_CHAIN_NODE_TYPE,
|
||||
OPEN_AI_ASSISTANT_NODE_TYPE,
|
||||
OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE,
|
||||
];
|
||||
|
||||
const isChatTriggerMissing =
|
||||
@@ -228,6 +231,10 @@ export const useActions = () => {
|
||||
}
|
||||
|
||||
addedNodes.forEach((node, index) => {
|
||||
if (node.type === OPEN_AI_NODE_MESSAGE_ASSISTANT_TYPE) {
|
||||
node.type = OPEN_AI_NODE_TYPE;
|
||||
}
|
||||
|
||||
nodes.push(node);
|
||||
|
||||
switch (node.type) {
|
||||
|
||||
@@ -97,7 +97,9 @@ interface NodeView {
|
||||
|
||||
function getAiNodesBySubcategory(nodes: INodeTypeDescription[], subcategory: string) {
|
||||
return nodes
|
||||
.filter((node) => node.codex?.subcategories?.[AI_SUBCATEGORY]?.includes(subcategory))
|
||||
.filter(
|
||||
(node) => !node.hidden && node.codex?.subcategories?.[AI_SUBCATEGORY]?.includes(subcategory),
|
||||
)
|
||||
.map((node) => ({
|
||||
key: node.name,
|
||||
type: 'node',
|
||||
@@ -109,6 +111,13 @@ function getAiNodesBySubcategory(nodes: INodeTypeDescription[], subcategory: str
|
||||
description: node.description,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
icon: node.icon!,
|
||||
iconData: node.name.toLowerCase().includes('openai')
|
||||
? {
|
||||
type: 'file',
|
||||
icon: 'openai',
|
||||
fileBuffer: '/static/open-ai.svg',
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
}))
|
||||
.sort((a, b) => a.properties.displayName.localeCompare(b.properties.displayName));
|
||||
|
||||
Reference in New Issue
Block a user