Skip to content

Commit

Permalink
chore: rename KnowledgeNamespace to KnowledgeSourceNamespace
Browse files Browse the repository at this point in the history
Helps to differentiate between what entities can pull from knowledge files vs knowledge sources
  • Loading branch information
ryanhopperlowe committed Dec 30, 2024
1 parent e5a3673 commit b2f0044
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions ui/admin/app/hooks/knowledge/useKnowledgeSourceFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import useSWR from "swr";
import {
KnowledgeFile,
KnowledgeFileState,
KnowledgeNamespace,
KnowledgeSource,
KnowledgeSourceNamespace,
KnowledgeSourceStatus,
} from "~/lib/model/knowledge";
import { KnowledgeSourceApiService } from "~/lib/service/api/knowledgeSourceApiService";
import { handlePromise } from "~/lib/service/async";

export function useKnowledgeSourceFiles(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
knowledgeSource: KnowledgeSource
) {
Expand Down
4 changes: 2 additions & 2 deletions ui/admin/app/hooks/knowledge/useKnowledgeSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { useMemo, useState } from "react";
import useSWR from "swr";

import {
KnowledgeNamespace,
KnowledgeSource,
KnowledgeSourceInput,
KnowledgeSourceNamespace,
KnowledgeSourceStatus,
} from "~/lib/model/knowledge";
import { KnowledgeSourceApiService } from "~/lib/service/api/knowledgeSourceApiService";

export function useKnowledgeSources(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string
) {
const [blockPollingSources, setBlockPollingSources] = useState(false);
Expand Down
6 changes: 3 additions & 3 deletions ui/admin/app/lib/model/knowledge.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const KnowledgeNamespace = {
export const KnowledgeSourceNamespace = {
Agents: "agents",
Workflows: "workflows",
} as const;
export type KnowledgeNamespace =
(typeof KnowledgeNamespace)[keyof typeof KnowledgeNamespace];
export type KnowledgeSourceNamespace =
(typeof KnowledgeSourceNamespace)[keyof typeof KnowledgeSourceNamespace];

export const KnowledgeFileNamespace = {
Threads: "threads",
Expand Down
20 changes: 10 additions & 10 deletions ui/admin/app/lib/routers/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { mutate } from "swr";

import {
KnowledgeFileNamespace,
KnowledgeNamespace,
KnowledgeSourceNamespace,
} from "~/lib/model/knowledge";
import { ToolReferenceType } from "~/lib/model/toolReferences";
import { ApiUrl } from "~/lib/routers/baseRouter";
Expand Down Expand Up @@ -66,49 +66,49 @@ export const ApiRoutes = {
},
knowledgeSources: {
getKnowledgeSources: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string
) => buildUrl(`/${namespace}/${entityId}/knowledge-sources`),
createKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string
) => buildUrl(`/${namespace}/${entityId}/knowledge-sources`),
getKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string
) =>
buildUrl(`/${namespace}/${entityId}/knowledge-sources/${sourceId}`),
updateKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string
) =>
buildUrl(`/${namespace}/${entityId}/knowledge-sources/${sourceId}`),
deleteKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string
) =>
buildUrl(`/${namespace}/${entityId}/knowledge-sources/${sourceId}`),
syncKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string
) =>
buildUrl(
`/${namespace}/${entityId}/knowledge-sources/${sourceId}/sync`
),
getFilesForKnowledgeSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string
) =>
buildUrl(
`/${namespace}/${entityId}/knowledge-sources/${sourceId}/knowledge-files`
),
reingestKnowledgeFileFromSource: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
sourceId: string,
fileName: string
Expand All @@ -117,7 +117,7 @@ export const ApiRoutes = {
`/${namespace}/${entityId}/knowledge-sources/${sourceId}/knowledge-files/${fileName}/ingest`
),
approveFile: (
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
entityId: string,
fileName: string
) => buildUrl(`/${namespace}/${entityId}/approve-file/${fileName}`),
Expand Down
22 changes: 11 additions & 11 deletions ui/admin/app/lib/service/api/knowledgeSourceApiService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
KnowledgeFile,
KnowledgeNamespace,
KnowledgeSource,
KnowledgeSourceInput,
KnowledgeSourceNamespace,
} from "~/lib/model/knowledge";
import { ApiRoutes } from "~/lib/routers/apiRoutes";
import { request } from "~/lib/service/api/primitives";

async function createKnowledgeSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
input: KnowledgeSourceInput
) {
Expand All @@ -25,7 +25,7 @@ async function createKnowledgeSource(
}

async function updateKnowledgeSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
knowledgeSourceId: string,
input: KnowledgeSourceInput
Expand All @@ -44,7 +44,7 @@ async function updateKnowledgeSource(
}

async function resyncKnowledgeSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
knowledgeSourceId: string
) {
Expand All @@ -61,7 +61,7 @@ async function resyncKnowledgeSource(
}

async function approveFile(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
fileID: string,
approve: boolean
Expand All @@ -77,7 +77,7 @@ async function approveFile(
}

async function getKnowledgeSources(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string
) {
const res = await request<{
Expand All @@ -90,7 +90,7 @@ async function getKnowledgeSources(
return res.data.items;
}
getKnowledgeSources.key = (
namespace?: Nullish<KnowledgeNamespace>,
namespace?: Nullish<KnowledgeSourceNamespace>,
agentId?: Nullish<string>
) => {
if (!namespace || !agentId) return null;
Expand All @@ -104,7 +104,7 @@ getKnowledgeSources.key = (
};

async function getFilesForKnowledgeSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
sourceId: string
) {
Expand All @@ -121,7 +121,7 @@ async function getFilesForKnowledgeSource(
}

getFilesForKnowledgeSource.key = (
namespace?: Nullish<KnowledgeNamespace>,
namespace?: Nullish<KnowledgeSourceNamespace>,
agentId?: Nullish<string>,
sourceId?: Nullish<string>
) => {
Expand All @@ -139,7 +139,7 @@ getFilesForKnowledgeSource.key = (
};

async function reingestFileFromSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
sourceId: string,
fileID: string
Expand All @@ -161,7 +161,7 @@ async function reingestFileFromSource(
}

async function deleteKnowledgeSource(
namespace: KnowledgeNamespace,
namespace: KnowledgeSourceNamespace,
agentId: string,
sourceId: string
) {
Expand Down

0 comments on commit b2f0044

Please sign in to comment.