fix: default user (#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 <borisarzentar@gmail.com>
This commit is contained in:
parent
c09750b7c6
commit
fe0a4cb702
6 changed files with 57 additions and 15 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ export default function DatasetsView({
|
|||
</DatasetItem>
|
||||
))}
|
||||
</Stack>
|
||||
<Modal onClose={hideExplorationWindow} isOpen={isExplorationWindowShown} className={styles.explorerModal}>
|
||||
<Modal closeOnBackdropClick={false} onClose={hideExplorationWindow} isOpen={isExplorationWindowShown} className={styles.explorerModal}>
|
||||
<Spacer horizontal="2" vertical="3" wrap>
|
||||
<Text>{dataset?.name}</Text>
|
||||
</Spacer>
|
||||
</Spacer>
|
||||
<Explorer dataset={dataset!} />
|
||||
</Modal>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -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<HTMLInputElement>) => {
|
||||
setRangeValue(parseInt(event.target.value));
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack className={styles.searchViewContainer}>
|
||||
<DropdownSelect<SelectOption>
|
||||
|
|
@ -146,9 +158,15 @@ export default function SearchView() {
|
|||
</Stack>
|
||||
</div>
|
||||
<form onSubmit={handleSearchSubmit}>
|
||||
<Stack orientation="horizontal" align="end/" gap="2">
|
||||
<Stack orientation="vertical" gap="2">
|
||||
<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" />
|
||||
<CTAButton hugContent type="submit">Search</CTAButton>
|
||||
<Stack orientation="horizontal" gap="between">
|
||||
<Stack orientation="horizontal" gap="2" align="center">
|
||||
<label><Text>Search range: </Text></label>
|
||||
<Input style={{ maxWidth: "90px" }} value={rangeValue} onChange={handleRangeValueChange} type="number" />
|
||||
</Stack>
|
||||
<CTAButton hugContent type="submit">Search</CTAButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</form>
|
||||
</Stack>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
|
|
@ -18,9 +22,19 @@
|
|||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
"@/*": [
|
||||
"./src/*"
|
||||
]
|
||||
},
|
||||
"target": "ES2017"
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from typing import Optional
|
||||
from uuid import UUID
|
||||
from datetime import datetime
|
||||
from fastapi import Depends, APIRouter
|
||||
|
|
@ -12,6 +13,7 @@ from cognee.modules.users.methods import get_authenticated_user
|
|||
class SearchPayloadDTO(InDTO):
|
||||
search_type: SearchType
|
||||
query: str
|
||||
top_k: Optional[int] = 10
|
||||
|
||||
|
||||
def get_search_router() -> APIRouter:
|
||||
|
|
@ -39,7 +41,10 @@ def get_search_router() -> APIRouter:
|
|||
|
||||
try:
|
||||
results = await cognee_search(
|
||||
query_text=payload.query, query_type=payload.search_type, user=user
|
||||
query_text=payload.query,
|
||||
query_type=payload.search_type,
|
||||
user=user,
|
||||
top_k=payload.top_k,
|
||||
)
|
||||
|
||||
return results
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ echo "Environment: $ENVIRONMENT"
|
|||
# smooth redeployments and container restarts while maintaining data integrity.
|
||||
echo "Running database migrations..."
|
||||
|
||||
MIGRATION_OUTPUT=$(alembic upgrade head 2>&1)
|
||||
MIGRATION_OUTPUT=$(alembic upgrade head)
|
||||
MIGRATION_EXIT_CODE=$?
|
||||
|
||||
if [[ $MIGRATION_EXIT_CODE -ne 0 ]]; then
|
||||
|
|
@ -42,5 +42,5 @@ if [ "$ENVIRONMENT" = "dev" ] || [ "$ENVIRONMENT" = "local" ]; then
|
|||
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app
|
||||
fi
|
||||
else
|
||||
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app
|
||||
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level error cognee.api.client:app
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue