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

fix(groq): Feature/groq response format improvements #6754

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
5 changes: 4 additions & 1 deletion docs/core_docs/docs/integrations/chat/groq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
" maxTokens: undefined,\n",
" maxRetries: 2,\n",
" // other params...\n",
"})"
"})\n",
"\n",
"// if you need a response format other than the default\n",
"const llmWithResponseFormat = llm.bind({ response_format: \"json_object\" });"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or wait, does this need to be response_format: { type: "json_object" }? I think that's what OpenAI does

Copy link
Contributor Author

@allohamora allohamora Sep 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yes, fixed in 7c6250a
image

]
},
{
Expand Down
3 changes: 2 additions & 1 deletion libs/langchain-groq/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
ChatCompletionCreateParams,
ChatCompletionCreateParamsNonStreaming,
ChatCompletionCreateParamsStreaming,
CompletionCreateParams,
} from "groq-sdk/resources/chat/completions";
import {
Runnable,
Expand Down Expand Up @@ -73,7 +74,7 @@ export interface ChatGroqCallOptions extends BaseChatModelCallOptions {
headers?: Record<string, string>;
tools?: ChatGroqToolType[];
tool_choice?: OpenAIClient.ChatCompletionToolChoiceOption | "any" | string;
response_format?: { type: "json_object" };
response_format?: CompletionCreateParams.ResponseFormat;
}

export interface ChatGroqInput extends BaseChatModelParams {
Expand Down
Loading