Closed yharaskrik closed 3 months ago
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! 🤖
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.
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.
Amazing thank you Brace! That's pretty much what I determined as well. I went to try and do it myself but only got so far as copying the code from the common package for those functions. I'm sure there's a better way just not familiar with the structure of all the packages!
Thanks!
On Mon, May 20, 2024, 11:11 AM Brace Sproul @.***> wrote:
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.
— Reply to this email directly, view it on GitHub https://github.com/langchain-ai/langchainjs/issues/5484#issuecomment-2120954193, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACIHZITXNRW2OJXSVPZHXNTZDI4GNAVCNFSM6AAAAABIAD455GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRQHE2TIMJZGM . You are receiving this because you were mentioned.Message ID: @.***>
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!
To implement the withStructuredOutput
function in the @langchain/google-genai
package, follow these steps:
Fork and Clone the Repository: Fork the langchainjs
repository to your account and clone it locally.
Set Up Your Development Environment: Ensure Node.js (v18+) is installed. Run yarn install
in the repository's root to install dependencies.
Create a New Branch: Use git checkout -b feature/withStructuredOutput
to create a branch for your changes.
Implement withStructuredOutput
:
langchain-core/src/language_models
.withStructuredOutput
function in the relevant TypeScript files. Follow the project's coding standards and ensure compatibility with existing patterns.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.
Commit and Push Your Changes: After testing, commit your changes and push them to your fork.
Open a Pull Request (PR): From your fork, open a PR to the main langchainjs
repository. Describe your changes and their motivation clearly.
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.
To continue the conversation, mention @dosu.
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.
same with groq
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
The
ChatGoogleGenerativeAI
class has thewithStructuredOutput
function on it, but it isundefined
. If it is not implemented for this model then it should not be on the types.System Info
Mac yarn 1.22.7 node 18.20.2