+
Welcome to cognee
+ {session ? (
+
+ Hello, {session.user.name}!
+
+
+ Log out
+
+
-
-
-
-
Sign in
-
-
+ ) : (
+
+
+
+ Sign up
+
+
+
+
+
+ Log in
+
+
-
-
-
-
+ )}
+
)
}
diff --git a/cognee-frontend/src/app/auth/layout.tsx b/cognee-frontend/src/app/auth/layout.tsx
new file mode 100644
index 000000000..66b32e86c
--- /dev/null
+++ b/cognee-frontend/src/app/auth/layout.tsx
@@ -0,0 +1,31 @@
+import type { Metadata } from "next";
+import { TextLogo } from "@/ui/App";
+import { Divider } from "@/ui/Layout";
+import { Footer } from "@/ui/Partials";
+
+export const metadata: Metadata = {
+ title: "Cognee",
+ description: "Cognee authentication",
+};
+
+export default function AuthLayout({
+ children,
+}: Readonly<{
+ children: React.ReactNode;
+}>) {
+ return (
+
+
+
+
+
+
+ {children}
+
+
+
+
+
+
+ );
+}
diff --git a/cognee-frontend/src/app/auth/login/LoginPage.tsx b/cognee-frontend/src/app/auth/login/LoginPage.tsx
new file mode 100644
index 000000000..76c00107f
--- /dev/null
+++ b/cognee-frontend/src/app/auth/login/LoginPage.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import Link from "next/link";
+import Image from "next/image";
+
+import AuthForm from "../AuthForm";
+
+export default function LoginPage() {
+ return (
+
+
+
+
+
Welcome
+
Log in to continue with Cognee
+
+
+
+
+
+ {"Or go to Sign up ->"}
+
+
+
+
+ );
+}
+
+function formatPayload(data: { email: string, password: string }) {
+ const payload = new URLSearchParams();
+
+ payload.append("username", data.email);
+ payload.append("password", data.password);
+
+ return payload;
+}
diff --git a/cognee-frontend/src/app/auth/login/page.tsx b/cognee-frontend/src/app/auth/login/page.tsx
new file mode 100644
index 000000000..f81523088
--- /dev/null
+++ b/cognee-frontend/src/app/auth/login/page.tsx
@@ -0,0 +1 @@
+export { default } from "./LoginPage";
diff --git a/cognee-frontend/src/app/auth/page.tsx b/cognee-frontend/src/app/auth/page.tsx
index c1a940de9..c62393502 100644
--- a/cognee-frontend/src/app/auth/page.tsx
+++ b/cognee-frontend/src/app/auth/page.tsx
@@ -1 +1 @@
-export { default } from './AuthPage';
+export { default } from "./AuthPage";
diff --git a/cognee-frontend/src/app/auth/signup/SignUpPage.tsx b/cognee-frontend/src/app/auth/signup/SignUpPage.tsx
new file mode 100644
index 000000000..7b52dc7b0
--- /dev/null
+++ b/cognee-frontend/src/app/auth/signup/SignUpPage.tsx
@@ -0,0 +1,31 @@
+"use client";
+
+import Link from "next/link";
+import Image from "next/image";
+
+import AuthForm from "../AuthForm";
+
+export default function SignUpPage() {
+ return (
+
+
+
+
+
Welcome
+
Sign up to start using Cognee
+
+
window.location.href = "/auth/login"}
+ />
+
+
+
+ {"Or go to Login ->"}
+
+
+
+
+ );
+}
diff --git a/cognee-frontend/src/app/auth/signup/page.tsx b/cognee-frontend/src/app/auth/signup/page.tsx
new file mode 100644
index 000000000..a29e66c33
--- /dev/null
+++ b/cognee-frontend/src/app/auth/signup/page.tsx
@@ -0,0 +1 @@
+export { default } from "./SignUpPage";
diff --git a/cognee-frontend/src/app/auth/token/route.ts b/cognee-frontend/src/app/auth/token/route.ts
new file mode 100644
index 000000000..780ba45c8
--- /dev/null
+++ b/cognee-frontend/src/app/auth/token/route.ts
@@ -0,0 +1,17 @@
+import { redirect } from "next/navigation";
+import { auth0 } from "@/modules/auth/auth0";
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export async function GET(request: Request) {
+ const accessToken = await auth0.getAccessToken();
+
+ if (accessToken) {
+ const response = new Response();
+
+ response.headers.set("Set-Cookie", `${process.env.AUTH_TOKEN_COOKIE_NAME}=${accessToken.token}; Expires=${new Date(accessToken.expiresAt * 1000).toUTCString()}; Path=/; SameSite=Lax; Domain=localhost; HttpOnly`);
+
+ return response;
+ } else {
+ redirect("/auth");
+ }
+}
diff --git a/cognee-frontend/src/app/layout.tsx b/cognee-frontend/src/app/layout.tsx
index 3314e4780..efb82e537 100644
--- a/cognee-frontend/src/app/layout.tsx
+++ b/cognee-frontend/src/app/layout.tsx
@@ -5,8 +5,8 @@ import "./globals.css";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
- title: "Create Next App",
- description: "Generated by create next app",
+ title: "Cognee",
+ description: "Cognee Dev Mexican Standoff",
};
export default function RootLayout({
diff --git a/cognee-frontend/src/app/page copy.tsx b/cognee-frontend/src/app/page copy.tsx
deleted file mode 100644
index 21847fd75..000000000
--- a/cognee-frontend/src/app/page copy.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-'use client';
-
-import { useCallback, useEffect, useState } from 'react';
-import styles from "./page.module.css";
-import { GhostButton, Notification, NotificationContainer, Spacer, Stack, Text, useBoolean, useNotifications } from 'ohmy-ui';
-import useDatasets from '@/modules/ingestion/useDatasets';
-import DataView, { Data } from '@/modules/ingestion/DataView';
-import DatasetsView from '@/modules/ingestion/DatasetsView';
-import classNames from 'classnames';
-import addData from '@/modules/ingestion/addData';
-import cognifyDataset from '@/modules/datasets/cognifyDataset';
-import getDatasetData from '@/modules/datasets/getDatasetData';
-import { Footer, SettingsModal } from '@/ui/Partials';
-import { TextLogo } from '@/ui/App';
-import { SettingsIcon } from '@/ui/Icons';
-
-export default function Home() {
- const {
- datasets,
- refreshDatasets,
- } = useDatasets();
-
- const [datasetData, setDatasetData] = useState
([]);
- const [selectedDataset, setSelectedDataset] = useState(null);
-
- useEffect(() => {
- refreshDatasets();
- }, [refreshDatasets]);
-
- const openDatasetData = (dataset: { id: string }) => {
- getDatasetData(dataset)
- .then(setDatasetData)
- .then(() => setSelectedDataset(dataset.id));
- };
-
- const closeDatasetData = () => {
- setDatasetData([]);
- setSelectedDataset(null);
- };
-
- const { notifications, showNotification } = useNotifications();
-
- const onDataAdd = useCallback((dataset: { id: string }, files: File[]) => {
- return addData(dataset, files)
- .then(() => {
- showNotification("Data added successfully. Please run \"Cognify\" when ready.", 5000);
- openDatasetData(dataset);
- });
- }, [showNotification])
-
- const onDatasetCognify = useCallback((dataset: { id: string, name: string }) => {
- showNotification(`Cognification started for dataset "${dataset.name}".`, 5000);
-
- return cognifyDataset(dataset)
- .then(() => {
- showNotification(`Dataset "${dataset.name}" cognified.`, 5000);
- })
- .catch(() => {
- showNotification(`Dataset "${dataset.name}" cognification failed. Please try again.`, 5000);
- });
- }, [showNotification]);
-
- const onCognify = useCallback(() => {
- const dataset = datasets.find((dataset) => dataset.id === selectedDataset);
- return onDatasetCognify({
- id: dataset!.id,
- name: dataset!.name,
- });
- }, [datasets, onDatasetCognify, selectedDataset]);
-
- const {
- value: isSettingsModalOpen,
- setTrue: openSettingsModal,
- setFalse: closeSettingsModal,
- } = useBoolean(false);
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
0,
- })}>
-
-
- {datasetData.length > 0 && selectedDataset && (
-
-
-
- )}
-
-
-
-
-
-
- {notifications.map((notification, index: number) => (
-
- {notification.message}
-
- ))}
-
-
- );
-}
diff --git a/cognee-frontend/src/app/page.tsx b/cognee-frontend/src/app/page.tsx
index b6bae761a..523a90f6b 100644
--- a/cognee-frontend/src/app/page.tsx
+++ b/cognee-frontend/src/app/page.tsx
@@ -1 +1,3 @@
export { default } from "./(graph)/GraphView";
+
+export const dynamic = "force-dynamic";
diff --git a/cognee-frontend/src/app/wizard/AddStep/AddStep.module.css b/cognee-frontend/src/app/wizard/AddStep/AddStep.module.css
deleted file mode 100644
index 8147acc28..000000000
--- a/cognee-frontend/src/app/wizard/AddStep/AddStep.module.css
+++ /dev/null
@@ -1,8 +0,0 @@
-.files {
- width: 100%;
- padding: 4px;
-}
-
-.fileSize {
- display: block;
-}
diff --git a/cognee-frontend/src/app/wizard/AddStep/AddStep.tsx b/cognee-frontend/src/app/wizard/AddStep/AddStep.tsx
deleted file mode 100644
index 6052ac52c..000000000
--- a/cognee-frontend/src/app/wizard/AddStep/AddStep.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { useCallback, useState } from 'react';
-import { CTAButton, GhostButton, Stack, Text, TrashIcon, UploadIcon, UploadInput, useBoolean } from 'ohmy-ui';
-import { Divider } from '@/ui/Layout';
-import addData from '@/modules/ingestion/addData';
-import { LoadingIndicator } from '@/ui/App';
-import styles from './AddStep.module.css';
-import { WizardHeading } from '@/ui/Partials/Wizard';
-
-interface ConfigStepProps {
- onNext: () => void;
-}
-
-export default function AddStep({ onNext }: ConfigStepProps) {
- const [files, setFiles] = useState([]);
-
- const {
- value: isUploading,
- setTrue: disableUploading,
- setFalse: enableUploading,
- } = useBoolean(false);
-
- const uploadFiles = useCallback(() => {
- disableUploading()
- addData({ name: 'main' }, files)
- .then(() => {
- onNext();
- })
- .finally(() => enableUploading());
- }, [disableUploading, enableUploading, files, onNext]);
-
- const addFiles = useCallback((files: File[]) => {
- setFiles((existingFiles) => {
- const newFiles = files.filter((file) => !existingFiles.some((existingFile) => existingFile.name === file.name));
-
- return [...existingFiles, ...newFiles]
- });
- }, []);
-
- const removeFile = useCallback((file: File) => {
- setFiles((files) => files.filter((f) => f !== file));
- }, []);
-
- return (
-
- Step 2/3 Add knowledge
-
-
- Cognee lets you process your personal data, books, articles or company data.
- Simply add datasets to get started.
-
-
-
-
-
- Upload your data
-
-
-
- {files.map((file, index) => (
-
-
- {file.name}
-
- {getBiggestUnitSize(file.size)}
-
-
- removeFile(file)}>
-
-
-
- ))}
-
-
-
-
-
- Next
- {isUploading && (
-
- )}
-
-
-
-
- )
-}
-
-function getBiggestUnitSize(sizeInBytes: number): string {
- const units = ['B', 'KB', 'MB', 'GB'];
-
- let i = 0;
- while (sizeInBytes >= 1024 && i < units.length - 1) {
- sizeInBytes /= 1024;
- i++;
- }
- return `${sizeInBytes.toFixed(2)} ${units[i]}`;
-}
diff --git a/cognee-frontend/src/app/wizard/AddStep/index.ts b/cognee-frontend/src/app/wizard/AddStep/index.ts
deleted file mode 100644
index 79a6cbdf5..000000000
--- a/cognee-frontend/src/app/wizard/AddStep/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './AddStep';
diff --git a/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx b/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx
deleted file mode 100644
index 7d6cdc0ae..000000000
--- a/cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import { useEffect, useRef } from 'react';
-import { CTAButton, Stack, Text, useBoolean } from 'ohmy-ui';
-import { Divider } from '@/ui/Layout';
-import { CognifyLoadingIndicator } from '@/ui/App';
-import { WizardHeading } from '@/ui/Partials/Wizard';
-import cognifyDataset from '@/modules/datasets/cognifyDataset';
-
-interface ConfigStepProps {
- onNext: () => void;
- dataset: { name: string }
-}
-
-export default function CognifyStep({ onNext, dataset }: ConfigStepProps) {
- const {
- value: isCognifyRunning,
- setFalse: stopCognifyIndicator,
- } = useBoolean(true);
- const cognifyPromise = useRef>()
-
- useEffect(() => {
- if (cognifyPromise.current) {
- return;
- }
-
- cognifyPromise.current = cognifyDataset(dataset)
- .then(() => {
- stopCognifyIndicator();
- });
- }, [stopCognifyIndicator, dataset]);
-
- return (
-
- Step 3/3 Cognify
-
-
-
-
-
-
-
- Cognee decomposes your data into facts and connects them in relevant clusters,
- so that you can navigate your knowledge better.
-
-
-
- Explore data
-
-
-
- )
-}
diff --git a/cognee-frontend/src/app/wizard/CognifyStep/index.ts b/cognee-frontend/src/app/wizard/CognifyStep/index.ts
deleted file mode 100644
index 7bf949986..000000000
--- a/cognee-frontend/src/app/wizard/CognifyStep/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './CognifyStep';
diff --git a/cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.module.css b/cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.module.css
deleted file mode 100644
index e69de29bb..000000000
diff --git a/cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.tsx b/cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.tsx
deleted file mode 100644
index 8b52b889a..000000000
--- a/cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Stack, Text } from 'ohmy-ui';
-import { Divider } from '@/ui/Layout';
-import Settings from '@/ui/Partials/SettingsModal/Settings';
-import { WizardContent, WizardHeading } from '@/ui/Partials/Wizard';
-
-interface ConfigStepProps {
- onNext: () => void;
-}
-
-export default function ConfigStep({ onNext }: ConfigStepProps) {
- return (
-
- Step 1/3 Basic configuration
-
-
- Cognee helps you process your data and create a mind-like structure you can explore.
- To get started you need an OpenAI API key.
-
-
-
- )
-}
diff --git a/cognee-frontend/src/app/wizard/ConfigStep/index.ts b/cognee-frontend/src/app/wizard/ConfigStep/index.ts
deleted file mode 100644
index beb48cc3d..000000000
--- a/cognee-frontend/src/app/wizard/ConfigStep/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './ConfigStep';
diff --git a/cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.tsx b/cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.tsx
deleted file mode 100644
index 8cc0e422a..000000000
--- a/cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Explorer } from '@/ui/Partials';
-import { Spacer } from 'ohmy-ui';
-
-interface ExploreStepProps {
- dataset: { name: string };
-}
-
-export default function ExploreStep({ dataset }: ExploreStepProps) {
- return (
-
-
-
- )
-}
diff --git a/cognee-frontend/src/app/wizard/ExploreStep/index.ts b/cognee-frontend/src/app/wizard/ExploreStep/index.ts
deleted file mode 100644
index f99c485ac..000000000
--- a/cognee-frontend/src/app/wizard/ExploreStep/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './ExploreStep';
diff --git a/cognee-frontend/src/app/wizard/WizardPage.module.css b/cognee-frontend/src/app/wizard/WizardPage.module.css
deleted file mode 100644
index c84021655..000000000
--- a/cognee-frontend/src/app/wizard/WizardPage.module.css
+++ /dev/null
@@ -1,13 +0,0 @@
-.main {
- display: flex;
- flex-direction: row;
- flex-direction: column;
- padding: 0;
- min-height: 100vh;
-}
-
-.wizardContainer {
- flex: 1;
- display: flex;
- padding: 24px 0;
-}
diff --git a/cognee-frontend/src/app/wizard/WizardPage.tsx b/cognee-frontend/src/app/wizard/WizardPage.tsx
deleted file mode 100644
index b8d064f4e..000000000
--- a/cognee-frontend/src/app/wizard/WizardPage.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-import { useState } from 'react';
-import { CloseIcon, GhostButton, Spacer, Stack, useBoolean } from 'ohmy-ui';
-import { TextLogo } from '@/ui/App';
-import { SettingsIcon } from '@/ui/Icons';
-import { Footer, SettingsModal } from '@/ui/Partials';
-import ConfigStep from './ConfigStep';
-import AddStep from './AddStep';
-import CognifyStep from './CognifyStep';
-import ExploreStep from './ExploreStep';
-import { WizardContent } from '@/ui/Partials/Wizard';
-
-import styles from './WizardPage.module.css';
-import { Divider } from '@/ui/Layout';
-import { useSearchParams } from 'next/navigation';
-
-interface WizardPageProps {
- onFinish: () => void;
-}
-
-export default function WizardPage({
- onFinish,
-}: WizardPageProps) {
- const searchParams = useSearchParams()
- const presetWizardStep = searchParams.get('step') as 'config';
- const [wizardStep, setWizardStep] = useState<'config' | 'add' | 'cognify' | 'explore'>(presetWizardStep || 'config');
- const {
- value: isSettingsModalOpen,
- setTrue: openSettingsModal,
- setFalse: closeSettingsModal,
- } = useBoolean(false);
-
- const dataset = { name: 'main' };
-
- return (
-
-
-
-
- {wizardStep === 'explore' && (
-
-
-
- )}
- {wizardStep === 'add' && (
-
-
-
- )}
-
-
-
-
-
- {wizardStep === 'config' && (
-
- setWizardStep('add')} />
-
- )}
-
- {wizardStep === 'add' && (
-
- setWizardStep('cognify')} />
-
- )}
-
- {wizardStep === 'cognify' && (
-
- setWizardStep('explore')} />
-
- )}
-
- {wizardStep === 'explore' && (
-
-
-
- )}
-
-
-
-
-
- )
-}
diff --git a/cognee-frontend/src/app/wizard/page.tsx b/cognee-frontend/src/app/wizard/page.tsx
deleted file mode 100644
index 7d6521e24..000000000
--- a/cognee-frontend/src/app/wizard/page.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-'use client';
-
-import { Suspense, useCallback } from 'react';
-import WizardPage from './WizardPage';
-
-export default function Page() {
- const finishWizard = useCallback(() => {
- window.location.href = '/';
- }, []);
-
- return (
-
-
-
- );
-}
diff --git a/cognee-frontend/src/middleware.ts b/cognee-frontend/src/middleware.ts
new file mode 100644
index 000000000..f53d88367
--- /dev/null
+++ b/cognee-frontend/src/middleware.ts
@@ -0,0 +1,29 @@
+import { NextResponse, type NextRequest } from "next/server";
+// import { auth0 } from "./modules/auth/auth0";
+
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export async function middleware(request: NextRequest) {
+ // if (process.env.USE_AUTH0_AUTHORIZATION?.toLowerCase() === "true") {
+ // if (request.nextUrl.pathname === "/auth/token") {
+ // return NextResponse.next();
+ // }
+
+ // const response: NextResponse = await auth0.middleware(request);
+
+ // return response;
+ // }
+
+ return NextResponse.next();
+}
+
+export const config = {
+ matcher: [
+ /*
+ * Match all request paths except for the ones starting with:
+ * - _next/static (static files)
+ * - _next/image (image optimization files)
+ * - favicon.ico, sitemap.xml, robots.txt (metadata files)
+ */
+ "/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)",
+ ],
+};
diff --git a/cognee-frontend/src/modules/auth/auth0.ts b/cognee-frontend/src/modules/auth/auth0.ts
new file mode 100644
index 000000000..0be0b3f1c
--- /dev/null
+++ b/cognee-frontend/src/modules/auth/auth0.ts
@@ -0,0 +1,8 @@
+import { Auth0Client } from "@auth0/nextjs-auth0/server";
+
+export const auth0 = new Auth0Client({
+ authorizationParameters: {
+ scope: "openid profile email",
+ audience: "cognee:api",
+ },
+});
diff --git a/cognee-frontend/src/modules/chat/getHistory.ts b/cognee-frontend/src/modules/chat/api/getHistory.ts
similarity index 67%
rename from cognee-frontend/src/modules/chat/getHistory.ts
rename to cognee-frontend/src/modules/chat/api/getHistory.ts
index dce914da7..9bab39cbb 100644
--- a/cognee-frontend/src/modules/chat/getHistory.ts
+++ b/cognee-frontend/src/modules/chat/api/getHistory.ts
@@ -1,8 +1,8 @@
-import { fetch } from '@/utils';
+import { fetch } from "@/utils";
export default function getHistory() {
return fetch(
- '/v1/search',
+ "/v1/search",
)
.then((response) => response.json());
}
diff --git a/cognee-frontend/src/modules/chat/hooks/useChat.ts b/cognee-frontend/src/modules/chat/hooks/useChat.ts
new file mode 100644
index 000000000..15f79f296
--- /dev/null
+++ b/cognee-frontend/src/modules/chat/hooks/useChat.ts
@@ -0,0 +1,123 @@
+import { v4 } from "uuid";
+import { useCallback, useState } from "react";
+import { fetch, useBoolean } from "@/utils";
+import { Dataset } from "@/modules/ingestion/useDatasets";
+
+interface ChatMessage {
+ id: string;
+ user: "user" | "system";
+ text: string;
+}
+
+const fetchMessages = () => {
+ return fetch("/v1/search/")
+ .then(response => response.json());
+};
+
+const sendMessage = (message: string, searchType: string) => {
+ return fetch("/v1/search/", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ query: message,
+ searchType,
+ datasets: ["main_dataset"],
+ }),
+ })
+ .then(response => response.json());
+};
+
+// Will be used in the future.
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
+export default function useChat(dataset: Dataset) {
+ const [messages, setMessages] = useState([]);
+
+ const {
+ value: isSearchRunning,
+ setTrue: disableSearchRun,
+ setFalse: enableSearchRun,
+ } = useBoolean(false);
+
+ const refreshChat = useCallback(async () => {
+ const data = await fetchMessages();
+ return setMessages(data);
+ }, []);
+
+ const handleMessageSending = useCallback((message: string, searchType: string) => {
+ const sentMessageId = v4();
+
+ setMessages((messages) => [
+ ...messages,
+ {
+ id: sentMessageId,
+ user: "user",
+ text: message,
+ },
+ ]);
+
+ disableSearchRun();
+
+ return sendMessage(message, searchType)
+ .then(newMessages => {
+ setMessages((messages) => [
+ ...messages,
+ ...newMessages.map((newMessage: string | []) => ({
+ id: v4(),
+ user: "system",
+ text: convertToSearchTypeOutput(newMessage, searchType),
+ })),
+ ]);
+ })
+ .catch(() => {
+ setMessages(
+ (messages) => messages.filter(message => message.id !== sentMessageId),
+ );
+ throw new Error("Failed to send message. Please try again. If the issue persists, please contact support.")
+ })
+ .finally(() => enableSearchRun());
+ }, [disableSearchRun, enableSearchRun]);
+
+ return {
+ messages,
+ refreshChat,
+ sendMessage: handleMessageSending,
+ isSearchRunning,
+ };
+}
+
+
+interface Node {
+ name: string;
+}
+
+interface Relationship {
+ relationship_name: string;
+}
+
+type InsightMessage = [Node, Relationship, Node];
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+function convertToSearchTypeOutput(systemMessage: any[] | any, searchType: string): string {
+ if (Array.isArray(systemMessage) && systemMessage.length === 1 && typeof(systemMessage[0]) === "string") {
+ return systemMessage[0];
+ }
+
+ switch (searchType) {
+ case "INSIGHTS":
+ return systemMessage.map((message: InsightMessage) => {
+ const [node1, relationship, node2] = message;
+ if (node1.name && node2.name) {
+ return `${node1.name} ${relationship.relationship_name} ${node2.name}.`;
+ }
+ return "";
+ }).join("\n");
+ case "SUMMARIES":
+ return systemMessage.map((message: { text: string }) => message.text).join("\n");
+ case "CHUNKS":
+ return systemMessage.map((message: { text: string }) => message.text).join("\n");
+ default:
+ return systemMessage;
+ }
+}
diff --git a/cognee-frontend/src/modules/datasets/cognifyDataset.ts b/cognee-frontend/src/modules/datasets/cognifyDataset.ts
index 09d9b85dc..7842334af 100644
--- a/cognee-frontend/src/modules/datasets/cognifyDataset.ts
+++ b/cognee-frontend/src/modules/datasets/cognifyDataset.ts
@@ -1,43 +1,58 @@
-import { fetch } from '@/utils';
+import { fetch } from "@/utils";
+import getDatasetGraph from "./getDatasetGraph";
+import { Dataset } from "../ingestion/useDatasets";
-export default function cognifyDataset(dataset: { id?: string, name?: string }, onUpdate = (data: []) => {}) {
- return fetch('/v1/cognify', {
- method: 'POST',
+interface GraphData {
+ nodes: { id: string; label: string; properties?: object }[];
+ edges: { source: string; target: string; label: string }[];
+}
+
+export default async function cognifyDataset(dataset: Dataset, onUpdate: (data: GraphData) => void) {
+ // const data = await (
+ return fetch("/v1/cognify", {
+ method: "POST",
headers: {
- 'Content-Type': 'application/json',
+ "Content-Type": "application/json",
},
body: JSON.stringify({
- datasets: [dataset.id || dataset.name],
+ datasetIds: [dataset.id],
+ runInBackground: false,
}),
})
- .then((response) => response.json())
- .then((data) => {
- const websocket = new WebSocket(`ws://localhost:8000/api/v1/cognify/subscribe/${data.pipeline_run_id}`);
-
- websocket.onopen = () => {
- websocket.send(JSON.stringify({
- "Authorization": `Bearer ${localStorage.getItem("access_token")}`,
- }));
- };
-
- let isCognifyDone = false;
-
- websocket.onmessage = (event) => {
- const data = JSON.parse(event.data);
- onUpdate(data);
-
- if (data.status === "PipelineRunCompleted") {
- isCognifyDone = true;
- websocket.close();
- }
- };
-
- return new Promise(async (resolve) => {
- while (!isCognifyDone) {
- await new Promise(resolve => setTimeout(resolve, 1000));
- }
-
- resolve(true);
+ .then((response) => response.json())
+ .then(() => {
+ return getDatasetGraph(dataset)
+ .then((data) => {
+ onUpdate({
+ nodes: data.nodes,
+ edges: data.edges,
+ });
});
- });
+ });
+ // )
+
+ // const websocket = new WebSocket(`ws://localhost:8000/api/v1/cognify/subscribe/${data.pipeline_run_id}`);
+
+ // let isCognifyDone = false;
+
+ // websocket.onmessage = (event) => {
+ // const data = JSON.parse(event.data);
+ // onUpdate?.({
+ // nodes: data.payload.nodes,
+ // edges: data.payload.edges,
+ // });
+
+ // if (data.status === "PipelineRunCompleted") {
+ // isCognifyDone = true;
+ // websocket.close();
+ // }
+ // };
+
+ // return new Promise(async (resolve) => {
+ // while (!isCognifyDone) {
+ // await new Promise(resolve => setTimeout(resolve, 1000));
+ // }
+
+ // resolve(true);
+ // });
}
diff --git a/cognee-frontend/src/modules/datasets/createDataset.ts b/cognee-frontend/src/modules/datasets/createDataset.ts
new file mode 100644
index 000000000..661240036
--- /dev/null
+++ b/cognee-frontend/src/modules/datasets/createDataset.ts
@@ -0,0 +1,12 @@
+import { fetch } from "@/utils";
+
+export default function createDataset(dataset: { name: string }) {
+ return fetch(`/v1/datasets/`, {
+ method: "POST",
+ body: JSON.stringify(dataset),
+ headers: {
+ "Content-Type": "application/json",
+ }
+ })
+ .then((response) => response.json());
+}
diff --git a/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts b/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts
index 2721e7b03..1483bf123 100644
--- a/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts
+++ b/cognee-frontend/src/modules/exploration/getExplorationGraphUrl.ts
@@ -1,6 +1,6 @@
import { fetch } from '@/utils';
-export default function getExplorationGraphUrl(dataset: { name: string }) {
+export default function getExplorationGraphUrl(/* dataset: { name: string } */) {
return fetch('/v1/visualize')
.then(async (response) => {
if (response.status !== 200) {
diff --git a/cognee-frontend/src/modules/ingestion/DataView/DataView.module.css b/cognee-frontend/src/modules/ingestion/DataView/DataView.module.css
deleted file mode 100644
index e79e63c31..000000000
--- a/cognee-frontend/src/modules/ingestion/DataView/DataView.module.css
+++ /dev/null
@@ -1,24 +0,0 @@
-
-.tableContainer {
- overflow: auto;
- padding-bottom: 32px;
- min-height: 300px;
-}
-
-.datasetMenu {
- background-color: var(--global-background-default);
- border-radius: var(--border-radius);
- padding: 4px;
-}
-
-.dataTable {
- color: white;
- border-collapse: collapse;
-}
-.dataTable td, .dataTable th {
- vertical-align: top;
- padding: 8px;
- border: 1px solid white;
- margin: 0;
- white-space: nowrap;
-}
diff --git a/cognee-frontend/src/modules/ingestion/DataView/DataView.tsx b/cognee-frontend/src/modules/ingestion/DataView/DataView.tsx
deleted file mode 100644
index b2cb06b44..000000000
--- a/cognee-frontend/src/modules/ingestion/DataView/DataView.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import { useCallback, useState } from 'react';
-import {
- DropdownMenu,
- GhostButton,
- Stack,
- Text,
- UploadInput,
- CloseIcon,
- CTAButton,
- useBoolean,
-} from "ohmy-ui";
-import { fetch } from '@/utils';
-import RawDataPreview from './RawDataPreview';
-import styles from "./DataView.module.css";
-
-export interface Data {
- id: string;
- name: string;
- mimeType: string;
- extension: string;
- rawDataLocation: string;
-}
-
-interface DatasetLike {
- id: string;
-}
-
-interface DataViewProps {
- data: Data[];
- datasetId: string;
- onClose: () => void;
- onDataAdd: (dataset: DatasetLike, files: File[]) => void;
- onCognify: () => Promise;
-}
-
-export default function DataView({ datasetId, data, onClose, onDataAdd, onCognify }: DataViewProps) {
- // const handleDataDelete = () => {};
- const [rawData, setRawData] = useState(null);
- const [selectedData, setSelectedData] = useState(null);
-
- const showRawData = useCallback((dataItem: Data) => {
- setSelectedData(dataItem);
-
- fetch(`/v1/datasets/${datasetId}/data/${dataItem.id}/raw`)
- .then((response) => response.arrayBuffer())
- .then(setRawData);
-
- document.body.click(); // Close the dropdown menu.
- }, [datasetId]);
-
- const resetDataPreview = useCallback(() => {
- setSelectedData(null);
- setRawData(null);
- }, []);
-
- const handleDataAdd = (files: File[]) => {
- onDataAdd({ id: datasetId }, files);
- };
-
- const {
- value: isCognifyButtonDisabled,
- setTrue: disableCognifyButton,
- setFalse: enableCognifyButton,
- } = useBoolean(false);
-
- const handleCognify = () => {
- disableCognifyButton();
- onCognify()
- .finally(() => enableCognifyButton());
- };
-
- return (
-
-
-
-
- Add data
-
-
-
-
- Cognify
-
-
-
-
-
-
- {rawData && selectedData && (
-
- )}
-
-
-
-
- | Actions |
- ID |
- Name |
- File path |
- MIME type |
-
-
-
- {data.map((dataItem) => (
-
- |
-
-
-
- showRawData(dataItem)}>
- View raw data
-
- {/*
- Delete
- */}
-
-
-
- |
-
- {dataItem.id}
- |
-
- {dataItem.name}.{dataItem.extension}
- |
-
- {dataItem.rawDataLocation}
- |
-
- {dataItem.mimeType}
- |
-
- ))}
-
-
-
-
- );
-}
diff --git a/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.module.css b/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.module.css
deleted file mode 100644
index 4cb3e63dd..000000000
--- a/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.module.css
+++ /dev/null
@@ -1,8 +0,0 @@
-
-.dataPreviewModal {
- left: 5% !important;
- padding: 0 !important;
- max-width: 90% !important;
- height: 80%;
- top: 5% !important;
-}
diff --git a/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx b/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx
deleted file mode 100644
index b9c2914ea..000000000
--- a/cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { IFrameView } from '@/ui/Partials';
-import { CloseIcon, GhostButton, Modal, Spacer, Stack, Text } from 'ohmy-ui';
-import styles from './RawDataPreview.module.css';
-
-interface RawDataPreviewProps {
- fileName: string;
- rawData: ArrayBuffer;
- onClose: () => void;
-}
-
-const file_header = ';headers=filename%3D';
-
-export default function RawDataPreview({ fileName, rawData, onClose }: RawDataPreviewProps) {
- const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', file_header + encodeURIComponent(fileName) + ';');
-
- return (
-
-
- {fileName}
-
-
-
- );
-}
-
-function arrayBufferToBase64(buffer: ArrayBuffer): string {
- let binary = '';
- const bytes = new Uint8Array(buffer);
- const len = bytes.byteLength;
-
- for (var i = 0; i < len; i++) {
- binary += String.fromCharCode( bytes[ i ] );
- }
-
- return window.btoa(binary);
-}
-
diff --git a/cognee-frontend/src/modules/ingestion/DataView/index.ts b/cognee-frontend/src/modules/ingestion/DataView/index.ts
deleted file mode 100644
index 5277720d5..000000000
--- a/cognee-frontend/src/modules/ingestion/DataView/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default, type Data } from './DataView';
diff --git a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.module.css b/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.module.css
deleted file mode 100644
index 6c982f2e6..000000000
--- a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.module.css
+++ /dev/null
@@ -1,16 +0,0 @@
-
-.datasetMenu {
- background-color: var(--global-background-default);
- border-radius: var(--border-radius);
- padding: 4px;
-}
-
-.explorerModal {
- left: 5% !important;
- padding: 0 !important;
- max-width: 90% !important;
- height: 80%;
- top: 5% !important;
- display: flex;
- flex-direction: column;
-}
diff --git a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx b/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx
deleted file mode 100644
index 7cfb43876..000000000
--- a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-import { useState } from 'react';
-import Link from 'next/link';
-import { Explorer } from '@/ui/Partials';
-import StatusIcon from '@/ui/elements/StatusIndicator';
-import { LoadingIndicator } from '@/ui/App';
-import { DropdownMenu, GhostButton, Stack, Text, CTAButton, useBoolean, Modal, Spacer } from "ohmy-ui";
-import styles from "./DatasetsView.module.css";
-
-interface Dataset {
- id: string;
- name: string;
- status: string;
-}
-
-const DatasetItem = GhostButton.remix({ Component: 'div' });
-
-interface DatasetsViewProps {
- datasets: Dataset[];
- onDatasetClick: (dataset: Dataset) => void;
- onDatasetCognify: (dataset: Dataset) => Promise;
-}
-
-export default function DatasetsView({
- datasets,
- onDatasetClick,
- onDatasetCognify,
-}: DatasetsViewProps) {
- const {
- value: isCognifyRunning,
- setTrue: disableCognifyRun,
- setFalse: enableCognifyRun,
- } = useBoolean(false);
-
- const handleCognifyDataset = (event: React.MouseEvent, dataset: Dataset) => {
- event.stopPropagation();
-
- disableCognifyRun();
-
- onDatasetCognify(dataset)
- .finally(() => enableCognifyRun());
- }
-
- const [dataset, setExplorationDataset] = useState<{ id: string, name: string } | null>(null);
- const {
- value: isExplorationWindowShown,
- setTrue: showExplorationWindow,
- setFalse: hideExplorationWindow,
- } = useBoolean(false);
-
- const handleExploreDataset = (event: React.MouseEvent, dataset: Dataset) => {
- event.stopPropagation();
-
- setExplorationDataset(dataset);
- showExplorationWindow();
- }
-
- return (
- <>
-
- {datasets.map((dataset) => (
- onDatasetClick(dataset)}>
-
- {dataset.name}
-
-
-
-
- {dataset.status === 'DATASET_PROCESSING_COMPLETED' ? (
- ) => handleExploreDataset(event, dataset)}
- >
- Explore
-
- ) : (
- ) => handleCognifyDataset(event, dataset)}
- >
-
- Cognify
- {isCognifyRunning && (
-
- )}
-
-
- )}
-
-
- Add data
-
-
-
-
-
-
-
- ))}
-
-
-
- {dataset?.name}
-
-
-
- >
- );
-}
diff --git a/cognee-frontend/src/modules/ingestion/DatasetsView/index.ts b/cognee-frontend/src/modules/ingestion/DatasetsView/index.ts
deleted file mode 100644
index a7381ff15..000000000
--- a/cognee-frontend/src/modules/ingestion/DatasetsView/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './DatasetsView';
diff --git a/cognee-frontend/src/modules/ingestion/addData.ts b/cognee-frontend/src/modules/ingestion/addData.ts
index 601c6f884..c4a1a84e1 100644
--- a/cognee-frontend/src/modules/ingestion/addData.ts
+++ b/cognee-frontend/src/modules/ingestion/addData.ts
@@ -1,19 +1,19 @@
-import { fetch } from '@/utils';
+import { fetch } from "@/utils";
export default function addData(dataset: { id?: string, name?: string }, files: File[]) {
const formData = new FormData();
files.forEach((file) => {
- formData.append('data', file, file.name);
+ formData.append("data", file, file.name);
})
if (dataset.id) {
- formData.append('datasetId', dataset.id);
+ formData.append("datasetId", dataset.id);
}
if (dataset.name) {
- formData.append('datasetName', dataset.name);
+ formData.append("datasetName", dataset.name);
}
- return fetch('/v1/add', {
- method: 'POST',
+ return fetch("/v1/add", {
+ method: "POST",
body: formData,
}).then((response) => response.json());
}
diff --git a/cognee-frontend/src/modules/ingestion/useDatasets.ts b/cognee-frontend/src/modules/ingestion/useDatasets.ts
index 441e3a0e3..165f4501c 100644
--- a/cognee-frontend/src/modules/ingestion/useDatasets.ts
+++ b/cognee-frontend/src/modules/ingestion/useDatasets.ts
@@ -12,16 +12,12 @@ export interface Dataset {
function useDatasets() {
const [datasets, setDatasets] = useState([]);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
const statusTimeout = useRef(null);
const fetchDatasetStatuses = useCallback((datasets: Dataset[]) => {
fetch(
`/v1/datasets/status?dataset=${datasets.map(d => d.id).join('&dataset=')}`,
- {
- headers: {
- Authorization: `Bearer ${localStorage.getItem('access_token')}`,
- },
- },
)
.then((response) => response.json())
.then((statuses) => setDatasets(
@@ -42,7 +38,7 @@ function useDatasets() {
statusTimeout.current = setTimeout(() => {
checkDatasetStatuses(datasets);
- }, 5000);
+ }, 50000);
}, [fetchDatasetStatuses]);
useEffect(() => {
@@ -73,11 +69,7 @@ function useDatasets() {
}, []);
const fetchDatasets = useCallback(() => {
- return fetch('/v1/datasets', {
- headers: {
- Authorization: `Bearer ${localStorage.getItem('access_token')}`,
- },
- })
+ return fetch('/v1/datasets')
.then((response) => response.json())
.then((datasets) => {
setDatasets(datasets);
diff --git a/cognee-frontend/src/ui/Icons/AddIcon.tsx b/cognee-frontend/src/ui/Icons/AddIcon.tsx
new file mode 100644
index 000000000..b9092feec
--- /dev/null
+++ b/cognee-frontend/src/ui/Icons/AddIcon.tsx
@@ -0,0 +1,7 @@
+export default function SearchIcon({ width = 24, height = 24, color = 'currentColor', className = '' }) {
+ return (
+
+ );
+}
diff --git a/cognee-frontend/src/ui/Icons/CaretIcon.tsx b/cognee-frontend/src/ui/Icons/CaretIcon.tsx
new file mode 100644
index 000000000..29a5eca62
--- /dev/null
+++ b/cognee-frontend/src/ui/Icons/CaretIcon.tsx
@@ -0,0 +1,8 @@
+export default function CaretIcon({ width = 50, height = 36, color = "currentColor", className = "" }) {
+ return (
+
+ );
+}
diff --git a/cognee-frontend/src/ui/Icons/SearchIcon.tsx b/cognee-frontend/src/ui/Icons/SearchIcon.tsx
new file mode 100644
index 000000000..3a3baac33
--- /dev/null
+++ b/cognee-frontend/src/ui/Icons/SearchIcon.tsx
@@ -0,0 +1,9 @@
+export default function SearchIcon({ width = 24, height = 24, color = 'currentColor', className = '' }) {
+ return (
+
+ );
+}
diff --git a/cognee-frontend/src/ui/Icons/index.ts b/cognee-frontend/src/ui/Icons/index.ts
index 71d6307c2..0adaa8fd1 100644
--- a/cognee-frontend/src/ui/Icons/index.ts
+++ b/cognee-frontend/src/ui/Icons/index.ts
@@ -1,3 +1,6 @@
+export { default as AddIcon } from './AddIcon';
+export { default as CaretIcon } from './CaretIcon';
+export { default as SearchIcon } from './SearchIcon';
export { default as DeleteIcon } from './DeleteIcon';
export { default as GithubIcon } from './GitHubIcon';
export { default as DiscordIcon } from './DiscordIcon';
diff --git a/cognee-frontend/src/ui/Partials/Explorer/Explorer.module.css b/cognee-frontend/src/ui/Partials/Explorer/Explorer.module.css
deleted file mode 100644
index 552e8eda3..000000000
--- a/cognee-frontend/src/ui/Partials/Explorer/Explorer.module.css
+++ /dev/null
@@ -1,21 +0,0 @@
-
-.explorer {
- flex: 1;
- min-height: 100%;
- flex-direction: column;
-}
-
-.explorerContent {
- flex: 1;
-}
-
-.graphExplorer {
- width: 65%;
- overflow: hidden;
- border-radius: var(--border-radius);
-}
-
-.chat {
- width: 35%;
- display: flex;
-}
diff --git a/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx b/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx
deleted file mode 100644
index cc9759ee6..000000000
--- a/cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx
+++ /dev/null
@@ -1,61 +0,0 @@
-import classNames from 'classnames';
-import { useCallback, useEffect, useState } from 'react';
-import { Spacer, Stack, Text } from 'ohmy-ui';
-import { LoadingIndicator } from '@/ui/App';
-import { IFrameView, SearchView } from '@/ui/Partials';
-import { getExplorationGraphUrl } from '@/modules/exploration';
-import styles from './Explorer.module.css';
-
-interface ExplorerProps {
- dataset: { name: string };
- className?: string;
- style?: React.CSSProperties;
-}
-
-export default function Explorer({ dataset, className, style }: ExplorerProps) {
- const [error, setError] = useState(null);
- const [graphHtml, setGraphHtml] = useState(null);
-
- const exploreData = useCallback(() => {
- getExplorationGraphUrl(dataset)
- .then((graphHtml) => {
- setError(null);
- setGraphHtml(graphHtml);
- })
- .catch((error) => {
- setError(error);
- });
- }, [dataset]);
-
- useEffect(() => {
- exploreData();
- }, [exploreData]);
-
- return (
-
-
- {error ? (
- {error.message}
- ) : (
- <>
- {!graphHtml ? (
-
-
-
- ) : (
-
- )}
- >
- )}
-
-
-
-
-
- )
-}
diff --git a/cognee-frontend/src/ui/Partials/FeedbackForm.tsx b/cognee-frontend/src/ui/Partials/FeedbackForm.tsx
index 76ecebf43..db5b6f325 100644
--- a/cognee-frontend/src/ui/Partials/FeedbackForm.tsx
+++ b/cognee-frontend/src/ui/Partials/FeedbackForm.tsx
@@ -26,19 +26,22 @@ export default function FeedbackForm({ onSuccess }: FeedbackFormProps) {
event.preventDefault();
const formElements = event.currentTarget;
- const authCredentials = new FormData();
- authCredentials.append("feedback", formElements.feedback.value);
-
setFeedbackError(null);
disableFeedbackSubmit();
- fetch("/v1/feedback/reasoning", {
+ fetch("/v1/crewai/feedback", {
method: "POST",
- body: authCredentials,
+ body: JSON.stringify({
+ feedback: formElements.feedback.value,
+ }),
+ headers: {
+ "Content-Type": "application/json",
+ },
})
.then(response => response.json())
.then(() => {
onSuccess();
+ formElements.feedback.value = "";
})
.catch(error => setFeedbackError(error.detail))
.finally(() => enableFeedbackSubmit());
@@ -48,7 +51,7 @@ export default function FeedbackForm({ onSuccess }: FeedbackFormProps) {