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

LmdbCache throwing error using with Nextjs #37

Closed
benfiratkaya opened this issue Apr 25, 2024 · 1 comment
Closed

LmdbCache throwing error using with Nextjs #37

benfiratkaya opened this issue Apr 25, 2024 · 1 comment
Assignees

Comments

@benfiratkaya
Copy link

I'm trying to use LmdbCache with Nextjs but i got error.

My route.ts file:

import {auth} from '@/lib/auth'
import {OpenAi, RAGApplication, RAGApplicationBuilder} from "@llm-tools/embedjs";
import * as path from "path";
const { QdrantDb } = require("@llm-tools/embedjs/vectorDb/qdrant");
const { LmdbCache } = require("@llm-tools/embedjs/cache/lmdb");

let ragApplication: RAGApplication;
const ragBuilder = new RAGApplicationBuilder()
    .setModel(new OpenAi({ modelName: 'gpt-3.5-turbo' }))
    .setVectorDb(
        new QdrantDb({
          apiKey: process.env.QDRANTDB_API_KEY || '',
          url: process.env.QDRANTDB_API_URL || '',
          clusterName: process.env.QDRANTDB_CLUSTER_NAME || '',
        })
    )
    .setLoaderInit(false);

export async function POST(request: Request) {
  const session = await auth()
  const { query } = await request.json()
  
  if (!session) {
    return new Response(null, {
      status: 401
    })
  }
  
  if (!ragApplication) {
    ragApplication = await ragBuilder.build();
  }
  
  const result = await ragApplication.query(query);
  
  return Response.json({ result })
}

Error:

Import trace for requested module:
./node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@llm-tools/embedjs/dist/cache/lmdb-cache.cjs
./app/api/chat/route.ts
 ⨯ ./node_modules/.pnpm/[email protected]/node_modules/lmdb/dist/index.cjs:3109:0
Module not found: Can't resolve 'cbor-x'

https://nextjs.org/docs/messages/module-not-found

If I install the cbor-x node package, I got this error:

 ⨯ node_modules/.pnpm/[email protected]/node_modules/node-gyp-build-optional-packages/index.js (77:0) @ load.path
 ⨯ Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.20.2 webpack=true
    attempted loading from: .next/server/vendor-chunks and package: @/-darwin-arm64

@adhityan
Copy link
Collaborator

@benfiratkaya did this get resolved? What happened in the end?

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

No branches or pull requests

2 participants