langchain-ai / langchainjs

πŸ¦œπŸ”— Build context-aware reasoning applications πŸ¦œπŸ”—
https://js.langchain.com/docs/
MIT License
12.29k stars 2.08k forks source link

What mean of "Not Found" #4096

Closed meithon closed 1 month ago

meithon commented 7 months ago

I executed this code.

/* eslint-disable @typescript-eslint/no-explicit-any */
import weaviate from "weaviate-ts-client";
import { WeaviateStore } from "@langchain/community/vectorstores/weaviate";
import { OpenAIEmbeddings } from "@langchain/openai";

export async function run() {
  // Something wrong with the weaviate-ts-client types, so we need to disable
  const client = weaviate.client({
    scheme: process.env.WEAVIATE_SCHEME || "http",
    host: process.env.WEAVIATE_HOST || "localhost:8080",
  });
  const docs = [{ pageContent: "see ya!", metadata: { foo: "bar" } }];

  WeaviateStore.fromDocuments(docs, new OpenAIEmbeddings(), {
    client,
    indexName: "Test",
  });
}

run();

Returned this error

150 |             if (errorMessages.length > 0) {
151 |                 throw new Error(errorMessages.join("\n"));
152 |             }
153 |         }
154 |         catch (e) {
155 |             throw Error(`Error adding vectors: ${e}`);
                        ^
error: Error adding vectors: Error: usage error (404): {"detail":"Not Found"}
      at /Users/mei/workspace/private/langchain-ts/node_modules/@langchain/community/dist/vectorstores/weaviate.js:155:19

What was not found for this? And how can this be resolved?

dosubot[bot] commented 7 months ago

πŸ€–

Hello @rneithon! Nice to see you back here. I hope your project is coming along well. Let's take a look at this issue you've encountered.

The "Not Found" error you're encountering is likely due to the Weaviate instance not being able to find the resource you're trying to access. This could be due to a number of reasons, such as the Weaviate instance not being properly set up, the specified index not existing, or the Weaviate instance not being reachable at the specified host and port.

In your code, you're trying to create a Weaviate client and use it to add documents to a Weaviate store. The error is thrown when the WeaviateStore.fromDocuments function is called. This function tries to add the provided documents to the Weaviate index specified in the indexName argument. If this index does not exist in the Weaviate instance, or if the Weaviate instance is not reachable, a "Not Found" error could be thrown.

Here's how you can troubleshoot this issue:

  1. Check the Weaviate instance: Make sure that the Weaviate instance is properly set up and running. You can do this by trying to access the Weaviate instance directly using its host and port. If you're running Weaviate locally, you can try accessing http://localhost:8080 in your browser.

  2. Check the index: Make sure that the index you're trying to add documents to exists in the Weaviate instance. You can do this by checking the Weaviate instance's schema. If the index does not exist, you'll need to create it before you can add documents to it.

  3. Check the host and port: Make sure that the host and port you're using to create the Weaviate client match the host and port of the Weaviate instance. In your code, you're using the WEAVIATE_HOST environment variable to specify the host and port. Make sure that this environment variable is correctly set to the host and port of the Weaviate instance.

If you've checked all of these and you're still encountering the error, it would be helpful if you could provide more information about your setup. Specifically, it would be helpful to know how your Weaviate instance is set up, what the WEAVIATE_HOST environment variable is set to, and whether the index you're trying to add documents to exists in the Weaviate instance.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a πŸ‘ if this is helpful and πŸ‘Ž if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

meithon commented 7 months ago

I use this docker-compose.yml

version: "3.4"
services:
  weaviate:
    command:
      - --host
      - 0.0.0.0
      - --port
      - "8080"
      - --scheme
      - http
    image: semitechnologies/weaviate:1.23.3
    env_file: .env
    ports:
      - 8080:8080
      - 50051:50051
    volumes:
      - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    environment:
      QNA_INFERENCE_API: "http://qna-transformers:8080"
      NER_INFERENCE_API: "http://ner-transformers:8080"
      SPELLCHECK_INFERENCE_API: "http://text-spellcheck:8080"
      OPENAI_APIKEY: $OPENAI_API_KEY
      QUERY_DEFAULTS_LIMIT: 25
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true"
      PERSISTENCE_DATA_PATH: "/var/lib/weaviate"
      DEFAULT_VECTORIZER_MODULE: "text2vec-openai"
      ENABLE_MODULES: "text2vec-openai,qna-transformers,ner-transformers,text-spellcheck,ref2vec-centroid,generative-openai"
      CLUSTER_HOSTNAME: "node1"
  qna-transformers:
    image: semitechnologies/qna-transformers:distilbert-base-uncased-distilled-squad
    environment:
      ENABLE_CUDA: "0"
  ner-transformers:
    image: semitechnologies/ner-transformers:dbmdz-bert-large-cased-finetuned-conll03-english
    environment:
      ENABLE_CUDA: "0"
  text-spellcheck:
    image: semitechnologies/text-spellcheck-model:pyspellchecker-en
volumes:
  weaviate_data:
kahirokunn commented 5 months ago

@rneithon awesome