garyfeng / llm-graph-builder

Neo4j graph construction from unstructured data using LLMs
https://neo4j.com/labs/genai-ecosystem/llm-graph-builder/
Apache License 2.0
0 stars 0 forks source link

BUG: frontend dockerimage fails #2

Open garyfeng opened 1 month ago

garyfeng commented 1 month ago
=> ERROR [frontend build 7/7] RUN BACKEND_API_URL=http://localhost:8000     REACT_APP_SOURCES=local,youtube,wiki,s3     LLM  8.0s
------
 > [frontend build 7/7] RUN BACKEND_API_URL=http://localhost:8000     REACT_APP_SOURCES=local,youtube,wiki,s3     LLM_MODELS=diffbot,openai-gpt-3.5,openai-gpt-4o     GOOGLE_CLIENT_ID=""     BLOOM_URL=https://workspace-preview.neo4j.io/workspace/explore?connectURL={CONNECT_URL}&search=Show+me+a+graph&featureGenAISuggestions=true&featureGenAISuggestionsInternal=true     TIME_PER_CHUNK=4     CHUNK_SIZE=5242880     ENV=DEV     LARGE_FILE_SIZE=5242880     CHAT_MODES=""     yarn run build:
0.843 yarn run v1.22.22
0.896 $ tsc && vite build
7.880 src/components/QuickStarter.tsx(44,15): error TS2322: Type '{ openSettingsDialog: () => void; isSettingPanelExpanded: boolean; closeSettingModal: () => void; closeOrphanNodeDeletionModal: () => void; showOrphanNodeDeletionModal: boolean; openOrphanNodeDeletionModal: () => void; }' is not assignable to type 'IntrinsicAttributes & { isSettingPanelExpanded: boolean; closeSettingModal: () => void; openSettingsDialog: () => void; }'.
7.880   Property 'closeOrphanNodeDeletionModal' does not exist on type 'IntrinsicAttributes & { isSettingPanelExpanded: boolean; closeSettingModal: () => void; openSettingsDialog: () => void; }'.
7.880 src/utils/Utils.ts(190,92): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
7.880   Type 'undefined' is not assignable to type 'string'.
7.880 src/utils/Utils.ts(205,14): error TS2339: Property 'labels' does not exist on type 'Node'.
7.880 src/utils/Utils.ts(205,52): error TS2339: Property 'labels' does not exist on type 'Node'.
7.880 src/utils/Utils.ts(205,89): error TS2339: Property 'labels' does not exist on type 'Node'.
7.880 src/utils/Utils.ts(209,92): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
7.880   Type 'undefined' is not assignable to type 'string'.
7.880 src/utils/Utils.ts(217,68): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
7.880   Type 'undefined' is not assignable to type 'string'.
7.923 error Command failed with exit code 2.
7.923 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: process "/bin/sh -c BACKEND_API_URL=$BACKEND_API_URL     REACT_APP_SOURCES=$REACT_APP_SOURCES     LLM_MODELS=$LLM_MODELS     GOOGLE_CLIENT_ID=$GOOGLE_CLIENT_ID     BLOOM_URL=$BLOOM_URL     TIME_PER_CHUNK=$TIME_PER_CHUNK     CHUNK_SIZE=$CHUNK_SIZE     ENV=$ENV     LARGE_FILE_SIZE=${LARGE_FILE_SIZE}     CHAT_MODES=$CHAT_MODES     yarn run build" did not complete successfully: exit code: 2
garyfeng commented 1 month ago

from GPT4o:

The errors in your TypeScript build seem to be related to type mismatches and property issues. Here’s a detailed analysis and potential fixes for each error:

  1. Error TS2322:

    Property 'closeOrphanNodeDeletionModal' does not exist on type 'IntrinsicAttributes & { isSettingPanelExpanded: boolean; closeSettingModal: () => void; openSettingsDialog: () => void; }'.

    This error indicates that closeOrphanNodeDeletionModal is being passed as a prop to a component that does not expect it. You need to ensure that closeOrphanNodeDeletionModal is a valid prop for the component. Check the definition of the component being used at src/components/QuickStarter.tsx:44 and add closeOrphanNodeDeletionModal to its props type if needed.

    Example fix:

    interface QuickStarterProps {
     isSettingPanelExpanded: boolean;
     closeSettingModal: () => void;
     openSettingsDialog: () => void;
     closeOrphanNodeDeletionModal?: () => void;
     showOrphanNodeDeletionModal?: boolean;
     openOrphanNodeDeletionModal?: () => void;
    }
  2. Error TS2345:

    Argument of type 'string | undefined' is not assignable to parameter of type 'string'.

    This error appears multiple times, indicating that some functions are expecting a string but are receiving a string | undefined type. Ensure that the argument being passed is always a string, possibly by providing a default value or by adding a type guard.

    Example fix:

    function exampleFunction(arg: string | undefined) {
     if (typeof arg === 'undefined') {
       throw new Error('Argument cannot be undefined');
     }
     // Proceed with the function using `arg`
    }
    
    // Or provide a default value
    const arg: string = potentiallyUndefinedValue ?? '';
  3. Error TS2339:

    Property 'labels' does not exist on type 'Node'.

    This error indicates that the labels property is being accessed on a Node object which does not have this property. Ensure that the Node type includes labels or use a type assertion or type guard.

    Example fix:

    interface Node {
     labels?: string[];
    }
    
    function processNode(node: Node) {
     if (node.labels) {
       // Safe to use node.labels
     }
    }

    If the Node type is from a third-party library, you might need to extend it:

    interface ExtendedNode extends Node {
     labels?: string[];
    }
  4. Error TS2339 and TS2345 in src/utils/Utils.ts: Check lines 190, 205, and 217 for the following issues:

    • Ensure that the variables potentiallyUndefinedValue and node (or similar variables) are properly type-checked before accessing their properties or passing them to functions.
    • For node.labels, ensure the Node type includes labels or use type guards/assertions as shown above.

Here's a consolidated example to handle these issues:

// src/utils/Utils.ts

function processString(arg: string | undefined) {
  if (typeof arg === 'undefined') {
    throw new Error('Argument cannot be undefined');
  }
  // Safe to use arg as string
}

interface Node {
  labels?: string[];
}

function processNode(node: Node) {
  if (!node.labels) {
    throw new Error('Node labels are undefined');
  }
  // Safe to use node.labels
}

// Example usage
const exampleNode: Node = { labels: ['label1', 'label2'] };
processNode(exampleNode);

const exampleString: string | undefined = 'someString';
processString(exampleString);

Summary

Apply these changes to your codebase to resolve the TypeScript errors and then attempt to rebuild your project.

garyfeng commented 1 month ago

see also https://github.com/neo4j-labs/llm-graph-builder/issues/541