Skip to content

groq[patch]: Support generic messages in messageToGroqRole #8078

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

grace0950
Copy link

Description

This PR adds support for handling generic message types in the messageToGroqRole function within libs/langchain-groq/src/chat_models.ts.

Previously, the Groq integration did not properly handle messages of type generic, which could result in runtime errors.
This update introduces a new helper function extractGenericMessageCustomRole to correctly map these messages.

🛠️ Changes

  • Added extractGenericMessageCustomRole function to handle ChatMessage with generic type.
  • Updated messageToGroqRole to properly support generic messages.

📢 Notes

  • This change is backward compatible.
  • No external dependencies were introduced.
  • No changes to yarn.lock or workspace configurations.

Copy link

vercel bot commented Apr 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 28, 2025 4:24pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ⬜️ Ignored (Inspect) Apr 28, 2025 4:24pm

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. auto:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Apr 26, 2025
@benjamincburns
Copy link
Collaborator

Hi @grace0950. Thanks for the contribution. In order to merge this you'll need to fix the formatting issue by running yarn format.

I'm also wondering, are you using generic messages? if so, for what purpose?

@grace0950
Copy link
Author

Hi @grace0950. Thanks for the contribution. In order to merge this you'll need to fix the formatting issue by running yarn format.

I'm also wondering, are you using generic messages? if so, for what purpose?

Hi! Thanks for the review.

  • I have already run yarn format locally and ensured there are no formatting issues now.

Regarding your question:
Yes, we are using generic messages in our application.
Specifically, we create previous conversation history manually by instantiating new ChatMessage objects, where we directly provide the content and role.
In this case, the message type will be generic, which is why we need proper support for handling it.

Please let me know if there’s anything else I should update!

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 size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants