Skip to content

Allowed nodes validation #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions frontend/src/components/Layout/PageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import LoadDBSchemaDialog from '../Popups/GraphEnhancementDialog/EnitityExtracti
import PredefinedSchemaDialog from '../Popups/GraphEnhancementDialog/EnitityExtraction/PredefinedSchemaDialog';
import { SKIP_AUTH } from '../../utils/Constants';
import { useNavigate } from 'react-router';
import { deduplicateByRelationshipTypeOnly, deduplicateNodeByValue } from '../../utils/Utils';
import { deduplicateByFullPattern, deduplicateNodeByValue } from '../../utils/Utils';

const GCSModal = lazy(() => import('../DataSources/GCS/GCSModal'));
const S3Modal = lazy(() => import('../DataSources/AWS/S3Modal'));
Expand Down Expand Up @@ -378,7 +378,7 @@ const PageLayout: React.FC = () => {
setSchemaValRels(rels);
setCombinedRelsVal((prevRels: OptionType[]) => {
const combined = [...rels, ...prevRels];
return deduplicateByRelationshipTypeOnly(combined);
return deduplicateByFullPattern(combined);
});
setSchemaView('text');
localStorage.setItem(LOCAL_KEYS.source, JSON.stringify(updatedSource));
Expand Down Expand Up @@ -418,7 +418,7 @@ const PageLayout: React.FC = () => {
setDbRels(rels);
setCombinedRelsVal((prevRels: OptionType[]) => {
const combined = [...rels, ...prevRels];
return deduplicateByRelationshipTypeOnly(combined);
return deduplicateByFullPattern(combined);
});
localStorage.setItem(LOCAL_KEYS.source, JSON.stringify(updatedSource));
localStorage.setItem(LOCAL_KEYS.type, JSON.stringify(updatedType));
Expand Down Expand Up @@ -456,7 +456,7 @@ const PageLayout: React.FC = () => {
setPreDefinedRels(rels);
setCombinedRelsVal((prevRels: OptionType[]) => {
const combined = [...rels, ...prevRels];
return deduplicateByRelationshipTypeOnly(combined);
return deduplicateByFullPattern(combined);
});
localStorage.setItem(LOCAL_KEYS.source, JSON.stringify(updatedSource));
localStorage.setItem(LOCAL_KEYS.type, JSON.stringify(updatedType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
updateLocalStorage,
extractOptions,
parseRelationshipString,
deduplicateByRelationshipTypeOnly,
deduplicateByFullPattern,
deduplicateNodeByValue,
} from '../../../../utils/Utils';
import TooltipWrapper from '../../../UI/TipWrapper';
Expand Down Expand Up @@ -175,15 +175,15 @@ export default function NewEntityExtractionSetting({
});
setUserDefinedRels((prev: OptionType[]) => {
const combined = [...prev, ...relationshipTypeOptions];
return deduplicateByRelationshipTypeOnly(combined);
return deduplicateByFullPattern(combined);
});
setCombinedNodes((prev: OptionType[]) => {
const combined = [...prev, ...nodeLabelOptions];
return deduplicateNodeByValue(combined);
});
setCombinedRels((prev: OptionType[]) => {
const combined = [...prev, ...relationshipTypeOptions];
return deduplicateByRelationshipTypeOnly(combined);
return deduplicateByFullPattern(combined);
});
setTupleOptions((prev) => [...updatedTuples, ...prev]);
} else {
Expand Down
8 changes: 3 additions & 5 deletions frontend/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,14 +881,12 @@ export const deduplicateNodeByValue = (arrays: { value: any }[]) => {
});
return Array.from(map.values());
};

export const deduplicateByRelationshipTypeOnly = (arrays: { value: string; label: string }[]) => {
export const deduplicateByFullPattern = (arrays: { value: string; label: string }[]) => {
const seen = new Set<string>();
const result: { value: string; label: string }[] = [];
arrays.forEach((item) => {
const [, type] = item.value.split(',');
if (!seen.has(type)) {
seen.add(type);
if (!seen.has(item.value)) {
seen.add(item.value);
result.push(item);
}
});
Expand Down