|
24 | 24 | "etc..." |
25 | 25 | ] |
26 | 26 | }, |
27 | | - { |
28 | | - "cell_type": "code", |
29 | | - "execution_count": 1, |
30 | | - "id": "653b4ff2-bde5-408b-afd6-14fd804399d0", |
31 | | - "metadata": {}, |
32 | | - "outputs": [], |
33 | | - "source": [ |
34 | | - "# Setup API Key\n", |
35 | | - "\n", |
36 | | - "f = open('keys/.openai_api_key.txt')\n", |
37 | | - "\n", |
38 | | - "OPENAI_API_KEY = f.read()" |
39 | | - ] |
40 | | - }, |
41 | 27 | { |
42 | 28 | "cell_type": "markdown", |
43 | 29 | "id": "5567d306-c0bd-4c14-ab46-8710bcf1d132", |
|
50 | 36 | }, |
51 | 37 | { |
52 | 38 | "cell_type": "code", |
53 | | - "execution_count": 2, |
| 39 | + "execution_count": 1, |
54 | 40 | "id": "fb66a263-96cc-42d2-9ccb-eecda7950b5d", |
55 | 41 | "metadata": {}, |
56 | 42 | "outputs": [], |
57 | 43 | "source": [ |
58 | | - "from langchain.output_parsers import CommaSeparatedListOutputParser\n", |
| 44 | + "from langchain_core.output_parsers import CommaSeparatedListOutputParser\n", |
59 | 45 | "\n", |
60 | 46 | "output_parser = CommaSeparatedListOutputParser()" |
61 | 47 | ] |
62 | 48 | }, |
63 | 49 | { |
64 | 50 | "cell_type": "code", |
65 | | - "execution_count": 3, |
| 51 | + "execution_count": 2, |
66 | 52 | "id": "bb683e6d-7d19-4bcc-92c1-a7993686d999", |
67 | 53 | "metadata": {}, |
68 | 54 | "outputs": [ |
|
72 | 58 | "'Your response should be a list of comma separated values, eg: `foo, bar, baz`'" |
73 | 59 | ] |
74 | 60 | }, |
75 | | - "execution_count": 3, |
| 61 | + "execution_count": 2, |
76 | 62 | "metadata": {}, |
77 | 63 | "output_type": "execute_result" |
78 | 64 | } |
|
85 | 71 | }, |
86 | 72 | { |
87 | 73 | "cell_type": "code", |
88 | | - "execution_count": 4, |
| 74 | + "execution_count": 3, |
89 | 75 | "id": "d19eb38e-6fc3-48c1-bd6e-c33c3790fbf7", |
90 | 76 | "metadata": {}, |
91 | 77 | "outputs": [ |
|
95 | 81 | "['Python', 'DA', 'SQL', 'ML', 'DL']" |
96 | 82 | ] |
97 | 83 | }, |
98 | | - "execution_count": 4, |
| 84 | + "execution_count": 3, |
99 | 85 | "metadata": {}, |
100 | 86 | "output_type": "execute_result" |
101 | 87 | } |
|
109 | 95 | }, |
110 | 96 | { |
111 | 97 | "cell_type": "code", |
112 | | - "execution_count": 5, |
| 98 | + "execution_count": 17, |
113 | 99 | "id": "67f5242f-1517-4b77-bb01-2507894a6fbe", |
114 | 100 | "metadata": {}, |
115 | | - "outputs": [], |
| 101 | + "outputs": [ |
| 102 | + { |
| 103 | + "data": { |
| 104 | + "text/plain": [ |
| 105 | + "[SystemMessagePromptTemplate(prompt=PromptTemplate(input_variables=[], template='You are a helpful AI Chef.')),\n", |
| 106 | + " HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['dish_name', 'output_format_instructions'], template='Give me the ingredients for cooking {dish_name}. {output_format_instructions}'))]" |
| 107 | + ] |
| 108 | + }, |
| 109 | + "execution_count": 17, |
| 110 | + "metadata": {}, |
| 111 | + "output_type": "execute_result" |
| 112 | + } |
| 113 | + ], |
116 | 114 | "source": [ |
117 | 115 | "from langchain_core.prompts import ChatPromptTemplate\n", |
118 | 116 | "\n", |
119 | 117 | "prompt_template = ChatPromptTemplate.from_messages([\n", |
120 | 118 | " (\"system\", \"You are a helpful AI Chef.\"),\n", |
121 | 119 | " (\"human\", \"Give me the ingredients for cooking {dish_name}. {output_format_instructions}\"),\n", |
122 | | - "])" |
| 120 | + "])\n", |
| 121 | + "\n", |
| 122 | + "prompt_template.messages" |
| 123 | + ] |
| 124 | + }, |
| 125 | + { |
| 126 | + "cell_type": "code", |
| 127 | + "execution_count": 18, |
| 128 | + "id": "653b4ff2-bde5-408b-afd6-14fd804399d0", |
| 129 | + "metadata": {}, |
| 130 | + "outputs": [], |
| 131 | + "source": [ |
| 132 | + "# Setup API Key\n", |
| 133 | + "\n", |
| 134 | + "f = open('keys/.openai_api_key.txt')\n", |
| 135 | + "\n", |
| 136 | + "OPENAI_API_KEY = f.read()" |
123 | 137 | ] |
124 | 138 | }, |
125 | 139 | { |
126 | 140 | "cell_type": "code", |
127 | | - "execution_count": 6, |
| 141 | + "execution_count": 19, |
128 | 142 | "id": "b734ae2c-bb0c-40a7-9e67-586eede34f7a", |
129 | 143 | "metadata": {}, |
130 | 144 | "outputs": [], |
|
137 | 151 | }, |
138 | 152 | { |
139 | 153 | "cell_type": "code", |
140 | | - "execution_count": 7, |
| 154 | + "execution_count": 20, |
141 | 155 | "id": "d5a6a423-ae97-4536-a898-ae9322478d22", |
142 | 156 | "metadata": {}, |
143 | 157 | "outputs": [], |
|
147 | 161 | }, |
148 | 162 | { |
149 | 163 | "cell_type": "code", |
150 | | - "execution_count": 8, |
| 164 | + "execution_count": 21, |
151 | 165 | "id": "f7fe8e3d-f2b8-4008-ac02-bc00f6bff39d", |
152 | 166 | "metadata": {}, |
153 | 167 | "outputs": [ |
|
156 | 170 | "text/plain": [ |
157 | 171 | "['paneer',\n", |
158 | 172 | " 'basmati rice',\n", |
| 173 | + " 'yogurt',\n", |
159 | 174 | " 'onions',\n", |
160 | 175 | " 'tomatoes',\n", |
161 | | - " 'yogurt',\n", |
162 | | - " 'ginger-garlic paste',\n", |
| 176 | + " 'ginger',\n", |
| 177 | + " 'garlic',\n", |
163 | 178 | " 'green chilies',\n", |
164 | | - " 'cilantro',\n", |
165 | | - " 'mint leaves',\n", |
166 | | - " 'garam masala',\n", |
167 | | - " 'turmeric powder',\n", |
168 | | - " 'red chili powder',\n", |
169 | | - " 'cumin seeds',\n", |
170 | | - " 'cinnamon',\n", |
171 | | - " 'cardamom',\n", |
172 | | - " 'cloves',\n", |
173 | | - " 'bay leaves',\n", |
174 | | - " 'saffron strands',\n", |
| 179 | + " 'biryani masala',\n", |
175 | 180 | " 'ghee',\n", |
| 181 | + " 'mint leaves',\n", |
| 182 | + " 'coriander leaves',\n", |
| 183 | + " 'saffron',\n", |
| 184 | + " 'milk',\n", |
| 185 | + " 'salt',\n", |
176 | 186 | " 'oil',\n", |
177 | | - " 'salt']" |
| 187 | + " 'spices']" |
178 | 188 | ] |
179 | 189 | }, |
180 | | - "execution_count": 8, |
| 190 | + "execution_count": 21, |
181 | 191 | "metadata": {}, |
182 | 192 | "output_type": "execute_result" |
183 | 193 | } |
|
200 | 210 | }, |
201 | 211 | { |
202 | 212 | "cell_type": "code", |
203 | | - "execution_count": 9, |
| 213 | + "execution_count": 22, |
204 | 214 | "id": "072bd02b-c06d-4d05-97b2-f62862e8dcc2", |
205 | 215 | "metadata": {}, |
206 | 216 | "outputs": [], |
|
212 | 222 | }, |
213 | 223 | { |
214 | 224 | "cell_type": "code", |
215 | | - "execution_count": 10, |
| 225 | + "execution_count": 23, |
216 | 226 | "id": "00755d45-e38a-4c09-8412-c12eb4540175", |
217 | 227 | "metadata": {}, |
218 | 228 | "outputs": [ |
219 | 229 | { |
220 | 230 | "data": { |
221 | 231 | "text/plain": [ |
222 | | - "\"Write a datetime string that matches the following pattern: '%Y-%m-%dT%H:%M:%S.%fZ'.\\n\\nExamples: 1954-03-17T22:08:55.730057Z, 0137-07-03T04:19:03.372185Z, 1525-07-14T06:53:07.534119Z\\n\\nReturn ONLY this string, no other words!\"" |
| 232 | + "\"Write a datetime string that matches the following pattern: '%Y-%m-%dT%H:%M:%S.%fZ'.\\n\\nExamples: 0789-09-27T20:15:58.070587Z, 0146-06-12T19:06:59.697461Z, 1178-01-28T21:50:31.033531Z\\n\\nReturn ONLY this string, no other words!\"" |
223 | 233 | ] |
224 | 234 | }, |
225 | | - "execution_count": 10, |
| 235 | + "execution_count": 23, |
226 | 236 | "metadata": {}, |
227 | 237 | "output_type": "execute_result" |
228 | 238 | } |
|
235 | 245 | }, |
236 | 246 | { |
237 | 247 | "cell_type": "code", |
238 | | - "execution_count": 11, |
| 248 | + "execution_count": 24, |
239 | 249 | "id": "3bd3acd4-2cda-4776-a90c-968e87133d9f", |
240 | 250 | "metadata": {}, |
241 | 251 | "outputs": [], |
|
253 | 263 | }, |
254 | 264 | { |
255 | 265 | "cell_type": "code", |
256 | | - "execution_count": 12, |
| 266 | + "execution_count": 25, |
257 | 267 | "id": "c18efe6f-b8d4-4839-b8d0-8cfc01fc3587", |
258 | 268 | "metadata": {}, |
259 | 269 | "outputs": [], |
|
266 | 276 | }, |
267 | 277 | { |
268 | 278 | "cell_type": "code", |
269 | | - "execution_count": 13, |
| 279 | + "execution_count": 26, |
270 | 280 | "id": "69182c25-2ba5-4ad4-9287-41b31011880f", |
271 | 281 | "metadata": {}, |
272 | 282 | "outputs": [ |
|
276 | 286 | "datetime.datetime(1947, 8, 15, 0, 0)" |
277 | 287 | ] |
278 | 288 | }, |
279 | | - "execution_count": 13, |
| 289 | + "execution_count": 26, |
280 | 290 | "metadata": {}, |
281 | 291 | "output_type": "execute_result" |
282 | 292 | } |
|
0 commit comments