andrewnguonly / Lumos

A RAG LLM co-pilot for browsing the web, powered by local LLMs
MIT License
1.32k stars 92 forks source link

TypeScript error when building `langgraph` branch with Webpack #183

Closed andrewnguonly closed 1 month ago

andrewnguonly commented 1 month ago

Branch: langgraph Build command: npm run build LangGraph version: "@langchain/langgraph": "^0.0.21"

Code:

import { StateGraph } from "@langchain/langgraph";

// GRAPH STATE
type GraphState = {
  /**
   * An object where each key is a string.
   */
  prompt: string;
  skipRAG: boolean;
};

const graphState = {
  prompt: {
    value: (x: string, y: string) => y,
    default: () => (""),
  },
  skipRAG: {
    value: (x: boolean, y: boolean) => y,
    default: () => (false),
  }
};

// GRAPH NODES

// GRAPH CONSTRUCTION
const workflow = new StateGraph<GraphState>({
  channels: graphState,
});

Error:

ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/src/scripts/background_v2.ts
27:32-42
[tsl] ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/src/scripts/background_v2.ts(27,33)
      TS2558: Expected 0 type arguments, but got 1.

ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts
22:27-32
[tsl] ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts(22,28)
      TS1139: Type parameter declaration expected.

ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts
22:35-42
[tsl] ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts(22,36)
      TS1005: ',' expected.

ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts
23:51-52
[tsl] ERROR in /Users/andrewnguonly/Documents/workspace/github/andrewnguonly/Lumos/node_modules/@langchain/langgraph/dist/graph/graph.d.ts(23,52)
      TS1005: ',' expected.
andrewnguonly commented 1 month ago

Upgrading to TypeScript 5.4.5 resolved this error.

andrewnguonly commented 1 month ago

This is resolved with "@langchain/langgraph": "^0.0.23"