Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: frontend redesign #97

Merged
merged 3 commits into from
May 27, 2024
Merged

feat: frontend redesign #97

merged 3 commits into from
May 27, 2024

Conversation

borisarzentar
Copy link
Contributor

No description provided.

@borisarzentar borisarzentar self-assigned this May 26, 2024
Copy link

gitguardian bot commented May 26, 2024

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
9573981 Triggered Generic Password f065a63 cognee/config.py View secret
9573981 Triggered Generic Password f065a63 cognee/infrastructure/databases/relational/config.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@borisarzentar borisarzentar changed the title Feat/frontend redesign feat: frontend redesign May 26, 2024
Copy link
Contributor

coderabbitai bot commented May 26, 2024

Walkthrough

The recent updates to the cognee-frontend project introduce several new components, refine existing ones, and adjust CSS styling across various modules. Key changes include the addition of new wizard steps for dataset management, new UI components like Divider and WizardHeading, and modifications to the layout and appearance of elements for improved user experience. The backend saw minor updates, such as adding type hints in the API client.

Changes

File(s) Change Summary
cognee-frontend/src/app/globals.css Modified --border-radius from 12px to 2px.
cognee-frontend/src/app/page.module.css Removed padding: 32px; from .main class.
cognee-frontend/src/app/page.tsx Added new imports, removed functions, and introduced state for settings modal.
cognee-frontend/src/app/wizard/AddStep/... Introduced new AddStep component and related styles.
cognee-frontend/src/app/wizard/CognifyStep/... Added new CognifyStep component for dataset processing.
cognee-frontend/src/app/wizard/ConfigStep/... Added new ConfigStep component for configuration settings.
cognee-frontend/src/app/wizard/ExploreStep/... Added new ExploreStep component and related styles.
cognee-frontend/src/app/wizard/WizardPage.tsx Refactored wizard step handling and data processing logic.
cognee-frontend/src/modules/exploration/index.ts Exported getExplorationGraphUrl.
cognee-frontend/src/modules/ingestion/DataView/... Commented out handleDataDelete function, added dropdown close logic, and adjusted GhostButton props.
cognee-frontend/src/ui/App/Loading/... Introduced new loading indicators and updated existing ones.
cognee-frontend/src/ui/App/Logo/TextLogo.v1.tsx Removed trailing whitespace.
cognee-frontend/src/ui/App/Logo/TextLogo.v2.tsx Added new TextLogo component with SVG rendering.
cognee-frontend/src/ui/App/index.ts Added new exports for various components.
cognee-frontend/src/ui/Icons/SettingsIcon.tsx Modified default values for SVG rendering.
cognee-frontend/src/ui/Layout/Divider/... Added new Divider component and styles.
cognee-frontend/src/ui/Partials/Explorer/... Introduced new Explorer component and related styles.
cognee-frontend/src/ui/Partials/Footer/Footer.tsx Commented out TextLogo import and usage.
cognee-frontend/src/ui/Partials/Wizard/... Added WizardHeading component and updated exports.
cognee/api/client.py Added Literal type hint and modified return structure in get_dataset_status.

In the code where data flows,
New components bloom and grow.
Wizards guide with steps so clear,
Loading spinners bring good cheer.
Explore, cognify, and configure with ease,
Our frontend now aims to please.
A rabbit's touch in every line,
Makes our project truly shine. 🌟🐇


Tip

Early Access Features
  • gpt-4o model for chat

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 10

Outside diff range and nitpick comments (9)
cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx (1)

Line range hint 31-31: Replace var with let for better scoping rules.

