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 cognee.modules.users.methods import create_default_user, delete_user
|
||||||
|
|
||||||
|
from fastapi_users.exceptions import UserAlreadyExists
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision: str = "482cd6517ce4"
|
revision: str = "482cd6517ce4"
|
||||||
|
|
@ -21,7 +23,10 @@ depends_on: Union[str, Sequence[str], None] = "8057ae7329c2"
|
||||||
|
|
||||||
|
|
||||||
def upgrade() -> None:
|
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:
|
def downgrade() -> None:
|
||||||
|
|
|
||||||
|
|
@ -95,10 +95,10 @@ export default function DatasetsView({
|
||||||
</DatasetItem>
|
</DatasetItem>
|
||||||
))}
|
))}
|
||||||
</Stack>
|
</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>
|
<Spacer horizontal="2" vertical="3" wrap>
|
||||||
<Text>{dataset?.name}</Text>
|
<Text>{dataset?.name}</Text>
|
||||||
</Spacer>
|
</Spacer>
|
||||||
<Explorer dataset={dataset!} />
|
<Explorer dataset={dataset!} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useCallback, useEffect, useState } from 'react';
|
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 { fetch } from '@/utils';
|
||||||
import styles from './SearchView.module.css';
|
import styles from './SearchView.module.css';
|
||||||
import getHistory from '@/modules/chat/getHistory';
|
import getHistory from '@/modules/chat/getHistory';
|
||||||
|
|
@ -33,8 +33,15 @@ export default function SearchView() {
|
||||||
}, {
|
}, {
|
||||||
value: 'RAG_COMPLETION',
|
value: 'RAG_COMPLETION',
|
||||||
label: 'Completion using RAG',
|
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 [searchType, setSearchType] = useState(searchOptions[0]);
|
||||||
|
const [rangeValue, setRangeValue] = useState(10);
|
||||||
|
|
||||||
const scrollToBottom = useCallback(() => {
|
const scrollToBottom = useCallback(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
@ -90,6 +97,7 @@ export default function SearchView() {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
query: inputValue.trim(),
|
query: inputValue.trim(),
|
||||||
searchType: searchTypeValue,
|
searchType: searchTypeValue,
|
||||||
|
topK: rangeValue,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
|
|
@ -108,7 +116,7 @@ export default function SearchView() {
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
setInputValue(inputValue);
|
setInputValue(inputValue);
|
||||||
});
|
});
|
||||||
}, [inputValue, scrollToBottom, searchType.value]);
|
}, [inputValue, rangeValue, scrollToBottom, searchType.value]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
value: isInputExpanded,
|
value: isInputExpanded,
|
||||||
|
|
@ -122,6 +130,10 @@ export default function SearchView() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRangeValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
setRangeValue(parseInt(event.target.value));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className={styles.searchViewContainer}>
|
<Stack className={styles.searchViewContainer}>
|
||||||
<DropdownSelect<SelectOption>
|
<DropdownSelect<SelectOption>
|
||||||
|
|
@ -146,9 +158,15 @@ export default function SearchView() {
|
||||||
</Stack>
|
</Stack>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={handleSearchSubmit}>
|
<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" />
|
<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>
|
</Stack>
|
||||||
</form>
|
</form>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|
@ -18,9 +22,19 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": [
|
||||||
}
|
"./src/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"target": "ES2017"
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
"include": [
|
||||||
"exclude": ["node_modules"]
|
"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 uuid import UUID
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from fastapi import Depends, APIRouter
|
from fastapi import Depends, APIRouter
|
||||||
|
|
@ -12,6 +13,7 @@ from cognee.modules.users.methods import get_authenticated_user
|
||||||
class SearchPayloadDTO(InDTO):
|
class SearchPayloadDTO(InDTO):
|
||||||
search_type: SearchType
|
search_type: SearchType
|
||||||
query: str
|
query: str
|
||||||
|
top_k: Optional[int] = 10
|
||||||
|
|
||||||
|
|
||||||
def get_search_router() -> APIRouter:
|
def get_search_router() -> APIRouter:
|
||||||
|
|
@ -39,7 +41,10 @@ def get_search_router() -> APIRouter:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results = await cognee_search(
|
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
|
return results
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ echo "Environment: $ENVIRONMENT"
|
||||||
# smooth redeployments and container restarts while maintaining data integrity.
|
# smooth redeployments and container restarts while maintaining data integrity.
|
||||||
echo "Running database migrations..."
|
echo "Running database migrations..."
|
||||||
|
|
||||||
MIGRATION_OUTPUT=$(alembic upgrade head 2>&1)
|
MIGRATION_OUTPUT=$(alembic upgrade head)
|
||||||
MIGRATION_EXIT_CODE=$?
|
MIGRATION_EXIT_CODE=$?
|
||||||
|
|
||||||
if [[ $MIGRATION_EXIT_CODE -ne 0 ]]; then
|
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
|
gunicorn -w 3 -k uvicorn.workers.UvicornWorker -t 30000 --bind=0.0.0.0:8000 --log-level debug --reload cognee.api.client:app
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue