Skip to content

Commit fe0a4cb

Browse files
fix: default user (topoteretes#908)
<!-- .github/pull_request_template.md --> ## 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 <[email protected]>
1 parent c09750b commit fe0a4cb

File tree

6 files changed

+57
-15
lines changed

6 files changed

+57
-15
lines changed

alembic/versions/482cd6517ce4_add_default_user.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
from cognee.modules.users.methods import create_default_user, delete_user
1414

15+
from fastapi_users.exceptions import UserAlreadyExists
16+
1517

1618
# revision identifiers, used by Alembic.
1719
revision: str = "482cd6517ce4"
@@ -21,7 +23,10 @@
2123

2224

2325
def upgrade() -> None:
24-
await_only(create_default_user())
26+
try:
27+
await_only(create_default_user())
28+
except UserAlreadyExists:
29+
pass # It's fine if the default user already exists
2530

2631

2732
def downgrade() -> None:

cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ export default function DatasetsView({
9595
</DatasetItem>
9696
))}
9797
</Stack>
98-
<Modal onClose={hideExplorationWindow} isOpen={isExplorationWindowShown} className={styles.explorerModal}>
98+
<Modal closeOnBackdropClick={false} onClose={hideExplorationWindow} isOpen={isExplorationWindowShown} className={styles.explorerModal}>
9999
<Spacer horizontal="2" vertical="3" wrap>
100100
<Text>{dataset?.name}</Text>
101-
</Spacer>
101+
</Spacer>
102102
<Explorer dataset={dataset!} />
103103
</Modal>
104104
</>

cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { v4 } from 'uuid';
44
import classNames from 'classnames';
55
import { useCallback, useEffect, useState } from 'react';
6-
import { CTAButton, Stack, Text, DropdownSelect, TextArea, useBoolean } from 'ohmy-ui';
6+
import { CTAButton, Stack, Text, DropdownSelect, TextArea, useBoolean, Input } from 'ohmy-ui';
77
import { fetch } from '@/utils';
88
import styles from './SearchView.module.css';
99
import getHistory from '@/modules/chat/getHistory';
@@ -33,8 +33,15 @@ export default function SearchView() {
3333
}, {
3434
value: 'RAG_COMPLETION',
3535
label: 'Completion using RAG',
36+
}, {
37+
value: 'GRAPH_COMPLETION_COT',
38+
label: 'Cognee\'s Chain of Thought search',
39+
}, {
40+
value: 'GRAPH_COMPLETION_CONTEXT_EXTENSION',
41+
label: 'Cognee\'s Multi-Hop search',
3642
}];
3743
const [searchType, setSearchType] = useState(searchOptions[0]);
44+
const [rangeValue, setRangeValue] = useState(10);
3845

3946
const scrollToBottom = useCallback(() => {
4047
setTimeout(() => {
@@ -90,6 +97,7 @@ export default function SearchView() {
9097
body: JSON.stringify({
9198
query: inputValue.trim(),
9299
searchType: searchTypeValue,
100+
topK: rangeValue,
93101
}),
94102
})
95103
.then((response) => response.json())
@@ -108,7 +116,7 @@ export default function SearchView() {
108116
.catch(() => {
109117
setInputValue(inputValue);
110118
});
111-
}, [inputValue, scrollToBottom, searchType.value]);
119+
}, [inputValue, rangeValue, scrollToBottom, searchType.value]);
112120

113121
const {
114122
value: isInputExpanded,
@@ -122,6 +130,10 @@ export default function SearchView() {
122130
}
123131
};
124132

133+
const handleRangeValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
134+
setRangeValue(parseInt(event.target.value));
135+
};
136+
125137
return (
126138
<Stack className={styles.searchViewContainer}>
127139
<DropdownSelect<SelectOption>
@@ -146,9 +158,15 @@ export default function SearchView() {
146158
</Stack>
147159
</div>
148160
<form onSubmit={handleSearchSubmit}>
149-
<Stack orientation="horizontal" align="end/" gap="2">
161+
<Stack orientation="vertical" gap="2">
150162
<TextArea onKeyUp={handleSubmitOnEnter} style={{ transition: 'height 0.3s ease', height: isInputExpanded ? '128px' : '38px' }} onFocus={expandInput} onBlur={contractInput} value={inputValue} onChange={handleInputChange} name="searchInput" placeholder="Search" />
151-
<CTAButton hugContent type="submit">Search</CTAButton>
163+
<Stack orientation="horizontal" gap="between">
164+
<Stack orientation="horizontal" gap="2" align="center">
165+
<label><Text>Search range: </Text></label>
166+
<Input style={{ maxWidth: "90px" }} value={rangeValue} onChange={handleRangeValueChange} type="number" />
167+
</Stack>
168+
<CTAButton hugContent type="submit">Search</CTAButton>
169+
</Stack>
152170
</Stack>
153171
</form>
154172
</Stack>

cognee-frontend/tsconfig.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"compilerOptions": {
3-
"lib": ["dom", "dom.iterable", "esnext"],
3+
"lib": [
4+
"dom",
5+
"dom.iterable",
6+
"esnext"
7+
],
48
"allowJs": true,
59
"skipLibCheck": true,
610
"strict": true,
@@ -18,9 +22,19 @@
1822
}
1923
],
2024
"paths": {
21-
"@/*": ["./src/*"]
22-
}
25+
"@/*": [
26+
"./src/*"
27+
]
28+
},
29+
"target": "ES2017"
2330
},
24-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
25-
"exclude": ["node_modules"]
31+
"include": [
32+
"next-env.d.ts",
33+
"**/*.ts",
34+
"**/*.tsx",
35+
".next/types/**/*.ts"
36+
],
37+
"exclude": [
38+
"node_modules"
39+
]
2640
}

cognee/api/v1/search/routers/get_search_router.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Optional
12
from uuid import UUID
23
from datetime import datetime
34
from fastapi import Depends, APIRouter
@@ -12,6 +13,7 @@
1213
class SearchPayloadDTO(InDTO):
1314
search_type: SearchType
1415
query: str
16+
top_k: Optional[int] = 10
1517

1618

1719
def get_search_router() -> APIRouter:
@@ -39,7 +41,10 @@ async def search(payload: SearchPayloadDTO, user: User = Depends(get_authenticat
3941

4042
try:
4143
results = await cognee_search(
42-
query_text=payload.query, query_type=payload.search_type, user=user
44+
query_text=payload.query,
45+
query_type=payload.search_type,
46+
user=user,
47+
top_k=payload.top_k,
4348
)
4449

4550
return results

entrypoint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ echo "Environment: $ENVIRONMENT"
1414
# smooth redeployments and container restarts while maintaining data integrity.
1515
echo "Running database migrations..."
1616

17-
MIGRATION_OUTPUT=$(alembic upgrade head 2>&1)
17+
MIGRATION_OUTPUT=$(alembic upgrade head)
1818
MIGRATION_EXIT_CODE=$?
1919

2020
if [[ $MIGRATION_EXIT_CODE -ne 0 ]]; then
@@ -42,5 +42,5 @@ if [ "$ENVIRONMENT" = "dev" ] || [ "$ENVIRONMENT" = "local" ]; then
4242
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app
4343
fi
4444
else
45-
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app
45+
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app
4646
fi

0 commit comments

Comments
 (0)