2023-10-10 18:14:48 +03:00
|
|
|
import {
|
|
|
|
FeedItemCrawlType,
|
|
|
|
FeedItemUploadType,
|
|
|
|
} from "@/app/chat/[chatId]/components/ActionsBar/types";
|
|
|
|
import { useKnowledgeToFeedContext } from "@/lib/context/KnowledgeToFeedProvider/hooks/useKnowledgeToFeedContext";
|
|
|
|
|
|
|
|
type UseKnowledgeToFeed = {
|
|
|
|
files: File[];
|
|
|
|
urls: string[];
|
|
|
|
};
|
2023-12-06 12:12:03 +03:00
|
|
|
export const useKnowledgeToFeedFilesAndUrls = (): UseKnowledgeToFeed => {
|
2023-10-10 18:14:48 +03:00
|
|
|
const { knowledgeToFeed } = useKnowledgeToFeedContext();
|
|
|
|
|
|
|
|
const files: File[] = (
|
|
|
|
knowledgeToFeed.filter((c) => c.source === "upload") as FeedItemUploadType[]
|
|
|
|
).map((c) => c.file);
|
|
|
|
|
|
|
|
const urls: string[] = (
|
|
|
|
knowledgeToFeed.filter((c) => c.source === "crawl") as FeedItemCrawlType[]
|
|
|
|
).map((c) => c.url);
|
|
|
|
|
|
|
|
return {
|
|
|
|
files,
|
|
|
|
urls,
|
|
|
|
};
|
|
|
|
};
|