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

YandexGPT implementation can't be used in tool calling / react agents #7562

Open
5 tasks done
morigs opened this issue Jan 20, 2025 · 3 comments
Open
5 tasks done

YandexGPT implementation can't be used in tool calling / react agents #7562

morigs opened this issue Jan 20, 2025 · 3 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@morigs
Copy link

morigs commented Jan 20, 2025

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

import { ChatYandexGPT } from "@langchain/yandex";
import { MemorySaver } from "@langchain/langgraph";
import { HumanMessage } from "@langchain/core/messages";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

const agent = createReactAgent({
	llm: new ChatYandexGPT({ temperature: 0 }),
	tools: [],
	checkpointSaver: new MemorySaver(),
});

for (const chunk in await agent.stream(
	{ messages: [new HumanMessage("Respond with hello world")] },
	{ configurable: { thread_id: "42" } },
)) {
	console.log(chunk);
}

Error Message and Stack Trace (if applicable)

bun run index.ts
120 |     }
121 |     else {
122 |         toolClasses = tools;
123 |     }
124 |     if (!("bindTools" in llm) || typeof llm.bindTools !== "function") {
125 |         throw new Error(`llm ${llm} must define bindTools method.`);
                    ^
error: llm [object Object] must define bindTools method.
      at createReactAgent (/Users/morigs/projects/concierge-js/node_modules/@langchain/langgraph/dist/prebuilt/react_agent_executor.js:125:15)
      at /Users/morigs/projects/concierge-js/index.ts:6:15

Bun v1.1.43 (macOS arm64)

Description

When using ChatYandexGPT for createReactAgent it throws llm [object Object] must define bindTools method

System Info

"@langchain/core": "^0.3.32",
"@langchain/langgraph": "^0.2.41",
"@langchain/yandex": "^0.1.0"

Bun 1.1.43

Copy link

dosubot bot commented Jan 20, 2025

Hi @morigs 👋, I'm here to help you with any issues you're facing. I'm a bot designed to assist you in solving bugs, answering questions, and becoming a contributor.

The error you're encountering occurs because the ChatYandexGPT model does not implement the bindTools method, which is required by the createReactAgent function. This method is necessary for binding tools to the language model, allowing it to utilize them during its operation [1].

To resolve this issue, you need to ensure that the ChatYandexGPT model implements the bindTools method. If it doesn't, you can create a wrapper around the ChatYandexGPT model to add this functionality. Here's a basic example of how you might implement such a wrapper:

class ChatYandexGPTWithTools extends ChatYandexGPT {
  bindTools(tools) {
    // Implement the logic to bind tools to the model
    // This might involve storing the tools and using them in the model's methods
    this.tools = tools;
  }
}

// Use the wrapped model with createReactAgent
const agent = createReactAgent({
  llm: new ChatYandexGPTWithTools({ temperature: 0 }),
  tools: [],
  checkpointSaver: new MemorySaver(),
});

This example assumes you have a way to integrate the tools into the model's operation. You will need to adapt the bindTools method to fit the specific requirements of your tools and how they should interact with the ChatYandexGPT model.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Jan 20, 2025
@jacoblee93
Copy link
Collaborator

Yeah only certain providers support tool calling. It's a model-specific feature so I'm not sure there's much we can do about it as I don't have access to Yandex models.

@tyumentsev4 maybe can weigh in?

@morigs
Copy link
Author

morigs commented Jan 22, 2025

YandexGPT supports function calling as for now.
So as far as I understand the issue is with the langchain adapter not binding tools to the YandexGPT API

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

2 participants