- for (var i = 0; i < len; i++) {
+ for (let i = 0; i < len; i++) {
cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx (1)

Line range hint 18-111: Optimize key usage in React lists.

Using the index of an array as a key in React can lead to issues with rendering and state updates, especially if the order of items changes. It's better to use unique identifiers.

- <Stack gap="between" orientation="horizontal" align="center/" key={index}>
+ <Stack gap="between" orientation="horizontal" align="center/" key={message.id}>
- <div key={index}>
+ <div key={message.id}>
cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx (1)

Line range hint 43-103: Remove the non-null assertion in line 102 to prevent potential runtime errors. Consider checking for null or providing default values before using the dataset.

cognee-frontend/src/app/page.tsx (1)

Line range hint 5-105: 1. Consider renaming the DataView import to avoid shadowing the global DataView property.
2. Ensure that all dependencies are specified in the dependency array for the useEffect hook to avoid subtle bugs.

cognee/infrastructure/databases/relational/duckdb/DuckDBAdapter.py (1)

Line range hint 1-72: Consider parameterizing the SQL queries to mitigate SQL injection risks. This practice enhances security by preventing malicious SQL code execution.

cognee/infrastructure/InfrastructureConfig.py (1)

Line range hint 48-48: Refactor get_config method to reduce complexity and improve readability.

Consider using a dictionary to map configuration keys to their default values and methods, simplifying the conditional logic.

cognee-frontend/src/ui/App/Logo/TextLogo.v1.tsx (1)

Line range hint 3-3: Add an accessible title to the SVG for better accessibility.

+ <title>Company Logo</title>
cognee/api/client.py (1)

Line range hint 21-21: Move the module level import to the top of the file to adhere to Python's PEP 8 style guide.

- from cognee.config import Config
+ from cognee.config import Config
cognee/api/v1/cognify/cognify.py (1)

Line range hint 224-224: Avoid using a bare except to handle exceptions.

- except:
+ except Exception as e:
+     logger.error(f"An error occurred: {e}")
Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 372f23a and ff743e1.
Files ignored due to path filters (2)
  • cognee-frontend/package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • cognee-frontend/package.json is excluded by !**/*.json
Files selected for processing (54)
  • cognee-frontend/src/app/globals.css (1 hunks)
  • cognee-frontend/src/app/page.module.css (1 hunks)
  • cognee-frontend/src/app/page.tsx (2 hunks)
  • cognee-frontend/src/app/wizard/AddStep/AddStep.module.css (1 hunks)
  • cognee-frontend/src/app/wizard/AddStep/AddStep.tsx (1 hunks)
  • cognee-frontend/src/app/wizard/AddStep/index.ts (1 hunks)
  • cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx (1 hunks)
  • cognee-frontend/src/app/wizard/CognifyStep/index.ts (1 hunks)
  • cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.tsx (1 hunks)
  • cognee-frontend/src/app/wizard/ConfigStep/index.ts (1 hunks)
  • cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.module.css (1 hunks)
  • cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.tsx (1 hunks)
  • cognee-frontend/src/app/wizard/ExploreStep/index.ts (1 hunks)
  • cognee-frontend/src/app/wizard/WizardPage.module.css (1 hunks)
  • cognee-frontend/src/app/wizard/WizardPage.tsx (1 hunks)
  • cognee-frontend/src/app/wizard/page.tsx (1 hunks)
  • cognee-frontend/src/modules/exploration/index.ts (1 hunks)
  • cognee-frontend/src/modules/ingestion/DataView/DataView.tsx (3 hunks)
  • cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.module.css (1 hunks)
  • cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx (2 hunks)
  • cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.module.css (1 hunks)
  • cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx (4 hunks)
  • cognee-frontend/src/ui/App/Loading/CognifyLoadingIndicator/CognifyLoadingIndicator.module.css (1 hunks)
  • cognee-frontend/src/ui/App/Loading/CognifyLoadingIndicator/CognifyLoadingIndicator.tsx (1 hunks)
  • cognee-frontend/src/ui/App/Loading/DefaultLoadingIndicator/LoadingIndicator.module.css (1 hunks)
  • cognee-frontend/src/ui/App/Logo/TextLogo.v1.tsx (1 hunks)
  • cognee-frontend/src/ui/App/Logo/TextLogo.v2.tsx (1 hunks)
  • cognee-frontend/src/ui/App/index.ts (1 hunks)
  • cognee-frontend/src/ui/Icons/SettingsIcon.tsx (1 hunks)
  • cognee-frontend/src/ui/Layout/Divider/Divider.module.css (1 hunks)
  • cognee-frontend/src/ui/Layout/Divider/Divider.tsx (1 hunks)
  • cognee-frontend/src/ui/Layout/index.ts (1 hunks)
  • cognee-frontend/src/ui/Partials/Explorer/Explorer.module.css (1 hunks)
  • cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/Footer/Footer.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/IFrameView/IFrameView.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/SearchView/SearchView.module.css (1 hunks)
  • cognee-frontend/src/ui/Partials/SearchView/SearchView.tsx (2 hunks)
  • cognee-frontend/src/ui/Partials/SettingsModal/Settings.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/SettingsModal/SettingsModal.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/Wizard/WizardContent/WizardContent.module.css (1 hunks)
  • cognee-frontend/src/ui/Partials/Wizard/WizardContent/WizardContent.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/Wizard/WizardHeading.tsx (1 hunks)
  • cognee-frontend/src/ui/Partials/Wizard/index.ts (1 hunks)
  • cognee-frontend/src/ui/Partials/index.ts (1 hunks)
  • cognee/api/client.py (2 hunks)
  • cognee/api/v1/cognify/cognify.py (5 hunks)
  • cognee/api/v1/config/config.py (1 hunks)
  • cognee/api/v1/datasets/datasets.py (2 hunks)
  • cognee/base_config.py (2 hunks)
  • cognee/infrastructure/InfrastructureConfig.py (5 hunks)
  • cognee/infrastructure/databases/relational/config.py (1 hunks)
  • cognee/infrastructure/databases/relational/duckdb/DuckDBAdapter.py (1 hunks)
  • cognee/infrastructure/databases/vector/init.py (1 hunks)
Files not processed due to max files limit (12)
  • cognee/infrastructure/databases/vector/config.py
  • cognee/infrastructure/databases/vector/create_vector_engine.py
  • cognee/infrastructure/llm/get_llm_client.py
  • cognee/modules/cognify/graph/add_cognitive_layer_graphs.py
  • cognee/modules/cognify/graph/add_data_chunks.py
  • cognee/modules/cognify/llm/resolve_cross_graph_references.py
  • cognee/modules/search/vector/search_similarity.py
  • cognee/modules/settings/get_settings.py
  • cognee/modules/settings/save_llm_config.py
  • cognee/modules/settings/save_vector_db_config.py
  • cognee/modules/tasks/init.py
  • cognee/modules/tasks/get_task_status.py
Files skipped from review due to trivial changes (26)
  • cognee-frontend/src/app/globals.css
  • cognee-frontend/src/app/wizard/AddStep/AddStep.module.css
  • cognee-frontend/src/app/wizard/AddStep/index.ts
  • cognee-frontend/src/app/wizard/CognifyStep/index.ts
  • cognee-frontend/src/app/wizard/ConfigStep/index.ts
  • cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.module.css
  • cognee-frontend/src/app/wizard/ExploreStep/index.ts
  • cognee-frontend/src/modules/exploration/index.ts
  • cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.module.css
  • cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.module.css
  • cognee-frontend/src/ui/App/Loading/CognifyLoadingIndicator/CognifyLoadingIndicator.module.css
  • cognee-frontend/src/ui/App/Loading/CognifyLoadingIndicator/CognifyLoadingIndicator.tsx
  • cognee-frontend/src/ui/App/Loading/DefaultLoadingIndicator/LoadingIndicator.module.css
  • cognee-frontend/src/ui/App/index.ts
  • cognee-frontend/src/ui/Layout/Divider/Divider.module.css
  • cognee-frontend/src/ui/Layout/Divider/Divider.tsx
  • cognee-frontend/src/ui/Layout/index.ts
  • cognee-frontend/src/ui/Partials/Explorer/Explorer.module.css
  • cognee-frontend/src/ui/Partials/Footer/Footer.tsx
  • cognee-frontend/src/ui/Partials/SettingsModal/SettingsModal.tsx
  • cognee-frontend/src/ui/Partials/Wizard/WizardContent/WizardContent.module.css
  • cognee-frontend/src/ui/Partials/Wizard/index.ts
  • cognee-frontend/src/ui/Partials/index.ts
  • cognee/api/v1/config/config.py
  • cognee/base_config.py
  • cognee/infrastructure/databases/relational/config.py
Additional Context Used
Ruff (4)
cognee/api/client.py (1)

21-21: Module level import not at top of file

cognee/api/v1/cognify/cognify.py (1)

224-224: Do not use bare except

cognee/infrastructure/InfrastructureConfig.py (2)

16-16: Module level import not at top of file


17-17: Module level import not at top of file

Biome (16)
cognee-frontend/src/app/page.tsx (3)

7-7: Do not shadow the global "DataView" property.


6-7: Some named imports are only used as types.


43-43: This hook does not specify all of its dependencies: openDatasetData

cognee-frontend/src/app/wizard/AddStep/AddStep.tsx (3)

60-60: Avoid using the index of an array as key property in an element.


61-61: Avoid using the index of an array as key property in an element.


93-93: Reassigning a function parameter is confusing.

cognee-frontend/src/app/wizard/ExploreStep/ExploreStep.tsx (1)

11-11: Forbidden non-null assertion.

cognee-frontend/src/modules/ingestion/DataView/DataView.tsx (1)

32-32: Do not shadow the global "DataView" property.

cognee-frontend/src/modules/ingestion/DataView/RawDataPreview.tsx (3)

14-14: Template literals are preferred over string concatenation.


31-31: This var should be declared at the root of the enclosing function.


31-31: Use let or const instead of var.

cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx (1)

102-102: Forbidden non-null assertion.

cognee-frontend/src/ui/App/Logo/TextLogo.v1.tsx (1)

3-3: Alternative text title element cannot be empty

cognee-frontend/src/ui/App/Logo/TextLogo.v2.tsx (1)

3-3: Alternative text title element cannot be empty

cognee-frontend/src/ui/Icons/SettingsIcon.tsx (1)

3-3: Alternative text title element cannot be empty

cognee-frontend/src/ui/Partials/IFrameView/IFrameView.tsx (1)

7-11: Provide a title attribute when using iframe elements.

Additional comments not posted (15)
cognee-frontend/src/app/wizard/WizardPage.module.css (2)

5-5: Padding removed to allow the wizard to use the full vertical space. Looks good.


11-12: Updated display and padding settings enhance the layout structure of the wizard container.

cognee/infrastructure/databases/vector/__init__.py (1)

5-5: Centralizing configuration settings with get_vectordb_config import. Good practice for maintainability.

cognee-frontend/src/ui/Partials/Wizard/WizardContent/WizardContent.tsx (1)

1-6: Styled component implementation using withStyles is clean and follows good practices.

cognee-frontend/src/app/wizard/page.tsx (1)

Line range hint 1-12: Simple and effective use of useCallback to manage wizard completion. Good use of React hooks.

cognee-frontend/src/ui/Partials/Wizard/WizardHeading.tsx (1)

1-11: Effective use of props and the spread operator to customize the H1 element. Well-implemented component.

cognee-frontend/src/ui/Partials/SearchView/SearchView.module.css (1)

5-7: CSS changes align well with the redesign objectives.

cognee-frontend/src/app/wizard/ConfigStep/ConfigStep.tsx (1)

10-22: The implementation of ConfigStep is consistent and aligns with the new design and functionality objectives.

cognee/api/v1/datasets/datasets.py (1)

29-29: The integration of get_task_status enhances the dataset status retrieval functionality.

cognee-frontend/src/ui/Partials/Explorer/Explorer.tsx (1)

15-50: Ensure proper error handling for asynchronous calls.

The exploreData function makes an asynchronous call to getExplorationGraphUrl but does not handle potential errors. Consider adding a .catch() block to handle these cases.

  .then((graphUrl) => {
    setGraphUrl(graphUrl);
  })
+ .catch((error) => {
+   console.error('Failed to load graph URL:', error);
+ });
cognee-frontend/src/app/wizard/CognifyStep/CognifyStep.tsx (1)

14-47: Ensure proper error handling for asynchronous calls.

The useEffect hook in CognifyStep makes an asynchronous call to cognifyDataset but does not handle potential errors. Consider adding a .catch() block to handle these cases.

  .then(() => {
    stopCognifyIndicator();        
  })
+ .catch((error) => {
+   console.error('Failed to cognify dataset:', error);
+ });
cognee-frontend/src/app/wizard/WizardPage.tsx (1)

23-82: Ensure consistent use of React hooks.

The useSearchParams hook is used to retrieve query parameters, but it's important to verify that this hook is compatible with your React and Next.js versions, as its behavior can vary.

Verification successful

The React version is ^18 and the Next.js version is 14.2.3. Both versions are compatible with the useSearchParams hook.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check React and Next.js versions to ensure compatibility with useSearchParams.

cat package.json | jq '.dependencies.react, .dependencies.next'

Length of output: 110



Script:

#!/bin/bash
# Locate the package.json file and check React and Next.js versions

# Find the package.json file
PACKAGE_JSON_PATH=$(fd package.json)

# Check React and Next.js versions if package.json is found
if [ -n "$PACKAGE_JSON_PATH" ]; then
  cat "$PACKAGE_JSON_PATH" | jq '.dependencies.react, .dependencies.next'
else
  echo "package.json not found"
fi

Length of output: 206

cognee-frontend/src/modules/ingestion/DataView/DataView.tsx (1)

59-63: Ensure that the wrapping of UploadInput in a div is necessary for styling or layout purposes. If not, consider simplifying the markup.

cognee-frontend/src/modules/ingestion/DatasetsView/DatasetsView.tsx (1)

Line range hint 69-90: The implementation of conditional rendering and event handling for dataset exploration and cognification is well-done.

cognee/api/client.py (1)

109-112: Ensure proper error handling in the get_dataset_status endpoint.

Consider adding specific error handling for cases where datasets_statuses might be None or empty.

export default function ExploreStep({ dataset }: ExploreStepProps) {
return (
<Spacer horizontal="3">
<Explorer dataset={dataset!} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the non-null assertion to prevent potential runtime errors.

- <Explorer dataset={dataset!} />
+ <Explorer dataset={dataset} />

Committable suggestion was skipped due low confidence.

Comment on lines +7 to +11
<iframe
src={src}
width="100%"
height="100%"
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a title attribute to the iframe for accessibility.

-    <iframe
+    <iframe title="Content Frame"

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<iframe
src={src}
width="100%"
height="100%"
/>
<iframe
src={src}
width="100%"
height="100%"
title="Content Frame"
/>

@@ -12,11 +14,12 @@ export default function RawDataPreview({ fileName, rawData, onClose }: RawDataPr
const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', file_header + encodeURIComponent(fileName) + ';');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use template literals for better readability and performance.

- const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', file_header + encodeURIComponent(fileName) + ';');
+ const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', `${file_header}${encodeURIComponent(fileName)};`);

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', file_header + encodeURIComponent(fileName) + ';');
const src = `data:application/pdf;base64,${arrayBufferToBase64(rawData)}`.replace(';', `${file_header}${encodeURIComponent(fileName)};`);

from .databases.relational import DuckDBAdapter, DatabaseEngine
from .databases.vector.vector_db_interface import VectorDBInterface
# from .databases.vector.embeddings.DefaultEmbeddingEngine import DefaultEmbeddingEngine
from .databases.relational import DatabaseEngine
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving module level imports to the top of the file to follow Python's PEP 8 style guide.

- from .databases.relational import DatabaseEngine
- from .llm.llm_interface import LLMInterface
+ from cognee.infrastructure.databases.relational import DatabaseEngine
+ from cognee.infrastructure.llm.llm_interface import LLMInterface

Also applies to: 17-17

Committable suggestion was skipped due low confidence.

@@ -40,6 +40,8 @@ export default function DataView({ datasetId, data, onClose, onDataAdd }: DataVi
fetch(`http://0.0.0.0:8000/datasets/${datasetId}/data/${dataItem.id}/raw`)
.then((response) => response.arrayBuffer())
.then(setRawData);

document.body.click(); // Close the dropdown menu.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct manipulation of document.body to close the dropdown menu is discouraged in React. Consider using a more React-friendly approach, such as updating state or using refs to manage focus.

@@ -30,7 +30,7 @@
}

export default function DataView({ datasetId, data, onClose, onDataAdd }: DataViewProps) {
const handleDataDelete = () => {};
// const handleDataDelete = () => {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the commented-out handleDataDelete function if it's no longer needed, or clarify its purpose with a more descriptive comment.

Comment on lines +1 to +27
export default function TextLogo({ width = 285, height = 81, color = 'currentColor' }) {
return (
<svg width={width} height={height} viewBox="0 0 285 81" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M42.0964 46.4597C39.6678 49.6212 36.2632 51.8922 32.4114 52.92C28.5596 53.9479 24.4762 53.6749 20.7954 52.1436C17.1147 50.6123 14.0426 47.9083 12.0565 44.4517C10.0704 40.9951 9.2813 36.9793 9.81189 33.0282C10.3425 29.0771 12.163 25.4118 14.9907 22.6016C17.8184 19.7914 21.4949 17.9937 25.4493 17.4877C29.4036 16.9816 33.4144 17.7956 36.8586 19.8032" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M190.754 51.1936L199.5 35.4365L208.699 19.7656C205.249 17.7739 201.238 16.9762 197.289 17.4961C193.34 18.016 189.672 19.8246 186.856 22.6413C184.039 25.458 182.23 29.1253 181.71 33.0746C181.191 37.0239 181.988 41.0345 183.98 44.4842C185.972 47.9339 189.046 50.63 192.726 52.1544C196.406 53.6787 200.487 53.9462 204.334 52.9152C208.182 51.8842 211.582 49.6125 214.007 46.4522C214.701 45.5482 215.303 44.5859 215.811 43.5794" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M260.873 35.4365C260.873 39.4199 259.559 43.292 257.134 46.4522C254.709 49.6124 251.309 51.8842 247.461 52.9152C243.614 53.9461 239.533 53.6787 235.853 52.1543C232.173 50.63 229.099 47.9338 227.107 44.4841C225.115 41.0344 224.317 37.0239 224.837 33.0746C225.357 29.1253 227.166 25.4579 229.983 22.6413C232.799 19.8246 236.467 18.016 240.416 17.4961C244.365 16.9761 248.376 17.7739 251.825 19.7656L242.627 35.4365L233.881 51.1936" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<circle cx="112.945" cy="32.4206" r="15.2302" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M128.126 52.627C128.126 62.6207 120.025 70.7222 110.031 70.7222C104.317 70.7222 99.221 68.0734 95.9048 63.9365" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M128.175 17.1905L128.175 52.627" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M170.698 30.7619L170.698 52.4762" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M170.698 30.1587C170.698 22.9966 164.143 17.1905 156.056 17.1905" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M141.746 30.1587C141.746 22.9966 148.153 17.1905 156.056 17.1905" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<path d="M141.746 17.3413L141.746 52.627" stroke={color} strokeWidth="6.03175" strokeLinecap="round"/>
<circle cx="69.0635" cy="35.4365" r="18.0952" stroke="url(#paint0_linear_103_348)" strokeWidth="6.03175" strokeLinecap="round"/>
<path fillRule="evenodd" clipRule="evenodd" d="M69.0637 56.3968C67.3981 56.3968 66.0479 55.0466 66.0479 53.3809L66.0479 17.4921C66.0479 15.8264 67.3981 14.4762 69.0637 14.4762C70.7293 14.4762 72.0796 15.8264 72.0796 17.4921L72.0796 53.3809C72.0796 55.0466 70.7293 56.3968 69.0637 56.3968Z" fill="url(#paint1_linear_103_348)"/>
<defs>
<linearGradient id="paint0_linear_103_348" x1="50.8501" y1="13.1077" x2="87.277" y2="13.1084" gradientUnits="userSpaceOnUse">
<stop stopColor="#D82EB5"/>
<stop offset="1" stopColor="#9245FD"/>
</linearGradient>
<linearGradient id="paint1_linear_103_348" x1="72.0443" y1="56.5336" x2="72.1623" y2="14.3395" gradientUnits="userSpaceOnUse">
<stop stopColor="#D82EB5"/>
<stop offset="1" stopColor="#9245FD"/>
</linearGradient>
</defs>
</svg>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an accessible <title> element within the SVG to improve accessibility. This title can describe the logo or the company it represents.

Comment on lines +1 to +187
}
return config;
});
}, []);

const handleLLMProviderChange = useCallback((newLLMProvider: SelectOption) => {
setLLMConfig((config) => {
if (config?.provider !== newLLMProvider) {
return {
...config,
provider: newLLMProvider,
model: config?.models[newLLMProvider.value][0],
apiKey: '',
};
}
return config;
});
}, []);

const handleLLMModelChange = useCallback((newLLMModel: SelectOption) => {
setLLMConfig((config) => {
if (config?.model !== newLLMModel) {
return {
...config,
model: newLLMModel,
};
}
return config;
});
}, []);

useEffect(() => {
const fetchConfig = async () => {
const response = await fetch('http://0.0.0.0:8000/settings');
const settings = await response.json();

if (!settings.llm.model) {
settings.llm.model = settings.llm.models[settings.llm.provider.value][0];
}
setLLMConfig(settings.llm);
setVectorDBConfig(settings.vectorDB);
};
fetchConfig();
}, []);

return (
<form onSubmit={saveConfig} style={{ width: '100%' }}>
<Stack gap="4" orientation="vertical">
<Stack gap="4" orientation="vertical">
<FormGroup orientation="vertical" align="center/" gap="2">
<FormLabel>LLM provider:</FormLabel>
<DropdownSelect
value={llmConfig?.provider || null}
options={llmConfig?.providers || []}
onChange={handleLLMProviderChange}
/>
</FormGroup>
<FormGroup orientation="vertical" align="center/" gap="2">
<FormLabel>LLM model:</FormLabel>
<DropdownSelect
value={llmConfig?.model || null}
options={llmConfig?.provider ? llmConfig?.models[llmConfig?.provider.value] : []}
onChange={handleLLMModelChange}
/>
</FormGroup>
<FormInput>
<Input defaultValue={llmConfig?.apiKey} name="llmApiKey" placeholder="LLM API key" />
</FormInput>
</Stack>

<Stack gap="2" orientation="vertical">
<FormGroup orientation="vertical" align="center/" gap="2">
<FormLabel>Vector DB provider:</FormLabel>
<DropdownSelect
value={vectorDBConfig?.provider || null}
options={vectorDBConfig?.options || []}
onChange={handleVectorDBChange}
/>
</FormGroup>
<FormInput>
<Input defaultValue={vectorDBConfig?.url} name="vectorDBUrl" placeholder="Vector DB instance url" />
</FormInput>
<FormInput>
<Input defaultValue={vectorDBConfig?.apiKey} name="vectorDBApiKey" placeholder="Vector DB API key" />
</FormInput>
<Stack align="/end">
<Spacer top="2">
<CTAButton type="submit">
<Stack gap="2" orientation="vertical" align="center/">
{submitButtonText}
{isSaving && <LoadingIndicator />}
</Stack>
</CTAButton>
</Spacer>
</Stack>
</Stack>
</Stack>
</form>
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using environment variables for the API URLs in lines 63 and 121 to improve maintainability and security. This approach allows for easier configuration changes without modifying the codebase.

c0.462-23.5,19.886-42.176,43.381-41.715c23.497,0.463,42.172,19.889,41.71,43.387
C357.156,152.614,337.733,171.288,314.236,170.826z"/>
</g>
<svg width={width} height={height} viewBox="0 0 54 56" fill="none" xmlns="http://www.w3.org/2000/svg">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an accessible name to the SVG element.

The SVG element in SettingsIcon lacks an accessible name, which is important for accessibility. Consider adding a title element within the SVG.

  <svg width={width} height={height} viewBox="0 0 54 56" fill="none" xmlns="http://www.w3.org/2000/svg">
+   <title>Settings</title>
    <path d="M21.2482 55.75L20.1336 46.8322C19.1495 46.5357 18.0853 46.0691 16.9408 45.4324C15.7964 44.7962 14.8231 44.1145 14.0209 43.3874L5.79611 46.8854L0.0449219 36.8646L7.15432 31.5042C7.06336 30.9472 6.98833 30.3731 6.92923 29.7822C6.86962 29.1912 6.83982 28.6169 6.83982 28.0594C6.83982 27.5414 6.86962 26.9969 6.92923 26.426C6.98833 25.8545 7.06336 25.2111 7.15432 24.4958L0.0449219 19.1354L5.79611 9.23329L13.9615 12.672C14.8824 11.9053 15.8786 11.2136 16.9501 10.5969C18.021 9.98023 19.0624 9.50385 20.0743 9.16777L21.2482 0.25H32.7522L33.8668 9.22713C35.0487 9.64235 36.0932 10.1187 37.0002 10.6562C37.9072 11.1938 38.8412 11.8657 39.8022 12.672L48.2043 9.23329L53.9555 19.1354L46.6087 24.6739C46.7788 25.31 46.8738 25.8941 46.8939 26.426C46.9134 26.9573 46.9232 27.482 46.9232 28C46.9232 28.4784 46.9034 28.9833 46.8638 29.5147C46.8242 30.0466 46.7333 30.69 46.5909 31.4449L53.819 36.8646L48.0678 46.8854L39.8022 43.328C38.8412 44.1343 37.8746 44.826 36.9023 45.4031C35.93 45.9802 34.9182 46.4368 33.8668 46.7729L32.7522 55.75H21.2482ZM23.9169 52.6667H29.9471L31.0856 44.3178C32.6391 43.9067 34.0374 43.3424 35.2805 42.625C36.5241 41.9076 37.7901 40.9243 39.0784 39.675L46.769 42.9542L49.8346 37.7125L43.0867 32.6427C43.3437 31.765 43.5138 30.9577 43.597 30.2208C43.6797 29.4833 43.7211 28.7431 43.7211 28C43.7211 27.2173 43.6797 26.4771 43.597 25.7792C43.5138 25.0819 43.3437 24.3141 43.0867 23.476L49.9533 18.2875L46.8877 13.0458L39.019 16.3427C38.0863 15.319 36.8599 14.3593 35.3398 13.4636C33.8203 12.5684 32.3824 11.9746 31.0263 11.6822L30.0835 3.33333H23.9346L22.9741 11.6229C21.4206 11.9548 19.9925 12.4895 18.6898 13.227C17.3876 13.9639 16.0921 14.9768 14.8033 16.2656L7.11269 13.0458L4.04709 18.2875L10.7356 23.2802C10.4787 23.9719 10.2988 24.7229 10.196 25.5333C10.0932 26.3437 10.0419 27.1857 10.0419 28.0594C10.0419 28.842 10.0932 29.6187 10.196 30.3896C10.2988 31.1604 10.4589 31.9115 10.6763 32.6427L4.04709 37.7125L7.11269 42.9542L14.7439 39.7167C15.9536 40.9382 17.2096 41.9177 18.5118 42.6551C19.8145 43.392 21.2822 43.966 22.9148 44.3771L23.9169 52.6667ZM26.9169 35.7083C29.0676 35.7083 30.8901 34.9611 32.3845 33.4668C33.8783 31.9729 34.6253 30.1506 34.6253 28C34.6253 25.8494 33.8783 24.0271 32.3845 22.5333C30.8901 21.0389 29.0676 20.2917 26.9169 20.2917C24.755 20.2917 22.9297 21.0389 21.4409 22.5333C19.9527 24.0271 19.2086 25.8494 19.2086 28C19.2086 30.1506 19.9527 31.9729 21.4409 33.4668C22.9297 34.9611 24.755 35.7083 26.9169 35.7083Z" fill={color} />
  </svg>

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
<svg width={width} height={height} viewBox="0 0 54 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg width={width} height={height} viewBox="0 0 54 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<title>Settings</title>
<path d="M21.2482 55.75L20.1336 46.8322C19.1495 46.5357 18.0853 46.0691 16.9408 45.4324C15.7964 44.7962 14.8231 44.1145 14.0209 43.3874L5.79611 46.8854L0.0449219 36.8646L7.15432 31.5042C7.06336 30.9472 6.98833 30.3731 6.92923 29.7822C6.86962 29.1912 6.83982 28.6169 6.83982 28.0594C6.83982 27.5414 6.86962 26.9969 6.92923 26.426C6.98833 25.8545 7.06336 25.2111 7.15432 24.4958L0.0449219 19.1354L5.79611 9.23329L13.9615 12.672C14.8824 11.9053 15.8786 11.2136 16.9501 10.5969C18.021 9.98023 19.0624 9.50385 20.0743 9.16777L21.2482 0.25H32.7522L33.8668 9.22713C35.0487 9.64235 36.0932 10.1187 37.0002 10.6562C37.9072 11.1938 38.8412 11.8657 39.8022 12.672L48.2043 9.23329L53.9555 19.1354L46.6087 24.6739C46.7788 25.31 46.8738 25.8941 46.8939 26.426C46.9134 26.9573 46.9232 27.482 46.9232 28C46.9232 28.4784 46.9034 28.9833 46.8638 29.5147C46.8242 30.0466 46.7333 30.69 46.5909 31.4449L53.819 36.8646L48.0678 46.8854L39.8022 43.328C38.8412 44.1343 37.8746 44.826 36.9023 45.4031C35.93 45.9802 34.9182 46.4368 33.8668 46.7729L32.7522 55.75H21.2482ZM23.9169 52.6667H29.9471L31.0856 44.3178C32.6391 43.9067 34.0374 43.3424 35.2805 42.625C36.5241 41.9076 37.7901 40.9243 39.0784 39.675L46.769 42.9542L49.8346 37.7125L43.0867 32.6427C43.3437 31.765 43.5138 30.9577 43.597 30.2208C43.6797 29.4833 43.7211 28.7431 43.7211 28C43.7211 27.2173 43.6797 26.4771 43.597 25.7792C43.5138 25.0819 43.3437 24.3141 43.0867 23.476L49.9533 18.2875L46.8877 13.0458L39.019 16.3427C38.0863 15.319 36.8599 14.3593 35.3398 13.4636C33.8203 12.5684 32.3824 11.9746 31.0263 11.6822L30.0835 3.33333H23.9346L22.9741 11.6229C21.4206 11.9548 19.9925 12.4895 18.6898 13.227C17.3876 13.9639 16.0921 14.9768 14.8033 16.2656L7.11269 13.0458L4.04709 18.2875L10.7356 23.2802C10.4787 23.9719 10.2988 24.7229 10.196 25.5333C10.0932 26.3437 10.0419 27.1857 10.0419 28.0594C10.0419 28.842 10.0932 29.6187 10.196 30.3896C10.2988 31.1604 10.4589 31.9115 10.6763 32.6427L4.04709 37.7125L7.11269 42.9542L14.7439 39.7167C15.9536 40.9382 17.2096 41.9177 18.5118 42.6551C19.8145 43.392 21.2822 43.966 22.9148 44.3771L23.9169 52.6667ZM26.9169 35.7083C29.0676 35.7083 30.8901 34.9611 32.3845 33.4668C33.8783 31.9729 34.6253 30.1506 34.6253 28C34.6253 25.8494 33.8783 24.0271 32.3845 22.5333C30.8901 21.0389 29.0676 20.2917 26.9169 20.2917C24.755 20.2917 22.9297 21.0389 21.4409 22.5333C19.9527 24.0271 19.2086 25.8494 19.2086 28C19.2086 30.1506 19.9527 31.9729 21.4409 33.4668C22.9297 34.9611 24.755 35.7083 26.9169 35.7083Z" fill={color} />
</svg>

Comment on lines +13 to +87
export default function AddStep({ onNext }: ConfigStepProps) {
const [files, setFiles] = useState<File[]>([]);

const {
value: isUploading,
setTrue: disableUploading,
setFalse: enableUploading,
} = useBoolean(false);

const uploadFiles = useCallback(() => {
disableUploading()
addData({ id: '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 (
<Stack orientation="vertical" gap="6">
<WizardHeading><Text light size="large">Step 2/3</Text> Add knowledge</WizardHeading>
<Divider />
<Text align="center">
Cognee lets you process your personal data, books, articles or company data.
Simply add datasets to get started.
</Text>
<Stack gap="1">
<UploadInput onChange={addFiles}>
<Stack gap="2" orientation="horizontal" align="center/center">
<UploadIcon key={files.length} />
<Text>Upload your data</Text>
</Stack>
</UploadInput>
<Stack gap="3" className={styles.files}>
{files.map((file, index) => (
<Stack gap="between" orientation="horizontal" align="center/" key={index}>
<div key={index}>
<Text bold>{file.name}</Text>
<Text className={styles.fileSize} size="small">
{getBiggestUnitSize(file.size)}
</Text>
</div>
<GhostButton hugContent onClick={() => removeFile(file)}>
<TrashIcon />
</GhostButton>
</Stack>
))}
</Stack>
</Stack>
<Stack align="/end">
<CTAButton disabled={isUploading || files.length === 0} onClick={uploadFiles}>
<Stack gap="2" orientation="horizontal" align="center/center">
<Text>Next</Text>
{isUploading && (
<LoadingIndicator />
)}
</Stack>
</CTAButton>
</Stack>
</Stack>
)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid reassigning function parameters.

Reassigning function parameters can lead to confusing and hard-to-track bugs. Consider using a local variable instead.

- while (sizeInBytes >= 1024 && i < units.length - 1) {
+ let adjustedSize = sizeInBytes;
+ while (adjustedSize >= 1024 && i < units.length - 1) {
+   adjustedSize /= 1024;
-   sizeInBytes /= 1024;
    i++;
  }
- return `${sizeInBytes.toFixed(2)} ${units[i]}`;
+ return `${adjustedSize.toFixed(2)} ${units[i]}`;

Committable suggestion was skipped due low confidence.

@Vasilije1990 Vasilije1990 merged commit 402f0af into main May 27, 2024
13 of 14 checks passed
@borisarzentar borisarzentar deleted the feat/frontend-redesign branch June 3, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants