Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
PopDaph committed Sep 8, 2023
1 parent 75297c1 commit 31202d9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions front/admin/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@ async function main() {
await ExtractedEvent.sync({ alter: true });
await DocumentTrackerChangeSuggestion.sync({ alter: true });

await AgentConfiguration.sync({ alter: true });
await AgentGenerationConfiguration.sync({ alter: true });

await AgentRetrievalConfiguration.sync({ alter: true });
await AgentDataSourceConfiguration.sync({ alter: true });
await AgentConfiguration.sync({ alter: true });
await AgentRetrievalAction.sync({ alter: true });
await RetrievalDocument.sync({ alter: true });
await RetrievalDocumentChunk.sync({ alter: true });
Expand Down
4 changes: 2 additions & 2 deletions front/lib/api/assistant/actions/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ export async function* runRetrieval(

// Handle data sources list and parents/tags filtering.
config.DATASOURCE.data_sources = c.dataSources.map((d) => ({
workspace_id: d.workspaceSId,
data_source_id: d.dataSourceName,
workspace_id: d.workspaceId,
data_source_id: d.dataSourceId,
}));

for (const ds of c.dataSources) {
Expand Down
16 changes: 8 additions & 8 deletions front/lib/api/assistant/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ export async function _agentActionType(
}

dataSourcesConfigType.push({
dataSourceName: dataSource.name,
workspaceSId: workspace.sId,
dataSourceId: dataSource.name,
workspaceId: workspace.sId,
filter: {
tags:
dsConfig.tagsIn && dsConfig.tagsNotIn
Expand Down Expand Up @@ -530,7 +530,7 @@ export async function _createAgentDataSourcesConfigData(
// First we get the list of workspaces because we need the mapping between workspaceSId and workspaceId
const workspaces = await Workspace.findAll({
where: {
sId: dataSourcesConfig.map((dsConfig) => dsConfig.workspaceSId),
sId: dataSourcesConfig.map((dsConfig) => dsConfig.workspaceId),
},
attributes: ["id", "sId"],
});
Expand All @@ -551,7 +551,7 @@ export async function _createAgentDataSourcesConfigData(
curr: AgentDataSourceConfigurationType
) => {
// First we need to get the workspaceId from the workspaceSId
const workspace = workspaces.find((w) => w.sId === curr.workspaceSId);
const workspace = workspaces.find((w) => w.sId === curr.workspaceId);
if (!workspace) {
throw new Error("Workspace not found");
}
Expand All @@ -563,12 +563,12 @@ export async function _createAgentDataSourcesConfigData(
);
if (existingEntry) {
// Append dataSourceName to existing entry
existingEntry.dataSourceNames.push(curr.dataSourceName);
existingEntry.dataSourceNames.push(curr.dataSourceId);
} else {
// Add a new entry for this workspaceId
acc.push({
workspaceId: workspace.id,
dataSourceNames: [curr.dataSourceName],
dataSourceNames: [curr.dataSourceId],
});
}
return acc;
Expand Down Expand Up @@ -597,9 +597,9 @@ export async function _createAgentDataSourcesConfigData(
dataSourcesConfig.map(async (dsConfig) => {
const dataSource = dataSources.find(
(ds) =>
ds.name === dsConfig.dataSourceName &&
ds.name === dsConfig.dataSourceId &&
ds.workspaceId ===
workspaces.find((w) => w.sId === dsConfig.workspaceSId)?.id
workspaces.find((w) => w.sId === dsConfig.workspaceId)?.id
);
if (!dataSource) {
throw new Error("DataSource not found");
Expand Down
4 changes: 2 additions & 2 deletions front/types/assistant/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function isRetrievalConfiguration(
* Datasources config for Retrieval Action
*/
export type AgentDataSourceConfigurationType = {
workspaceSId: string; // need sId to talk with Core (external id)
dataSourceName: string; // need Datasource.name to talk with Core (external id)
workspaceId: string; // need sId to talk with Core (external id)
dataSourceId: string; // need Datasource.name to talk with Core (external id)
filter: {
tags: { in: string[]; not: string[] } | null;
parents: { in: string[]; not: string[] } | null;
Expand Down

0 comments on commit 31202d9

Please sign in to comment.