|
58 | 58 | "cell_type": "markdown",
|
59 | 59 | "id": "72ee0c4b-9764-423a-9dbf-95129e185210",
|
60 | 60 | "metadata": {},
|
61 |
| - "source": "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:" |
| 61 | + "source": [ |
| 62 | + "To enable automated tracing of your model calls, set your [LangSmith](https://docs.smith.langchain.com/) API key:" |
| 63 | + ] |
62 | 64 | },
|
63 | 65 | {
|
64 | 66 | "cell_type": "code",
|
|
98 | 100 | "source": [
|
99 | 101 | "## Instantiation\n",
|
100 | 102 | "\n",
|
101 |
| - "Now we can instantiate our model object and generate chat completions:" |
| 103 | + "Now we can instantiate our model object and generate chat completions. \n", |
| 104 | + "\n", |
| 105 | + "\n", |
| 106 | + ":::note Reasoning Format\n", |
| 107 | + "\n", |
| 108 | + "If you choose to set a `reasoning_format`, you must ensure that the model you are using supports it. You can find a list of supported models in the [Groq documentation](https://console.groq.com/docs/reasoning).\n", |
| 109 | + "\n", |
| 110 | + ":::" |
102 | 111 | ]
|
103 | 112 | },
|
104 | 113 | {
|
105 | 114 | "cell_type": "code",
|
106 |
| - "execution_count": 1, |
| 115 | + "execution_count": 6, |
107 | 116 | "id": "cb09c344-1836-4e0c-acf8-11d13ac1dbae",
|
108 | 117 | "metadata": {},
|
109 | 118 | "outputs": [],
|
110 | 119 | "source": [
|
111 | 120 | "from langchain_groq import ChatGroq\n",
|
112 | 121 | "\n",
|
113 | 122 | "llm = ChatGroq(\n",
|
114 |
| - " model=\"llama-3.1-8b-instant\",\n", |
| 123 | + " model=\"deepseek-r1-distill-llama-70b\",\n", |
115 | 124 | " temperature=0,\n",
|
116 | 125 | " max_tokens=None,\n",
|
| 126 | + " reasoning_format=\"parsed\",\n", |
117 | 127 | " timeout=None,\n",
|
118 | 128 | " max_retries=2,\n",
|
119 | 129 | " # other params...\n",
|
|
130 | 140 | },
|
131 | 141 | {
|
132 | 142 | "cell_type": "code",
|
133 |
| - "execution_count": 2, |
| 143 | + "execution_count": 7, |
134 | 144 | "id": "62e0dbc3",
|
135 | 145 | "metadata": {
|
136 | 146 | "tags": []
|
|
139 | 149 | {
|
140 | 150 | "data": {
|
141 | 151 | "text/plain": [
|
142 |
| - "AIMessage(content='The translation of \"I love programming\" to French is:\\n\\n\"J\\'adore le programmation.\"', additional_kwargs={}, response_metadata={'token_usage': {'completion_tokens': 22, 'prompt_tokens': 55, 'total_tokens': 77, 'completion_time': 0.029333333, 'prompt_time': 0.003502892, 'queue_time': 0.553054073, 'total_time': 0.032836225}, 'model_name': 'llama-3.1-8b-instant', 'system_fingerprint': 'fp_a491995411', 'finish_reason': 'stop', 'logprobs': None}, id='run-2b2da04a-993c-40ab-becc-201eab8b1a1b-0', usage_metadata={'input_tokens': 55, 'output_tokens': 22, 'total_tokens': 77})" |
| 152 | + "AIMessage(content=\"J'aime la programmation.\", additional_kwargs={'reasoning_content': 'Okay, so I need to translate the sentence \"I love programming.\" into French. Let me think about how to approach this. \\n\\nFirst, I know that \"I\" in French is \"Je.\" That\\'s straightforward. Now, the verb \"love\" in French is \"aime\" when referring to oneself. So, \"I love\" would be \"J\\'aime.\" \\n\\nNext, the word \"programming.\" In French, programming is \"la programmation.\" But wait, in French, when you talk about loving an activity, you often use the definite article. So, it would be \"la programmation.\" \\n\\nPutting it all together, \"I love programming\" becomes \"J\\'aime la programmation.\" That sounds right. I think that\\'s the correct translation. \\n\\nI should double-check to make sure I\\'m not missing anything. Maybe I can think of similar phrases. For example, \"I love reading\" is \"J\\'aime lire,\" but when it\\'s a noun, like \"I love music,\" it\\'s \"J\\'aime la musique.\" So, yes, using \"la programmation\" makes sense here. \\n\\nI don\\'t think I need to change anything else. The sentence structure in French is Subject-Verb-Object, just like in English, so \"J\\'aime la programmation\" should be correct. \\n\\nI guess another way to say it could be \"J\\'adore la programmation,\" using \"adore\" instead of \"aime,\" but \"aime\" is more commonly used in this context. So, sticking with \"J\\'aime la programmation\" is probably the best choice.\\n'}, response_metadata={'token_usage': {'completion_tokens': 346, 'prompt_tokens': 23, 'total_tokens': 369, 'completion_time': 1.447541218, 'prompt_time': 0.000983386, 'queue_time': 0.009673684, 'total_time': 1.448524604}, 'model_name': 'deepseek-r1-distill-llama-70b', 'system_fingerprint': 'fp_e98d30d035', 'finish_reason': 'stop', 'logprobs': None}, id='run--5679ae4f-f4e8-4931-bcd5-7304223832c0-0', usage_metadata={'input_tokens': 23, 'output_tokens': 346, 'total_tokens': 369})" |
143 | 153 | ]
|
144 | 154 | },
|
145 |
| - "execution_count": 2, |
| 155 | + "execution_count": 7, |
146 | 156 | "metadata": {},
|
147 | 157 | "output_type": "execute_result"
|
148 | 158 | }
|
|
161 | 171 | },
|
162 | 172 | {
|
163 | 173 | "cell_type": "code",
|
164 |
| - "execution_count": 3, |
| 174 | + "execution_count": 8, |
165 | 175 | "id": "d86145b3-bfef-46e8-b227-4dda5c9c2705",
|
166 | 176 | "metadata": {},
|
167 | 177 | "outputs": [
|
168 | 178 | {
|
169 | 179 | "name": "stdout",
|
170 | 180 | "output_type": "stream",
|
171 | 181 | "text": [
|
172 |
| - "The translation of \"I love programming\" to French is:\n", |
173 |
| - "\n", |
174 |
| - "\"J'adore le programmation.\"\n" |
| 182 | + "J'aime la programmation.\n" |
175 | 183 | ]
|
176 | 184 | }
|
177 | 185 | ],
|
|
191 | 199 | },
|
192 | 200 | {
|
193 | 201 | "cell_type": "code",
|
194 |
| - "execution_count": 4, |
| 202 | + "execution_count": 9, |
195 | 203 | "id": "e197d1d7-a070-4c96-9f8a-a0e86d046e0b",
|
196 | 204 | "metadata": {},
|
197 | 205 | "outputs": [
|
198 | 206 | {
|
199 | 207 | "data": {
|
200 | 208 | "text/plain": [
|
201 |
| - "AIMessage(content='Ich liebe Programmieren.', additional_kwargs={}, response_metadata={'token_usage': {'completion_tokens': 6, 'prompt_tokens': 50, 'total_tokens': 56, 'completion_time': 0.008, 'prompt_time': 0.003337935, 'queue_time': 0.20949214500000002, 'total_time': 0.011337935}, 'model_name': 'llama-3.1-8b-instant', 'system_fingerprint': 'fp_a491995411', 'finish_reason': 'stop', 'logprobs': None}, id='run-e33b48dc-5e55-466e-9ebd-7b48c81c3cbd-0', usage_metadata={'input_tokens': 50, 'output_tokens': 6, 'total_tokens': 56})" |
| 209 | + "AIMessage(content='The translation of \"I love programming\" into German is \"Ich liebe das Programmieren.\" \\n\\n**Step-by-Step Explanation:**\\n\\n1. **Subject Pronoun:** \"I\" translates to \"Ich.\"\\n2. **Verb Conjugation:** \"Love\" becomes \"liebe\" (first person singular of \"lieben\").\\n3. **Gerund Translation:** \"Programming\" is translated using the infinitive noun \"Programmieren.\"\\n4. **Article Usage:** The definite article \"das\" is included before the infinitive noun for natural phrasing.\\n\\nThus, the complete and natural translation is:\\n\\n**Ich liebe das Programmieren.**', additional_kwargs={'reasoning_content': 'Okay, so I need to translate the sentence \"I love programming.\" into German. Hmm, let\\'s break this down. \\n\\nFirst, \"I\" in German is \"Ich.\" That\\'s straightforward. Now, \"love\" translates to \"liebe.\" Wait, but in German, the verb conjugation depends on the subject. Since it\\'s \"I,\" the verb would be \"liebe\" because \"lieben\" is the infinitive, and for first person singular, it\\'s \"liebe.\" \\n\\nNext, \"programming\" is a gerund in English, which is the -ing form. In German, the equivalent would be the present participle, which is \"programmierend.\" But wait, sometimes in German, they use the noun form instead of the gerund. So maybe it\\'s better to say \"Ich liebe das Programmieren.\" Because \"Programmieren\" is the infinitive noun form, and it\\'s commonly used in such contexts. \\n\\nLet me think again. \"I love programming\" could be directly translated as \"Ich liebe Programmieren,\" but I\\'ve heard both \"Programmieren\" and \"programmierend\" used. However, \"Ich liebe das Programmieren\" sounds more natural because it uses the definite article \"das\" before the infinitive noun. \\n\\nAlternatively, if I use \"programmieren\" without the article, it\\'s still correct but maybe a bit less common. So, to make it sound more natural and fluent, including the article \"das\" would be better. \\n\\nTherefore, the correct translation should be \"Ich liebe das Programmieren.\" That makes sense because it\\'s similar to saying \"I love (the act of) programming.\" \\n\\nI think that\\'s the most accurate and natural way to express it in German. Let me double-check some examples. If someone says \"I love reading,\" in German it\\'s \"Ich liebe das Lesen.\" So yes, using \"das\" before the infinitive noun is the correct structure. \\n\\nSo, putting it all together, \"I love programming\" becomes \"Ich liebe das Programmieren.\" That should be the right translation.\\n'}, response_metadata={'token_usage': {'completion_tokens': 569, 'prompt_tokens': 18, 'total_tokens': 587, 'completion_time': 2.511255685, 'prompt_time': 0.001466702, 'queue_time': 0.009628211, 'total_time': 2.512722387}, 'model_name': 'deepseek-r1-distill-llama-70b', 'system_fingerprint': 'fp_87eae35036', 'finish_reason': 'stop', 'logprobs': None}, id='run--4d5ee86d-5eec-495c-9c4e-261526cf6e3d-0', usage_metadata={'input_tokens': 18, 'output_tokens': 569, 'total_tokens': 587})" |
202 | 210 | ]
|
203 | 211 | },
|
204 |
| - "execution_count": 4, |
| 212 | + "execution_count": 9, |
205 | 213 | "metadata": {},
|
206 | 214 | "output_type": "execute_result"
|
207 | 215 | }
|
|
236 | 244 | "source": [
|
237 | 245 | "## API reference\n",
|
238 | 246 | "\n",
|
239 |
| - "For detailed documentation of all ChatGroq features and configurations head to the API reference: https://python.langchain.com/api_reference/groq/chat_models/langchain_groq.chat_models.ChatGroq.html" |
| 247 | + "For detailed documentation of all ChatGroq features and configurations head to the [API reference](https://python.langchain.com/api_reference/groq/chat_models/langchain_groq.chat_models.ChatGroq.html)." |
240 | 248 | ]
|
241 | 249 | }
|
242 | 250 | ],
|
|
0 commit comments