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

Option field llm is not necessary for loadEvaluator with type embedding_distance #7051

Open
5 tasks done
trend-ouki-wang opened this issue Oct 23, 2024 · 1 comment
Open
5 tasks done
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@trend-ouki-wang
Copy link

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

const {loadEvaluator} = require("langchain/evaluation");
const {AzureOpenAI, AzureChatOpenAI, AzureOpenAIEmbeddings} = require("@langchain/openai");
...
const chain = await loadEvaluator("embedding_distance", {
        embedding: azure_embedding,
        distanceMetric: "euclidean",
    });
...

Error Message and Stack Trace (if applicable)

Error: OpenAI or Azure OpenAI API key or Token Provider not found
at new ChatOpenAI (C:\Users\ouki_wang\Desktop\Team\sandbox-companion\node_modules@langchain\openai\dist\chat_models.cjs:1032:19)
at loadEvaluator (C:\Users\ouki_wang\Desktop\Team\sandbox-companion\node_modules\langchain\dist\evaluation\loader.cjs:21:9)
at main (C:\Users\ouki_wang\Desktop\Team\sandbox-companion\05-sandbox.js:78:29)
at Object. (C:\Users\ouki_wang\Desktop\Team\sandbox-companion\05-sandbox.js:131:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49

Description

we have tried to call loadEvaluator to get euclidean distance with embedding model.
However get error message without llm missing in option fields of loadEvaluator.
I think llm field is not necessary when call with type embedding_distance.

System Info

"@langchain/openai": "^0.3.11",
"langchain": "^0.3.3"

node version: v18.20.4

Copy link

dosubot bot commented Oct 23, 2024

The error you're encountering is due to the OpenAIEmbeddings class requiring an API key or token provider, even if the llm field is not necessary for the embedding_distance evaluator. To resolve this, ensure that you provide either an OpenAI API key, an Azure OpenAI API key, or an Azure AD token provider. This requirement is part of the OpenAIEmbeddings class, which throws an error if none of these credentials are provided [1][2].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant