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

withStructuredOutput is not a function on ChatGoogleGenerativeAI #5484

Closed
5 tasks done
yharaskrik opened this issue May 20, 2024 · 9 comments · Fixed by #5507
Closed
5 tasks done

withStructuredOutput is not a function on ChatGoogleGenerativeAI #5484

yharaskrik opened this issue May 20, 2024 · 9 comments · Fixed by #5507
Assignees
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@yharaskrik
Copy link

yharaskrik commented May 20, 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 genAi = new ChatGoogleGenerativeAI({});

console.log(genAi.withStructuredOutput); <-- yields undefined, calling it on the call results in below

Error Message and Stack Trace (if applicable)

}).withStructuredOutput(schema);
   ^

TypeError: (intermediate value).withStructuredOutput is not a function

Description

The ChatGoogleGenerativeAI class has the withStructuredOutput function on it, but it is undefined. If it is not implemented for this model then it should not be on the types.

        "@langchain/community": "^0.2.0",
        "@langchain/core": "^0.2.0",
        "@langchain/google-genai": "^0.0.14",
        "@langchain/openai": "^0.0.33",
        "@langchain/redis": "^0.0.5",
        "langchain": "^0.2.0",

System Info

Mac
yarn 1.22.7
node 18.20.2

Copy link

dosubot bot commented May 20, 2024

Hey there, @yharaskrik! 👋 I'm Dosu, a bot here to lend a hand with bugs, answer questions, and guide you through becoming a contributor while we wait for a human maintainer to join us. Think of me as your friendly digital sidekick in navigating the world of LangChain JS. I'm diving into your issue now and will get back to you with a full answer shortly. Hang tight! 🤖

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label May 20, 2024
@yharaskrik
Copy link
Author

Oh I see the withStructuredOutput function is optional on the abstract BaseLanguageModel class. My IDE was not reflecting that, so the ChatGoogleGenerativeAI is not implementing it and that is why it is undefined.

@bracesproul
Copy link
Collaborator

bracesproul commented May 20, 2024

The withStructuredOutput isn't implemented (or normal tool calling for that matter) in the @langchain/google-genai package. It's on my list to implement both sometime this week though! I'll use this issue as a tracker for when that goes in.

@bracesproul bracesproul self-assigned this May 20, 2024
@yharaskrik
Copy link
Author

yharaskrik commented May 20, 2024 via email

@bracesproul
Copy link
Collaborator

g

That's how I was planning on going about it as well! If you want to take a stab at it, I wouldn't start until tmro. So if you can put up a PR before tmro morning I would love to use your implementation!

Copy link

dosubot bot commented May 20, 2024

To implement the withStructuredOutput function in the @langchain/google-genai package, follow these steps:

  1. Fork and Clone the Repository: Fork the langchainjs repository to your account and clone it locally.

  2. Set Up Your Development Environment: Ensure Node.js (v18+) is installed. Run yarn install in the repository's root to install dependencies.

  3. Create a New Branch: Use git checkout -b feature/withStructuredOutput to create a branch for your changes.

  4. Implement withStructuredOutput:

    • Navigate to langchain-core/src/language_models.
    • Update or define the withStructuredOutput function in the relevant TypeScript files. Follow the project's coding standards and ensure compatibility with existing patterns.
  5. Build and Test Your Changes: Run yarn build to build the package and yarn test to ensure your changes don't break existing functionality. Add new tests if necessary.

  6. Commit and Push Your Changes: After testing, commit your changes and push them to your fork.

  7. Open a Pull Request (PR): From your fork, open a PR to the main langchainjs repository. Describe your changes and their motivation clearly.

  8. Review Process: Engage with any review feedback to refine your contribution.

This approach will help you contribute effectively to resolving the TypeError issue with withStructuredOutput in the @langchain/google-genai package.

Details

Sources


About Dosu
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.

To continue the conversation, mention @dosu.

@bitsnaps
Copy link

The same applies for huggingface inference API, I'm getting the error TypeError: llm.withStructuredOutput is not a function even with models supporting function calling.

@jason-allen-oneal
Copy link

same with groq

@pndtr
Copy link

pndtr commented Oct 7, 2024

Are there anyone is facing the issue that using withStructuredOutput not calling tool

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

Successfully merging a pull request may close this issue.

5 participants