diff --git a/docs/core_docs/docs/integrations/chat/groq.ipynb b/docs/core_docs/docs/integrations/chat/groq.ipynb index b2f56ae48e2e..76ad7bff7d89 100644 --- a/docs/core_docs/docs/integrations/chat/groq.ipynb +++ b/docs/core_docs/docs/integrations/chat/groq.ipynb @@ -103,10 +103,7 @@ " 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: { type: \"json_object\" } });" + "})" ] }, { @@ -177,6 +174,50 @@ "console.log(aiMsg.content)" ] }, + { + "cell_type": "markdown", + "id": "ce0414fe", + "metadata": {}, + "source": [ + "## Json invocation" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3f0a7a2a", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " aiInvokeMsgContent: '{\\n\"result\": 6\\n}',\n", + " aiBindMsg: '{\\n\"result\": 6\\n}'\n", + "}\n" + ] + } + ], + "source": [ + "const messages = [\n", + " [\n", + " \"system\",\n", + " \"You are a math tutor that handles math exercises and makes output in json in format { result: number }.\",\n", + " ],\n", + " [\"human\", \"2 + 2 * 2\"],\n", + "];\n", + "\n", + "const aiInvokeMsg = await llm.invoke(messages, { response_format: { type: \"json_object\" } });\n", + "\n", + "// if you want not to pass response_format in every invoke, you can bind it to the instance\n", + "const llmWithResponseFormat = llm.bind({ response_format: { type: \"json_object\" } });\n", + "const aiBindMsg = await llmWithResponseFormat.invoke(messages);\n", + "\n", + "// they are the same\n", + "console.log({ aiInvokeMsgContent: aiInvokeMsg.content, aiBindMsg: aiBindMsg.content });" + ] + }, { "cell_type": "markdown", "id": "18e2bfc0-7e78-4528-a73f-499ac150dca8", @@ -189,7 +230,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b", "metadata": {}, "outputs": [ @@ -250,20 +291,18 @@ ], "metadata": { "kernelspec": { - "display_name": "TypeScript", + "display_name": "Deno", "language": "typescript", - "name": "tslab" + "name": "deno" }, "language_info": { - "codemirror_mode": { - "mode": "typescript", - "name": "javascript", - "typescript": true - }, + "codemirror_mode": "typescript", "file_extension": ".ts", - "mimetype": "text/typescript", + "mimetype": "text/x.typescript", "name": "typescript", - "version": "3.7.2" + "nbconvert_exporter": "script", + "pygments_lexer": "typescript", + "version": "5.5.2" } }, "nbformat": 4,