mongodb / chatbot

MongoDB Chatbot Framework. Powered by MongoDB and Atlas Vector Search.
https://mongodb.github.io/chatbot/
Apache License 2.0
106 stars 48 forks source link

Typescript error when running quickstart #430

Closed JohnGUnderwood closed 3 weeks ago

JohnGUnderwood commented 4 weeks ago

After attempting to install the fix for #425 (see #429 ) I get an error when running npm run dev in the examples/quick-start directory.

This occurs whether I have installed mongodb-chatbot-server@^0.9.1 in the root of the project or from within examples/quick-start.

Error output:

% npm run dev

> mongodb-chatbot-framework-quick-start@1.0.0 dev
> npm run dev --workspace=server & npm run dev --workspace=ui

> server@0.0.0 dev
> nodemon src/index.ts

> ui@0.0.0 dev
> vite

[nodemon] 3.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node src/index.ts`

  VITE v5.0.11  ready in 151 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h + enter to show help
/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:118:3 - error TS2345: Argument of type 'ChatRequestSystemMessage & { role: OpenAiMessageRole; embedding?: number[]; content: string; } & { role: "system"; content: string; }' is not assignable to parameter of type 'ConversationConstants'.
  Type 'ChatRequestSystemMessage & { role: OpenAiMessageRole; embedding?: number[]; content: string; } & { role: "system"; content: string; }' is missing the following properties from type 'ConversationConstants': NO_RELEVANT_CONTENT, LLM_NOT_WORKING

118   systemPrompt
      ~~~~~~~~~~~~
src/index.ts:123:3 - error TS2741: Property 'systemPrompt' is missing in type '{ llm: Required<ChatLlm>; conversations: ConversationsService; generateUserPrompt: GenerateUserPromptFunc; }' but required in type 'ConversationsRouterParams'.

123   conversationsRouterConfig: {
      ~~~~~~~~~~~~~~~~~~~~~~~~~

  ../../node_modules/mongodb-chatbot-server/build/routes/conversations/conversationsRouter.d.ts:68:5
    68     systemPrompt: SystemPrompt;
           ~~~~~~~~~~~~
    'systemPrompt' is declared here.
  ../../node_modules/mongodb-chatbot-server/build/app.d.ts:12:5
    12     conversationsRouterConfig: ConversationsRouterParams;
           ~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from property 'conversationsRouterConfig' which is declared here on type 'AppConfig'

    at createTSError (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/junderwood/GitHub/chatbot/examples/quick-start/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1091:32)
    at Function.Module._load (node:internal/modules/cjs/loader:938:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  diagnosticCodes: [ 2345, 2741 ]
}
[nodemon] app crashed - waiting for file changes before starting...
mongodben commented 3 weeks ago

hi john, i think there are some version mismatches going on in your environment. not sure exactly what's going on, but i think we can get you up and running on the quick start with the following steps:

  1. Get latest version of the repo code: git pull upstream main
    • I think this is the main issue, with a mismatch between your source code and the latest versions.
  2. Go to the quick start code: cd examples/quick-start
  3. Make sure your lock file and node_modules are up to date: rm -rf package-lock.json node_modules && npm i
    • Removes old versions and install new versions of dependencies
  4. Start the project: npm run dev

Let me know if this works, and if so we can close the issue.

If issue persists, please feel free to put a meeting on my calendar to address.

JohnGUnderwood commented 3 weeks ago

These steps fixed this issue. Although I'm now seeing the issue from #425 again.