Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions libs/langchain-groq/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,6 @@ function convertMessagesToGroqParams(
messages: BaseMessage[]
): Array<ChatCompletionsAPI.ChatCompletionMessage> {
return messages.map((message): ChatCompletionsAPI.ChatCompletionMessage => {
if (typeof message.content !== "string") {
throw new Error("Non string message content not supported");
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const completionParam: Record<string, any> = {
role: messageToGroqRole(message),
Expand Down
29 changes: 29 additions & 0 deletions libs/langchain-groq/src/tests/chat_models.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,32 @@ test("response metadata includes groq metadata when streaming", async () => {
// console.dir(finalRes, { depth: Infinity });
expect(finalRes?.response_metadata.x_groq?.id).toBeDefined();
});

test("invoke with image input", async () => {
const chat = new ChatGroq({
maxRetries: 0,
model: "meta-llama/llama-4-scout-17b-16e-instruct",
});
const message = new HumanMessage({
content: [
{
type: "text",
text: "What's in this image?",
},
{
type: "image_url",
image_url: {
url: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png",
},
},
],
});
const res = await chat.invoke([message]);

expect(res.content.length).toBeGreaterThan(10);
expect(typeof res.content).toBe("string");
// The response should contain some reference to Google or logo
expect((res.content as string).toLowerCase()).toMatch(
/google|logo|text|image/
);
});