From fe0a4cb702ec7e088ab9c21bc00cf9fbfffeed0c Mon Sep 17 00:00:00 2001 From: Igor Ilic <30923996+dexters1@users.noreply.github.com> Date: Thu, 5 Jun 2025 15:38:06 +0200 Subject: [PATCH] fix: default user (#908) ## Description Resolve user already exist issue for UI ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin. --------- Co-authored-by: Boris Arzentar --- .../versions/482cd6517ce4_add_default_user.py | 7 ++++- .../ingestion/DatasetsView/DatasetsView.tsx | 4 +-- .../src/ui/Partials/SearchView/SearchView.tsx | 26 ++++++++++++++++--- cognee-frontend/tsconfig.json | 24 +++++++++++++---- .../v1/search/routers/get_search_router.py | 7 ++++- entrypoint.sh | 4 +-- 6 files changed, 57 insertions(+), 15 deletions(-) diff --git a/alembic/versions/482cd6517ce4_add_default_user.py b/alembic/versions/482cd6517ce4_add_default_user.py index 92429e1e4..d85f0f146 100644 --- a/alembic/versions/482cd6517ce4_add_default_user.py +++ b/alembic/versions/482cd6517ce4_add_default_user.py @@ -12,6 +12,8 @@ from sqlalchemy.util import await_only from cognee.modules.users.methods import create_default_user, delete_user +from fastapi_users.exceptions import UserAlreadyExists + # revision identifiers, used by Alembic. revision: str = "482cd6517ce4" @@ -21,7 +23,10 @@ depends_on: Union[str, Sequence[str], None] = "8057ae7329c2" def upgrade() -> None: - await_only(create_default_user()) + try: + await_only(create_default_user()) + except UserAlreadyExists: + pass # It's fine if the default user already exists def downgrade() -> None: diff --git a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx b/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx index 13965230b..577a27d63 100644 --- a/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx +++ b/cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx @@ -95,10 +95,10 @@ export default function DatasetsView({ ))} - + {dataset?.name} - + diff --git a/cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx b/cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx index 664a46fad..bea5e1277 100644 --- a/cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx +++ b/cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx @@ -3,7 +3,7 @@ import { v4 } from 'uuid'; import classNames from 'classnames'; import { useCallback, useEffect, useState } from 'react'; -import { CTAButton, Stack, Text, DropdownSelect, TextArea, useBoolean } from 'ohmy-ui'; +import { CTAButton, Stack, Text, DropdownSelect, TextArea, useBoolean, Input } from 'ohmy-ui'; import { fetch } from '@/utils'; import styles from './SearchView.module.css'; import getHistory from '@/modules/chat/getHistory'; @@ -33,8 +33,15 @@ export default function SearchView() { }, { value: 'RAG_COMPLETION', label: 'Completion using RAG', + }, { + value: 'GRAPH_COMPLETION_COT', + label: 'Cognee\'s Chain of Thought search', + }, { + value: 'GRAPH_COMPLETION_CONTEXT_EXTENSION', + label: 'Cognee\'s Multi-Hop search', }]; const [searchType, setSearchType] = useState(searchOptions[0]); + const [rangeValue, setRangeValue] = useState(10); const scrollToBottom = useCallback(() => { setTimeout(() => { @@ -90,6 +97,7 @@ export default function SearchView() { body: JSON.stringify({ query: inputValue.trim(), searchType: searchTypeValue, + topK: rangeValue, }), }) .then((response) => response.json()) @@ -108,7 +116,7 @@ export default function SearchView() { .catch(() => { setInputValue(inputValue); }); - }, [inputValue, scrollToBottom, searchType.value]); + }, [inputValue, rangeValue, scrollToBottom, searchType.value]); const { value: isInputExpanded, @@ -122,6 +130,10 @@ export default function SearchView() { } }; + const handleRangeValueChange = (event: React.ChangeEvent) => { + setRangeValue(parseInt(event.target.value)); + }; + return ( @@ -146,9 +158,15 @@ export default function SearchView() {
- +