GithubHelp home page GithubHelp logo

Comments (15)

shanghaikid avatar shanghaikid commented on June 9, 2024 1

Nextjs doesn't load proto files by default, you should modify webpack config: copy these file into the build folder.

This config works for me.

const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config, { isServer }) => {
    if (isServer) {
      // Copy the proto files to the server build directory
      config.plugins.push(
        new CopyWebpackPlugin({
          patterns: [
            {
              from: path.join(
                __dirname,
                "node_modules/@zilliz/milvus2-sdk-node/dist"
              ),
              to: path.join(__dirname, ".next"),
            },
          ],
        })
      );
    }
    // Important: return the modified config
    return config;
  },
};

module.exports = nextConfig;

from milvus-sdk-node.

shanghaikid avatar shanghaikid commented on June 9, 2024

Let me do some test.

from milvus-sdk-node.

shanghaikid avatar shanghaikid commented on June 9, 2024

Would you like to share you code?

from milvus-sdk-node.

AdamGonda avatar AdamGonda commented on June 9, 2024

I have the same issue, running on vercel, sveltekit setup.
"@zilliz/milvus2-sdk-node": "^2.2.10",

relevant code 👇
`
import { DataType, MilvusClient } from '@zilliz/milvus2-sdk-node';

const client = new MilvusClient(address, secure, user, password);

	const collection_name = 'foobar';
	await client.loadCollectionSync({
		collection_name
	});

            const vector = [...Array(512)].map(() => Math.random());

	const res = await client.search({
	  collection_name,
	  vectors: [vector],
	  search_params: {
	    anns_field: "vector",
	    metric_type: "L2",
	    params: JSON.stringify({ nprobe: 64 }),
	    topk: '5',
	  },
	  output_fields: ['baz'],
	  vector_type: DataType.FloatVector,
	});

`

from milvus-sdk-node.

shanghaikid avatar shanghaikid commented on June 9, 2024

vercel

Thanks. maybe there is some limitation on vercel platform. let me test it.

from milvus-sdk-node.

AdamGonda avatar AdamGonda commented on June 9, 2024

it's the same for lower vector dims like 128

from milvus-sdk-node.

AdamGonda avatar AdamGonda commented on June 9, 2024

It breaks on Netlify as well, edge function related maybe.

from milvus-sdk-node.

evanlong0926 avatar evanlong0926 commented on June 9, 2024

Nextjs 默认不加载 proto 文件,你应该修改 webpack 配置:将这些文件复制到构建文件夹中。

这个配置对我有用。

const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config, { isServer }) => {
    if (isServer) {
      // Copy the proto files to the server build directory
      config.plugins.push(
        new CopyWebpackPlugin({
          patterns: [
            {
              from: path.join(
                __dirname,
                "node_modules/@zilliz/milvus2-sdk-node/dist"
              ),
              to: path.join(__dirname, ".next"),
            },
          ],
        })
      );
    }
    // Important: return the modified config
    return config;
  },
};

module.exports = nextConfig;

👋 我也碰到了类似的问题:ENOENT: no such file or directory, open 'C:/Users/Administrator/Desktop/official-website/.next/server/app/proto/proto/schema.proto',你这个方案貌似解决了我的问题,棒棒哒🤣

from milvus-sdk-node.

chekun avatar chekun commented on June 9, 2024

@shanghaikid

Can the protoPath variable be configured? From the code, it seems to use __dirname, which would cause the protoPath to constantly change by caller route in Next.js, making it more troublesome to use.

from milvus-sdk-node.

evanlong0926 avatar evanlong0926 commented on June 9, 2024

Or make it nextjs-milvus

Or is prisma-milvus

from milvus-sdk-node.

chekun avatar chekun commented on June 9, 2024

v2.3.0 works like a charm. Thanks @shanghaikid

from milvus-sdk-node.

mhamdik avatar mhamdik commented on June 9, 2024

Hello,
I have the some problem with Nuxt3 when build app.

Package version : @zilliz/milvus2-sdk-node": "^2.3.1"

Error message:

unresolvable extensions: 'extend google.protobuf.FileOptions' in .milvus.proto.milvus
at Root.resolveAll (//.output/server/node_modules/protobufjs/src/root.js:256:15)
at loadProtosWithOptionsSync (//.output/server/node_modules/@grpc/proto-loader/build/src/util.js:68:16)
at loadSync (//.output/server/node_modules/@grpc/proto-loader/build/src/index.js:197:61)

from milvus-sdk-node.

MarleneJiang avatar MarleneJiang commented on June 9, 2024

Nextjs doesn't load proto files by default, you should modify webpack config: copy these file into the build folder.

This config works for me.

const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config, { isServer }) => {
    if (isServer) {
      // Copy the proto files to the server build directory
      config.plugins.push(
        new CopyWebpackPlugin({
          patterns: [
            {
              from: path.join(
                __dirname,
                "node_modules/@zilliz/milvus2-sdk-node/dist"
              ),
              to: path.join(__dirname, ".next"),
            },
          ],
        })
      );
    }
    // Important: return the modified config
    return config;
  },
};

module.exports = nextConfig;

so this problem can not resolve? I think copy-webpack is a dirty code for me.

from milvus-sdk-node.

shanghaikid avatar shanghaikid commented on June 9, 2024

Nextjs doesn't load proto files by default, you should modify webpack config: copy these file into the build folder.
This config works for me.

const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack: (config, { isServer }) => {
    if (isServer) {
      // Copy the proto files to the server build directory
      config.plugins.push(
        new CopyWebpackPlugin({
          patterns: [
            {
              from: path.join(
                __dirname,
                "node_modules/@zilliz/milvus2-sdk-node/dist"
              ),
              to: path.join(__dirname, ".next"),
            },
          ],
        })
      );
    }
    // Important: return the modified config
    return config;
  },
};

module.exports = nextConfig;

so this problem can not resolve? I think copy-webpack is a dirty code for me.

You can define the milvus proto file in the clientOptions. or you can create a pr to make it better.

from milvus-sdk-node.

matan-co avatar matan-co commented on June 9, 2024

Hey @shanghaikid .
I managed to run nextjs with your solution but just on "npm run dev"(when changing to what you said) but when I'm doing npm run build I get this error:
Collecting page data ..Error: Unable to load service: milvus.proto.milvus.MilvusService from XXXXXX/.next/proto/proto/milvus.proto but the file exists in the direcoty

from milvus-sdk-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.