refactor: add display mode

This commit is contained in:
Mutasem Aldmour 2024-12-17 18:53:33 +01:00
parent ee23daeed6
commit 60138c3b1e
No known key found for this signature in database
GPG key ID: 3DFA8122BB7FD6B8

View file

@ -477,31 +477,29 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
description.name += 'Tool'; description.name += 'Tool';
description.outputs = [NodeConnectionType.AiTool]; description.outputs = [NodeConnectionType.AiTool];
description.displayName += ' Tool'; description.displayName += ' Tool';
if (description.defaults.name) {
description.defaults.name += ' Tool';
}
// const hasResource = description.properties.some((prop) => prop.name === 'resource'); const operationParameter = description.properties.find((prop) => prop.name === 'mode');
// const hasOperation = description.properties.some((prop) => prop.name === 'operation'); if (operationParameter?.options) {
operationParameter.options = operationParameter.options.filter(
(operation) => 'value' in operation && operation.value === 'retrieve',
);
}
// const descriptionType: INodeProperties = { const propertiesToAdd: INodeProperties[] = [
// displayName: 'Tool Description', {
// name: 'descriptionType', displayName: 'Name',
// type: 'options', name: 'toolName',
// noDataExpression: true, type: 'string',
// options: [ default: '',
// { required: true,
// name: 'Set Automatically', description: 'Name of the vector store',
// value: 'auto', placeholder: 'e.g. company_knowledge_base',
// description: 'Automatically set based on resource and operation', validateType: 'string-alphanumeric',
// }, },
// { {
// name: 'Set Manually',
// value: 'manual',
// description: 'Manually set the description',
// },
// ],
// default: 'auto',
// };
const descProp: INodeProperties = {
displayName: 'Description', displayName: 'Description',
name: 'toolDescription', name: 'toolDescription',
type: 'string', type: 'string',
@ -511,34 +509,9 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
description: description:
'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often', 'Explain to the LLM what this tool does, a good, specific description would allow LLMs to produce expected results much more often',
placeholder: `e.g. ${description.description}`, placeholder: `e.g. ${description.description}`,
}; },
];
description.properties.unshift(descProp); description.properties.unshift(...propertiesToAdd);
const nameProp: INodeProperties = {
displayName: 'Name',
name: 'toolName',
type: 'string',
default: '',
required: true,
description: 'Name of the vector store',
placeholder: 'e.g. company_knowledge_base',
validateType: 'string-alphanumeric',
};
description.properties.unshift(nameProp);
// // todo is this needed?
// // If node has resource or operation we can determine pre-populate tool description based on it
// // so we add the descriptionType property as the first property
// if (hasResource || hasOperation) {
// description.properties.unshift(descriptionType);
// descProp.displayOptions = {
// show: {
// descriptionType: ['manual'],
// },
// };
// }
} }
}; };