Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

rag fix

Ahmed Essama1dfed977f54
diff --git a/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts b/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts
index 74ef3544..8d7d0d08 100644
--- a/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts
+++ b/packages/app/src/builder-ui/components/DataSourceCleaner.class.ts
@@ -3,10 +3,28 @@ import { Component } from './Component.class';
// @ts-ignore
export class DataSourceCleaner extends Component {
- private namespaces: string[] = [];
+ private namespaces: { value: string; text: string; __legacy_id: string }[] = [];
protected async prepare(): Promise<any> {
- this.updateSettings();
+ this.updateSettings().then(() => {
+ // if the current value does not match anything
+ const isUnableToMatchNsRecord =
+ this.data['namespaceId'] &&
+ !this.namespaces.find((ns) => ns.value === this.data['namespaceId']);
+ if (isUnableToMatchNsRecord) {
+ // try two cases, case where teamid is stripped, and case of original id
+ const nsWithTeamId = `${window.workspace.teamData.id}_${this.data['namespaceId']}`;
+ const ns = this.data['namespaceId'];
+ const matching = this.namespaces.find(
+ (_nsRec) => _nsRec.__legacy_id === ns || _nsRec.__legacy_id === nsWithTeamId,
+ );
+ if (matching) {
+ this.data['namespaceId'] = matching.value;
+ } else {
+ console.log('WE are not able to map the old name');
+ }
+ }
+ });
}
protected async updateSettings() {
@@ -14,7 +32,11 @@ export class DataSourceCleaner extends Component {
`${this.workspace.server}/api/component/DataSourceIndexer/v2/namespaces`,
);
const namespaces = await result.json();
- this.namespaces = namespaces.map((item) => ({ value: item.label, text: item.label }));
+ this.namespaces = namespaces.map((item) => ({
+ value: item.label,
+ text: item.label,
+ __legacy_id: item.__legacy_id,
+ }));
this.settings.namespaceId.options = this.namespaces;
if (this.settingsOpen) this.refreshSettingsSidebar();
}
@@ -45,11 +67,6 @@ export class DataSourceCleaner extends Component {
if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
}
- // if the namespace value is using the old legacy format {{teamId}}_{{namespace}}, we need to convert it to the new format {{namespace}}
- if (this.data['namespaceId'] && /^c[a-z0-9]{24}.+$/.test(this.data['namespaceId'])) {
- this.data['namespaceId'] = this.data['namespaceId'].split('_').slice(1).join('_');
- }
-
this.properties.defaultInputs = [];
this.properties.defaultOutputs = ['Success'];
diff --git a/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts b/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts
index d41fbb4f..12283471 100644
--- a/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts
+++ b/packages/app/src/builder-ui/components/DataSourceIndexer.class.ts
@@ -3,10 +3,28 @@ import { Component } from './Component.class';
// @ts-ignore
export class DataSourceIndexer extends Component {
- private namespaces: string[] = [];
+ private namespaces: { value: string; text: string; __legacy_id: string }[] = [];
protected async prepare(): Promise<any> {
- this.updateSettings();
+ this.updateSettings().then(() => {
+ // if the current value does not match anything
+ const isUnableToMatchNsRecord =
+ this.data['namespace'] &&
+ !this.namespaces.find((ns) => ns.value === this.data['namespace']);
+ if (isUnableToMatchNsRecord) {
+ // try two cases, case where teamid is stripped, and case of original id
+ const nsWithTeamId = `${window.workspace.teamData.id}_${this.data['namespace']}`;
+ const ns = this.data['namespace'];
+ const matching = this.namespaces.find(
+ (_nsRec) => _nsRec.__legacy_id === ns || _nsRec.__legacy_id === nsWithTeamId,
+ );
+ if (matching) {
+ this.data['namespace'] = matching.value;
+ } else {
+ console.log('WE are not able to map the old name');
+ }
+ }
+ });
return new Promise((resolve) => resolve(true));
}
@@ -16,7 +34,11 @@ export class DataSourceIndexer extends Component {
`${this.workspace.server}/api/component/DataSourceIndexer/v2/namespaces`,
);
const namespaces = await result.json();
- this.namespaces = namespaces.map((item) => ({ value: item.label, text: item.label }));
+ this.namespaces = namespaces.map((item) => ({
+ value: item.label,
+ text: item.label,
+ __legacy_id: item.__legacy_id,
+ }));
this.settings.namespace.options = this.namespaces;
if (this.settingsOpen) this.refreshSettingsSidebar();
}
@@ -81,11 +103,6 @@ export class DataSourceIndexer extends Component {
if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
}
- // if the namespace value is using the old legacy format {{teamId}}_{{namespace}}, we need to convert it to the new format {{namespace}}
- if (this.data['namespace'] && /^c[a-z0-9]{24}.+$/.test(this.data['namespace'])) {
- this.data['namespace'] = this.data['namespace'].split('_').slice(1).join('_');
- }
-
this.properties.defaultInputs = ['Source'];
this.properties.defaultOutputs = ['Success'];
diff --git a/packages/app/src/builder-ui/components/DataSourceLookup.class.ts b/packages/app/src/builder-ui/components/DataSourceLookup.class.ts
index c0df6e94..83c4bf9a 100644
--- a/packages/app/src/builder-ui/components/DataSourceLookup.class.ts
+++ b/packages/app/src/builder-ui/components/DataSourceLookup.class.ts
@@ -3,12 +3,29 @@ import { Component } from './Component.class';
// @ts-ignore
export class DataSourceLookup extends Component {
- private namespaces: string[] = [];
-
+ private namespaces: { value: string; text: string; __legacy_id: string }[] = [];
protected async prepare(): Promise<any> {
// this.isNewComponent = Object.keys(this.data).length === 0;
- this.updateSettings();
+ this.updateSettings().then(() => {
+ // if the current value does not match anything
+ const isUnableToMatchNsRecord =
+ this.data['namespace'] &&
+ !this.namespaces.find((ns) => ns.value === this.data['namespace']);
+ if (isUnableToMatchNsRecord) {
+ // try two cases, case where teamid is stripped, and case of original id
+ const nsWithTeamId = `${window.workspace.teamData.id}_${this.data['namespace']}`;
+ const ns = this.data['namespace'];
+ const matching = this.namespaces.find(
+ (_nsRec) => _nsRec.__legacy_id === ns || _nsRec.__legacy_id === nsWithTeamId,
+ );
+ if (matching) {
+ this.data['namespace'] = matching.value;
+ } else {
+ console.log('WE are not able to map the old name');
+ }
+ }
+ });
}
protected async updateSettings() {
@@ -16,7 +33,11 @@ export class DataSourceLookup extends Component {
`${this.workspace.server}/api/component/DataSourceIndexer/v2/namespaces`,
);
const namespaces = await result.json();
- this.namespaces = namespaces.map((item) => ({ value: item.label, text: item.label }));
+ this.namespaces = namespaces.map((item) => ({
+ value: item.label,
+ text: item.label,
+ __legacy_id: item.__legacy_id,
+ }));
this.settings.namespace.options = this.namespaces;
if (this.settingsOpen) this.refreshSettingsSidebar();
}
@@ -65,9 +86,21 @@ export class DataSourceLookup extends Component {
if (typeof this.data[item] === 'undefined') this.data[item] = this.settings[item].value;
}
- // if the namespace value is using the old legacy format {{teamId}}_{{namespace}}, we need to convert it to the new format {{namespace}}
- if (this.data['namespace'] && /^c[a-z0-9]{24}.+$/.test(this.data['namespace'])) {
- this.data['namespace'] = this.data['namespace'].split('_').slice(1).join('_');
+ // if the current value does not match anything
+ const isUnableToMatchNsRecord =
+ this.data['namespace'] && !this.namespaces.find((ns) => ns.value === this.data['namespace']);
+ if (isUnableToMatchNsRecord) {
+ // try two cases, case where teamid is stripped, and case of original id
+ const nsWithTeamId = `${window.workspace.teamData.id}_${this.data['namespace']}`;
+ const ns = this.data['namespace'];
+ const matching = this.namespaces.find(
+ (_nsRec) => _nsRec.__legacy_id === ns || _nsRec.__legacy_id === nsWithTeamId,
+ );
+ if (matching) {
+ this.data['namespace'] = matching.value;
+ } else {
+ console.log('WE are not able to map the old name');
+ }
}
this.properties.defaultInputs = ['Query'];