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

Amazon Nova function calling not work #7349

Open
5 tasks done
anilguleroglu opened this issue Dec 11, 2024 · 2 comments
Open
5 tasks done

Amazon Nova function calling not work #7349

anilguleroglu opened this issue Dec 11, 2024 · 2 comments
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@anilguleroglu
Copy link

anilguleroglu commented Dec 11, 2024

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 { ChatBedrockConverse } = require("@langchain/aws");
const { createReactAgent } = require("@langchain/langgraph/prebuilt");
const {
  DuckDuckGoSearch,
} = require("@langchain/community/tools/duckduckgo_search");
const { HumanMessage } = require("@langchain/core/messages");
const DDG = require("duck-duck-scrape");
const { tool } = require("@langchain/core/tools");
const { z } = require("zod");
const accessKey = "";
const secretAccessKey = "";
const main = async () => {
  const chatModel = new ChatBedrockConverse({
    model: "amazon.nova-pro-v1:0",
    region: "us-east-1",

    credentials: {
      accessKeyId: accessKey,
      secretAccessKey: secretAccessKey,
    },
    temperature: 0.5,
    verbose: true,
  });

  const tools = [
    tool(
      async ({ query }) => {
        const searchResults = await DDG.search(query, {
          safeSearch: DDG.SafeSearchType.STRICT,
        });

        return JSON.stringify(searchResults);
      },
      {
        name: "search",
        description: "use when you need search online",
        schema: z.object({
          query: z.string().describe("Query for search"),
        }),
      }
    ),
  ];
  chatModel.bindTools(tools, {
    tool_choice: "any",
  });
  const app = createReactAgent({
    llm: chatModel,
    tools,
  });

  const result = await app.invoke({
    messages: [new HumanMessage("what is the current weather in sf?")],
  });
  const output = result.messages[result.messages?.length - 1].content;
  console.log(output);
};

main();

Error Message and Stack Trace (if applicable)

No response

Description

When I change model with llama models functions works but with Amazon nova functions not work.

System Info

Latest version

@anilguleroglu anilguleroglu changed the title Amazon Nova dunction calling not work Amazon Nova function calling not work Dec 11, 2024
Copy link

dosubot bot commented Dec 11, 2024

Hello, @anilguleroglu! 👋 I'm here to assist you with any bugs, questions, or contributions. Let's squash those bugs together!

The issue you're experiencing with the Amazon Nova model in LangChain.js is likely due to the fact that the functions and function_call options are explicitly unsupported in the ChatNovitaAI class, which is related to the Amazon Nova model. The code for this class omits these options from the ChatNovitaCallOptions and removes them from the request in the completionWithRetry method. This is why the Amazon Nova function does not work with the Novita model in your LangChain.js code [1].

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 Dec 11, 2024
@inno-elon
Copy link

Any update on this? It seems that the tool gets bound to the model and attempts to invoke the tool, but i can see when it comes back from the chain the tool's type is 'not_implemented'

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