Spaces:
Sleeping
Sleeping
Finalisation des calculs
Browse files- execution.ipynb +36 -352
- save/output_favarel_et_al.txt +1 -0
- save/output_sans_titre_1.txt +0 -0
- save/output_sans_titre_2.txt +1 -0
execution.ipynb
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
},
|
27 |
{
|
28 |
"cell_type": "code",
|
29 |
-
"execution_count":
|
30 |
"metadata": {},
|
31 |
"outputs": [],
|
32 |
"source": [
|
@@ -39,323 +39,7 @@
|
|
39 |
},
|
40 |
{
|
41 |
"cell_type": "code",
|
42 |
-
"execution_count":
|
43 |
-
"metadata": {},
|
44 |
-
"outputs": [
|
45 |
-
{
|
46 |
-
"data": {
|
47 |
-
"text/html": [
|
48 |
-
"<div>\n",
|
49 |
-
"<style scoped>\n",
|
50 |
-
" .dataframe tbody tr th:only-of-type {\n",
|
51 |
-
" vertical-align: middle;\n",
|
52 |
-
" }\n",
|
53 |
-
"\n",
|
54 |
-
" .dataframe tbody tr th {\n",
|
55 |
-
" vertical-align: top;\n",
|
56 |
-
" }\n",
|
57 |
-
"\n",
|
58 |
-
" .dataframe thead th {\n",
|
59 |
-
" text-align: right;\n",
|
60 |
-
" }\n",
|
61 |
-
"</style>\n",
|
62 |
-
"<table border=\"1\" class=\"dataframe\">\n",
|
63 |
-
" <thead>\n",
|
64 |
-
" <tr style=\"text-align: right;\">\n",
|
65 |
-
" <th></th>\n",
|
66 |
-
" <th>Unnamed: 0</th>\n",
|
67 |
-
" <th>item_id</th>\n",
|
68 |
-
" <th>date_published</th>\n",
|
69 |
-
" <th>url</th>\n",
|
70 |
-
" <th>titre</th>\n",
|
71 |
-
" <th>description</th>\n",
|
72 |
-
" <th>type</th>\n",
|
73 |
-
" <th>author</th>\n",
|
74 |
-
" <th>section</th>\n",
|
75 |
-
" <th>subhead</th>\n",
|
76 |
-
" <th>premium</th>\n",
|
77 |
-
" <th>image_url</th>\n",
|
78 |
-
" </tr>\n",
|
79 |
-
" </thead>\n",
|
80 |
-
" <tbody>\n",
|
81 |
-
" <tr>\n",
|
82 |
-
" <th>0</th>\n",
|
83 |
-
" <td>0</td>\n",
|
84 |
-
" <td>I4OEKQ6MHRBP3LQVVYDDXW6T6U</td>\n",
|
85 |
-
" <td>2024-10-07 15:33:34</td>\n",
|
86 |
-
" <td>https://www.liberation.fr/societe/familles/a-m...</td>\n",
|
87 |
-
" <td>Centre de loisirs à Marseille : sept plaintes ...</td>\n",
|
88 |
-
" <td>Une enquête pour violences sur mineurs et diff...</td>\n",
|
89 |
-
" <td>article</td>\n",
|
90 |
-
" <td>Caroline Delabroy</td>\n",
|
91 |
-
" <td>Familles</td>\n",
|
92 |
-
" <td>Justice</td>\n",
|
93 |
-
" <td>True</td>\n",
|
94 |
-
" <td>https://www.liberation.fr/resizer/E6tv2-_N7qhg...</td>\n",
|
95 |
-
" </tr>\n",
|
96 |
-
" <tr>\n",
|
97 |
-
" <th>1</th>\n",
|
98 |
-
" <td>1</td>\n",
|
99 |
-
" <td>LVA4MZBQOBECNPZD323NV6O7K4</td>\n",
|
100 |
-
" <td>2024-10-09 14:53:55</td>\n",
|
101 |
-
" <td>https://www.liberation.fr/sports/jeux-olympiqu...</td>\n",
|
102 |
-
" <td>JO de Paris 2024 : pour la santé mentale des a...</td>\n",
|
103 |
-
" <td>Avec la libération de la parole sur la santé m...</td>\n",
|
104 |
-
" <td>article</td>\n",
|
105 |
-
" <td>Marie Thimonnier</td>\n",
|
106 |
-
" <td>Jeux olympiques et paralympiques</td>\n",
|
107 |
-
" <td>Ecriture</td>\n",
|
108 |
-
" <td>True</td>\n",
|
109 |
-
" <td>https://www.liberation.fr/resizer/uAqwfrqGpk93...</td>\n",
|
110 |
-
" </tr>\n",
|
111 |
-
" <tr>\n",
|
112 |
-
" <th>2</th>\n",
|
113 |
-
" <td>2</td>\n",
|
114 |
-
" <td>4FAEHUUZ5ZFAJKLFEV2LT5CBAQ</td>\n",
|
115 |
-
" <td>2024-10-10 15:49:02</td>\n",
|
116 |
-
" <td>https://www.liberation.fr/international/afriqu...</td>\n",
|
117 |
-
" <td>Au Burkina Faso, la conscription pour «punir d...</td>\n",
|
118 |
-
" <td>Au moins sept magistrats ont été réquisitionné...</td>\n",
|
119 |
-
" <td>article</td>\n",
|
120 |
-
" <td>Agnès Faivre</td>\n",
|
121 |
-
" <td>Afrique</td>\n",
|
122 |
-
" <td>Répression</td>\n",
|
123 |
-
" <td>False</td>\n",
|
124 |
-
" <td>https://www.liberation.fr/resizer/_A-QaSGPPcHu...</td>\n",
|
125 |
-
" </tr>\n",
|
126 |
-
" <tr>\n",
|
127 |
-
" <th>3</th>\n",
|
128 |
-
" <td>3</td>\n",
|
129 |
-
" <td>4S4G6BKFRNER3LB22CLPAEWWKY</td>\n",
|
130 |
-
" <td>2024-10-11 15:28:25</td>\n",
|
131 |
-
" <td>https://www.liberation.fr/economie/social/ferm...</td>\n",
|
132 |
-
" <td>Fermeture de l’usine automobile MA France : «O...</td>\n",
|
133 |
-
" <td>Le 13 mai, l’entreprise sous-traitante de Stel...</td>\n",
|
134 |
-
" <td>article</td>\n",
|
135 |
-
" <td>Eléna Roney</td>\n",
|
136 |
-
" <td>Social</td>\n",
|
137 |
-
" <td>Lutte sociale</td>\n",
|
138 |
-
" <td>True</td>\n",
|
139 |
-
" <td>https://www.liberation.fr/resizer/6hlzuHlwTJFQ...</td>\n",
|
140 |
-
" </tr>\n",
|
141 |
-
" <tr>\n",
|
142 |
-
" <th>4</th>\n",
|
143 |
-
" <td>4</td>\n",
|
144 |
-
" <td>ZAFHRNAHJVC6THXRSBMCB4A24I</td>\n",
|
145 |
-
" <td>2024-10-09 10:55:05</td>\n",
|
146 |
-
" <td>https://www.liberation.fr/lifestyle/design/pre...</td>\n",
|
147 |
-
" <td>Près de Rouen, jardiner dans «un jeu subtil av...</td>\n",
|
148 |
-
" <td>Imaginé par Patrick et Sylvie Quibel il y a tr...</td>\n",
|
149 |
-
" <td>article</td>\n",
|
150 |
-
" <td>['Florian Bardou, envoyé spécial à Rouen', 'ph...</td>\n",
|
151 |
-
" <td>Design</td>\n",
|
152 |
-
" <td>Reportage</td>\n",
|
153 |
-
" <td>True</td>\n",
|
154 |
-
" <td>https://www.liberation.fr/resizer/goppJdUChU09...</td>\n",
|
155 |
-
" </tr>\n",
|
156 |
-
" <tr>\n",
|
157 |
-
" <th>...</th>\n",
|
158 |
-
" <td>...</td>\n",
|
159 |
-
" <td>...</td>\n",
|
160 |
-
" <td>...</td>\n",
|
161 |
-
" <td>...</td>\n",
|
162 |
-
" <td>...</td>\n",
|
163 |
-
" <td>...</td>\n",
|
164 |
-
" <td>...</td>\n",
|
165 |
-
" <td>...</td>\n",
|
166 |
-
" <td>...</td>\n",
|
167 |
-
" <td>...</td>\n",
|
168 |
-
" <td>...</td>\n",
|
169 |
-
" <td>...</td>\n",
|
170 |
-
" </tr>\n",
|
171 |
-
" <tr>\n",
|
172 |
-
" <th>511</th>\n",
|
173 |
-
" <td>516</td>\n",
|
174 |
-
" <td>AOT254SA2VDIDNF4YW7XPLWJ5E</td>\n",
|
175 |
-
" <td>2024-10-12 15:46:00</td>\n",
|
176 |
-
" <td>https://www.liberation.fr/culture/musique/char...</td>\n",
|
177 |
-
" <td>Charlie Dalin : «Mon oncle était le chanteur d...</td>\n",
|
178 |
-
" <td>Charlie Dalin, skipper qui s’apprête à embarqu...</td>\n",
|
179 |
-
" <td>article</td>\n",
|
180 |
-
" <td>Alexis Bernier</td>\n",
|
181 |
-
" <td>Musique</td>\n",
|
182 |
-
" <td>Casque t'écoutes?</td>\n",
|
183 |
-
" <td>False</td>\n",
|
184 |
-
" <td>https://www.liberation.fr/resizer/Oum9ZxntR4pt...</td>\n",
|
185 |
-
" </tr>\n",
|
186 |
-
" <tr>\n",
|
187 |
-
" <th>512</th>\n",
|
188 |
-
" <td>517</td>\n",
|
189 |
-
" <td>GUOUKHLPFZBK7GVR5XU7MXVD5A</td>\n",
|
190 |
-
" <td>2024-10-12 16:32:37</td>\n",
|
191 |
-
" <td>https://www.liberation.fr/societe/droits-des-f...</td>\n",
|
192 |
-
" <td>Violences sexuelles : à la recherche de «co-vi...</td>\n",
|
193 |
-
" <td>Avec un système de «matchs», le site Coabuse r...</td>\n",
|
194 |
-
" <td>article</td>\n",
|
195 |
-
" <td>Hélène Coutard</td>\n",
|
196 |
-
" <td>Droits des femmes</td>\n",
|
197 |
-
" <td>«Match»</td>\n",
|
198 |
-
" <td>True</td>\n",
|
199 |
-
" <td>https://www.liberation.fr/resizer/F5PeR7sIedRA...</td>\n",
|
200 |
-
" </tr>\n",
|
201 |
-
" <tr>\n",
|
202 |
-
" <th>513</th>\n",
|
203 |
-
" <td>518</td>\n",
|
204 |
-
" <td>5HT6C24ZBVDOBFXPLA4HNVOTT4</td>\n",
|
205 |
-
" <td>2024-10-12 16:33:57</td>\n",
|
206 |
-
" <td>https://www.liberation.fr/environnement/agricu...</td>\n",
|
207 |
-
" <td>«Plus ils habitent près des champs, plus les t...</td>\n",
|
208 |
-
" <td>Des traces de pesticides, dont certains interd...</td>\n",
|
209 |
-
" <td>article</td>\n",
|
210 |
-
" <td>[' LIBERATION', ' AFP']</td>\n",
|
211 |
-
" <td>Agriculture</td>\n",
|
212 |
-
" <td>Contamination</td>\n",
|
213 |
-
" <td>False</td>\n",
|
214 |
-
" <td>https://www.liberation.fr/resizer/VzMm-X_AuAhQ...</td>\n",
|
215 |
-
" </tr>\n",
|
216 |
-
" <tr>\n",
|
217 |
-
" <th>514</th>\n",
|
218 |
-
" <td>519</td>\n",
|
219 |
-
" <td>VLV6RSQ6U5E6XJ6AIRV26AEKO4</td>\n",
|
220 |
-
" <td>2024-10-12 16:43:33</td>\n",
|
221 |
-
" <td>https://www.liberation.fr/economie/annonces-de...</td>\n",
|
222 |
-
" <td>Annonces de la Chine contre la crise économiqu...</td>\n",
|
223 |
-
" <td>Face aux problèmes structurels de l’économie, ...</td>\n",
|
224 |
-
" <td>article</td>\n",
|
225 |
-
" <td>Arnaud Vaulerin</td>\n",
|
226 |
-
" <td>Economie</td>\n",
|
227 |
-
" <td>Analyse</td>\n",
|
228 |
-
" <td>True</td>\n",
|
229 |
-
" <td>https://www.liberation.fr/resizer/ZKreJUwCgQPk...</td>\n",
|
230 |
-
" </tr>\n",
|
231 |
-
" <tr>\n",
|
232 |
-
" <th>515</th>\n",
|
233 |
-
" <td>520</td>\n",
|
234 |
-
" <td>FVCJ6DQ5HVDNDGC4F6F276NVFM</td>\n",
|
235 |
-
" <td>2024-10-12 16:53:20</td>\n",
|
236 |
-
" <td>https://www.liberation.fr/economie/medias/budg...</td>\n",
|
237 |
-
" <td>Budget 2025 : les radios associatives dénoncen...</td>\n",
|
238 |
-
" <td>Les radios associatives se sont alarmées vendr...</td>\n",
|
239 |
-
" <td>article</td>\n",
|
240 |
-
" <td>[' LIBERATION', ' AFP']</td>\n",
|
241 |
-
" <td>Médias</td>\n",
|
242 |
-
" <td>Mauvaises ondes</td>\n",
|
243 |
-
" <td>False</td>\n",
|
244 |
-
" <td>https://www.liberation.fr/resizer/KVsBqITY61oN...</td>\n",
|
245 |
-
" </tr>\n",
|
246 |
-
" </tbody>\n",
|
247 |
-
"</table>\n",
|
248 |
-
"<p>516 rows × 12 columns</p>\n",
|
249 |
-
"</div>"
|
250 |
-
],
|
251 |
-
"text/plain": [
|
252 |
-
" Unnamed: 0 item_id date_published \\\n",
|
253 |
-
"0 0 I4OEKQ6MHRBP3LQVVYDDXW6T6U 2024-10-07 15:33:34 \n",
|
254 |
-
"1 1 LVA4MZBQOBECNPZD323NV6O7K4 2024-10-09 14:53:55 \n",
|
255 |
-
"2 2 4FAEHUUZ5ZFAJKLFEV2LT5CBAQ 2024-10-10 15:49:02 \n",
|
256 |
-
"3 3 4S4G6BKFRNER3LB22CLPAEWWKY 2024-10-11 15:28:25 \n",
|
257 |
-
"4 4 ZAFHRNAHJVC6THXRSBMCB4A24I 2024-10-09 10:55:05 \n",
|
258 |
-
".. ... ... ... \n",
|
259 |
-
"511 516 AOT254SA2VDIDNF4YW7XPLWJ5E 2024-10-12 15:46:00 \n",
|
260 |
-
"512 517 GUOUKHLPFZBK7GVR5XU7MXVD5A 2024-10-12 16:32:37 \n",
|
261 |
-
"513 518 5HT6C24ZBVDOBFXPLA4HNVOTT4 2024-10-12 16:33:57 \n",
|
262 |
-
"514 519 VLV6RSQ6U5E6XJ6AIRV26AEKO4 2024-10-12 16:43:33 \n",
|
263 |
-
"515 520 FVCJ6DQ5HVDNDGC4F6F276NVFM 2024-10-12 16:53:20 \n",
|
264 |
-
"\n",
|
265 |
-
" url \\\n",
|
266 |
-
"0 https://www.liberation.fr/societe/familles/a-m... \n",
|
267 |
-
"1 https://www.liberation.fr/sports/jeux-olympiqu... \n",
|
268 |
-
"2 https://www.liberation.fr/international/afriqu... \n",
|
269 |
-
"3 https://www.liberation.fr/economie/social/ferm... \n",
|
270 |
-
"4 https://www.liberation.fr/lifestyle/design/pre... \n",
|
271 |
-
".. ... \n",
|
272 |
-
"511 https://www.liberation.fr/culture/musique/char... \n",
|
273 |
-
"512 https://www.liberation.fr/societe/droits-des-f... \n",
|
274 |
-
"513 https://www.liberation.fr/environnement/agricu... \n",
|
275 |
-
"514 https://www.liberation.fr/economie/annonces-de... \n",
|
276 |
-
"515 https://www.liberation.fr/economie/medias/budg... \n",
|
277 |
-
"\n",
|
278 |
-
" titre \\\n",
|
279 |
-
"0 Centre de loisirs à Marseille : sept plaintes ... \n",
|
280 |
-
"1 JO de Paris 2024 : pour la santé mentale des a... \n",
|
281 |
-
"2 Au Burkina Faso, la conscription pour «punir d... \n",
|
282 |
-
"3 Fermeture de l’usine automobile MA France : «O... \n",
|
283 |
-
"4 Près de Rouen, jardiner dans «un jeu subtil av... \n",
|
284 |
-
".. ... \n",
|
285 |
-
"511 Charlie Dalin : «Mon oncle était le chanteur d... \n",
|
286 |
-
"512 Violences sexuelles : à la recherche de «co-vi... \n",
|
287 |
-
"513 «Plus ils habitent près des champs, plus les t... \n",
|
288 |
-
"514 Annonces de la Chine contre la crise économiqu... \n",
|
289 |
-
"515 Budget 2025 : les radios associatives dénoncen... \n",
|
290 |
-
"\n",
|
291 |
-
" description type \\\n",
|
292 |
-
"0 Une enquête pour violences sur mineurs et diff... article \n",
|
293 |
-
"1 Avec la libération de la parole sur la santé m... article \n",
|
294 |
-
"2 Au moins sept magistrats ont été réquisitionné... article \n",
|
295 |
-
"3 Le 13 mai, l’entreprise sous-traitante de Stel... article \n",
|
296 |
-
"4 Imaginé par Patrick et Sylvie Quibel il y a tr... article \n",
|
297 |
-
".. ... ... \n",
|
298 |
-
"511 Charlie Dalin, skipper qui s’apprête à embarqu... article \n",
|
299 |
-
"512 Avec un système de «matchs», le site Coabuse r... article \n",
|
300 |
-
"513 Des traces de pesticides, dont certains interd... article \n",
|
301 |
-
"514 Face aux problèmes structurels de l’économie, ... article \n",
|
302 |
-
"515 Les radios associatives se sont alarmées vendr... article \n",
|
303 |
-
"\n",
|
304 |
-
" author \\\n",
|
305 |
-
"0 Caroline Delabroy \n",
|
306 |
-
"1 Marie Thimonnier \n",
|
307 |
-
"2 Agnès Faivre \n",
|
308 |
-
"3 Eléna Roney \n",
|
309 |
-
"4 ['Florian Bardou, envoyé spécial à Rouen', 'ph... \n",
|
310 |
-
".. ... \n",
|
311 |
-
"511 Alexis Bernier \n",
|
312 |
-
"512 Hélène Coutard \n",
|
313 |
-
"513 [' LIBERATION', ' AFP'] \n",
|
314 |
-
"514 Arnaud Vaulerin \n",
|
315 |
-
"515 [' LIBERATION', ' AFP'] \n",
|
316 |
-
"\n",
|
317 |
-
" section subhead premium \\\n",
|
318 |
-
"0 Familles Justice True \n",
|
319 |
-
"1 Jeux olympiques et paralympiques Ecriture True \n",
|
320 |
-
"2 Afrique Répression False \n",
|
321 |
-
"3 Social Lutte sociale True \n",
|
322 |
-
"4 Design Reportage True \n",
|
323 |
-
".. ... ... ... \n",
|
324 |
-
"511 Musique Casque t'écoutes? False \n",
|
325 |
-
"512 Droits des femmes «Match» True \n",
|
326 |
-
"513 Agriculture Contamination False \n",
|
327 |
-
"514 Economie Analyse True \n",
|
328 |
-
"515 Médias Mauvaises ondes False \n",
|
329 |
-
"\n",
|
330 |
-
" image_url \n",
|
331 |
-
"0 https://www.liberation.fr/resizer/E6tv2-_N7qhg... \n",
|
332 |
-
"1 https://www.liberation.fr/resizer/uAqwfrqGpk93... \n",
|
333 |
-
"2 https://www.liberation.fr/resizer/_A-QaSGPPcHu... \n",
|
334 |
-
"3 https://www.liberation.fr/resizer/6hlzuHlwTJFQ... \n",
|
335 |
-
"4 https://www.liberation.fr/resizer/goppJdUChU09... \n",
|
336 |
-
".. ... \n",
|
337 |
-
"511 https://www.liberation.fr/resizer/Oum9ZxntR4pt... \n",
|
338 |
-
"512 https://www.liberation.fr/resizer/F5PeR7sIedRA... \n",
|
339 |
-
"513 https://www.liberation.fr/resizer/VzMm-X_AuAhQ... \n",
|
340 |
-
"514 https://www.liberation.fr/resizer/ZKreJUwCgQPk... \n",
|
341 |
-
"515 https://www.liberation.fr/resizer/KVsBqITY61oN... \n",
|
342 |
-
"\n",
|
343 |
-
"[516 rows x 12 columns]"
|
344 |
-
]
|
345 |
-
},
|
346 |
-
"execution_count": 10,
|
347 |
-
"metadata": {},
|
348 |
-
"output_type": "execute_result"
|
349 |
-
}
|
350 |
-
],
|
351 |
-
"source": [
|
352 |
-
"df = pd.read_csv('extract_sciences_po.csv')\n",
|
353 |
-
"df"
|
354 |
-
]
|
355 |
-
},
|
356 |
-
{
|
357 |
-
"cell_type": "code",
|
358 |
-
"execution_count": 8,
|
359 |
"metadata": {},
|
360 |
"outputs": [],
|
361 |
"source": [
|
@@ -381,8 +65,10 @@
|
|
381 |
"\n",
|
382 |
" if mapping_prompt[name]['client']=='deepseek':\n",
|
383 |
" client = OpenAI(api_key=keys[\"DEEPSEEK_API_KEY\"], base_url=\"https://api.deepseek.com\")\n",
|
|
|
384 |
" else:\n",
|
385 |
" client=OpenAI(api_key=keys['OPENAI_API_KEY'])\n",
|
|
|
386 |
"\n",
|
387 |
" df_to_process = df.loc[~df.item_id.isin(out_df.item_id)]\n",
|
388 |
"\n",
|
@@ -401,7 +87,7 @@
|
|
401 |
" {\"role\": \"user\", \"content\": text}]\n",
|
402 |
"\n",
|
403 |
" response = client.chat.completions.create(\n",
|
404 |
-
" model
|
405 |
" messages=messages,\n",
|
406 |
" response_format={\n",
|
407 |
" 'type': 'json_object'\n",
|
@@ -430,54 +116,52 @@
|
|
430 |
},
|
431 |
{
|
432 |
"cell_type": "code",
|
433 |
-
"execution_count":
|
434 |
"metadata": {},
|
435 |
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
{
|
437 |
"name": "stderr",
|
438 |
"output_type": "stream",
|
439 |
"text": [
|
440 |
-
"
|
441 |
]
|
442 |
},
|
443 |
{
|
444 |
-
"
|
445 |
-
"
|
446 |
-
"
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/openai/resources/chat/completions/completions.py:914\u001b[39m, in \u001b[36mCompletions.create\u001b[39m\u001b[34m(self, messages, model, audio, frequency_penalty, function_call, functions, logit_bias, logprobs, max_completion_tokens, max_tokens, metadata, modalities, n, parallel_tool_calls, prediction, presence_penalty, reasoning_effort, response_format, seed, service_tier, stop, store, stream, stream_options, temperature, tool_choice, tools, top_logprobs, top_p, user, web_search_options, extra_headers, extra_query, extra_body, timeout)\u001b[39m\n\u001b[32m 871\u001b[39m \u001b[38;5;129m@required_args\u001b[39m([\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mmodel\u001b[39m\u001b[33m\"\u001b[39m], [\u001b[33m\"\u001b[39m\u001b[33mmessages\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mmodel\u001b[39m\u001b[33m\"\u001b[39m, \u001b[33m\"\u001b[39m\u001b[33mstream\u001b[39m\u001b[33m\"\u001b[39m])\n\u001b[32m 872\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mcreate\u001b[39m(\n\u001b[32m 873\u001b[39m \u001b[38;5;28mself\u001b[39m,\n\u001b[32m (...)\u001b[39m\u001b[32m 911\u001b[39m timeout: \u001b[38;5;28mfloat\u001b[39m | httpx.Timeout | \u001b[38;5;28;01mNone\u001b[39;00m | NotGiven = NOT_GIVEN,\n\u001b[32m 912\u001b[39m ) -> ChatCompletion | Stream[ChatCompletionChunk]:\n\u001b[32m 913\u001b[39m validate_response_format(response_format)\n\u001b[32m--> \u001b[39m\u001b[32m914\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_post\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 915\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43m/chat/completions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[32m 916\u001b[39m \u001b[43m \u001b[49m\u001b[43mbody\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmaybe_transform\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 917\u001b[39m \u001b[43m \u001b[49m\u001b[43m{\u001b[49m\n\u001b[32m 918\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmessages\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmessages\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 919\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodel\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodel\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 920\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43maudio\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43maudio\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 921\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfrequency_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfrequency_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 922\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunction_call\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunction_call\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 923\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mfunctions\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mfunctions\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 924\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogit_bias\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogit_bias\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 925\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mlogprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mlogprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 926\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_completion_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_completion_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 927\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmax_tokens\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmax_tokens\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 928\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmetadata\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmetadata\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 929\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mmodalities\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mmodalities\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 930\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mn\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mn\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 931\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mparallel_tool_calls\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mparallel_tool_calls\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 932\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mprediction\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mprediction\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 933\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mpresence_penalty\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mpresence_penalty\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 934\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mreasoning_effort\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mreasoning_effort\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 935\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mresponse_format\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mresponse_format\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 936\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mseed\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mseed\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 937\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mservice_tier\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mservice_tier\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 938\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstop\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstop\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 939\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstore\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstore\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 940\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 941\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mstream_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mstream_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 942\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtemperature\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtemperature\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 943\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtool_choice\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtool_choice\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 944\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtools\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtools\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 945\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_logprobs\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_logprobs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 946\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mtop_p\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mtop_p\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 947\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43muser\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43muser\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 948\u001b[39m \u001b[43m \u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mweb_search_options\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mweb_search_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 949\u001b[39m \u001b[43m \u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 950\u001b[39m \u001b[43m \u001b[49m\u001b[43mcompletion_create_params\u001b[49m\u001b[43m.\u001b[49m\u001b[43mCompletionCreateParams\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 951\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 952\u001b[39m \u001b[43m \u001b[49m\u001b[43moptions\u001b[49m\u001b[43m=\u001b[49m\u001b[43mmake_request_options\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 953\u001b[39m \u001b[43m \u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_headers\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_query\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m=\u001b[49m\u001b[43mextra_body\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m 954\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 955\u001b[39m \u001b[43m \u001b[49m\u001b[43mcast_to\u001b[49m\u001b[43m=\u001b[49m\u001b[43mChatCompletion\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 956\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream\u001b[49m\u001b[43m=\u001b[49m\u001b[43mstream\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01mor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[32m 957\u001b[39m \u001b[43m \u001b[49m\u001b[43mstream_cls\u001b[49m\u001b[43m=\u001b[49m\u001b[43mStream\u001b[49m\u001b[43m[\u001b[49m\u001b[43mChatCompletionChunk\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[32m 958\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
|
454 |
-
"\
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
"
|
462 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpx/_client.py:153\u001b[39m, in \u001b[36mBoundSyncStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 152\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m--> \u001b[39m\u001b[32m153\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 154\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\n",
|
463 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpx/_transports/default.py:127\u001b[39m, in \u001b[36mResponseStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 125\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m 126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[32m--> \u001b[39m\u001b[32m127\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_httpcore_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 128\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\n",
|
464 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:407\u001b[39m, in \u001b[36mPoolByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 405\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m 406\u001b[39m \u001b[38;5;28mself\u001b[39m.close()\n\u001b[32m--> \u001b[39m\u001b[32m407\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m\n",
|
465 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:403\u001b[39m, in \u001b[36mPoolByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 401\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34m__iter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) -> typing.Iterator[\u001b[38;5;28mbytes\u001b[39m]:\n\u001b[32m 402\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m403\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_stream\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 404\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mpart\u001b[49m\n\u001b[32m 405\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
|
466 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py:342\u001b[39m, in \u001b[36mHTTP11ConnectionByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 340\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m ShieldCancellation():\n\u001b[32m 341\u001b[39m \u001b[38;5;28mself\u001b[39m.close()\n\u001b[32m--> \u001b[39m\u001b[32m342\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m exc\n",
|
467 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py:334\u001b[39m, in \u001b[36mHTTP11ConnectionByteStream.__iter__\u001b[39m\u001b[34m(self)\u001b[39m\n\u001b[32m 332\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 333\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[33m\"\u001b[39m\u001b[33mreceive_response_body\u001b[39m\u001b[33m\"\u001b[39m, logger, \u001b[38;5;28mself\u001b[39m._request, kwargs):\n\u001b[32m--> \u001b[39m\u001b[32m334\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mfor\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;129;43;01min\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_connection\u001b[49m\u001b[43m.\u001b[49m\u001b[43m_receive_response_body\u001b[49m\u001b[43m(\u001b[49m\u001b[43m*\u001b[49m\u001b[43m*\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[32m 335\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43;01myield\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mchunk\u001b[49m\n\u001b[32m 336\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[32m 337\u001b[39m \u001b[38;5;66;03m# If we get an exception while streaming the response,\u001b[39;00m\n\u001b[32m 338\u001b[39m \u001b[38;5;66;03m# we want to close the response (and possibly the connection)\u001b[39;00m\n\u001b[32m 339\u001b[39m \u001b[38;5;66;03m# before raising that exception.\u001b[39;00m\n",
|
468 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py:203\u001b[39m, in \u001b[36mHTTP11Connection._receive_response_body\u001b[39m\u001b[34m(self, request)\u001b[39m\n\u001b[32m 200\u001b[39m timeout = timeouts.get(\u001b[33m\"\u001b[39m\u001b[33mread\u001b[39m\u001b[33m\"\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[32m 202\u001b[39m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m203\u001b[39m event = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_receive_event\u001b[49m\u001b[43m(\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 204\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(event, h11.Data):\n\u001b[32m 205\u001b[39m \u001b[38;5;28;01myield\u001b[39;00m \u001b[38;5;28mbytes\u001b[39m(event.data)\n",
|
469 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_sync/http11.py:217\u001b[39m, in \u001b[36mHTTP11Connection._receive_event\u001b[39m\u001b[34m(self, timeout)\u001b[39m\n\u001b[32m 214\u001b[39m event = \u001b[38;5;28mself\u001b[39m._h11_state.next_event()\n\u001b[32m 216\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m event \u001b[38;5;129;01mis\u001b[39;00m h11.NEED_DATA:\n\u001b[32m--> \u001b[39m\u001b[32m217\u001b[39m data = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_network_stream\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\n\u001b[32m 218\u001b[39m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mREAD_NUM_BYTES\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m=\u001b[49m\u001b[43mtimeout\u001b[49m\n\u001b[32m 219\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 221\u001b[39m \u001b[38;5;66;03m# If we feed this case through h11 we'll raise an exception like:\u001b[39;00m\n\u001b[32m 222\u001b[39m \u001b[38;5;66;03m#\u001b[39;00m\n\u001b[32m 223\u001b[39m \u001b[38;5;66;03m# httpcore.RemoteProtocolError: can't handle event type\u001b[39;00m\n\u001b[32m (...)\u001b[39m\u001b[32m 227\u001b[39m \u001b[38;5;66;03m# perspective. Instead we handle this case distinctly and treat\u001b[39;00m\n\u001b[32m 228\u001b[39m \u001b[38;5;66;03m# it as a ConnectError.\u001b[39;00m\n\u001b[32m 229\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m data == \u001b[33mb\u001b[39m\u001b[33m\"\u001b[39m\u001b[33m\"\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m._h11_state.their_state == h11.SEND_RESPONSE:\n",
|
470 |
-
"\u001b[36mFile \u001b[39m\u001b[32m~/.cache/pypoetry/virtualenvs/sciences-poc-Bw010oVJ-py3.11/lib/python3.11/site-packages/httpcore/_backends/sync.py:128\u001b[39m, in \u001b[36mSyncStream.read\u001b[39m\u001b[34m(self, max_bytes, timeout)\u001b[39m\n\u001b[32m 126\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[32m 127\u001b[39m \u001b[38;5;28mself\u001b[39m._sock.settimeout(timeout)\n\u001b[32m--> \u001b[39m\u001b[32m128\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sock\u001b[49m\u001b[43m.\u001b[49m\u001b[43mrecv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmax_bytes\u001b[49m\u001b[43m)\u001b[49m\n",
|
471 |
-
"\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/ssl.py:1295\u001b[39m, in \u001b[36mSSLSocket.recv\u001b[39m\u001b[34m(self, buflen, flags)\u001b[39m\n\u001b[32m 1291\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m flags != \u001b[32m0\u001b[39m:\n\u001b[32m 1292\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[32m 1293\u001b[39m \u001b[33m\"\u001b[39m\u001b[33mnon-zero flags not allowed in calls to recv() on \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[33m\"\u001b[39m %\n\u001b[32m 1294\u001b[39m \u001b[38;5;28mself\u001b[39m.\u001b[34m__class__\u001b[39m)\n\u001b[32m-> \u001b[39m\u001b[32m1295\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbuflen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1296\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m 1297\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28msuper\u001b[39m().recv(buflen, flags)\n",
|
472 |
-
"\u001b[36mFile \u001b[39m\u001b[32m/opt/conda/lib/python3.11/ssl.py:1168\u001b[39m, in \u001b[36mSSLSocket.read\u001b[39m\u001b[34m(self, len, buffer)\u001b[39m\n\u001b[32m 1166\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m._sslobj.read(\u001b[38;5;28mlen\u001b[39m, buffer)\n\u001b[32m 1167\u001b[39m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[32m-> \u001b[39m\u001b[32m1168\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_sslobj\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mlen\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 1169\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m SSLError \u001b[38;5;28;01mas\u001b[39;00m x:\n\u001b[32m 1170\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m x.args[\u001b[32m0\u001b[39m] == SSL_ERROR_EOF \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m.suppress_ragged_eofs:\n",
|
473 |
-
"\u001b[31mKeyboardInterrupt\u001b[39m: "
|
474 |
]
|
475 |
}
|
476 |
],
|
477 |
"source": [
|
478 |
"with open('mapping_prompts.txt', 'r') as f : \n",
|
479 |
" mapping = json.loads(f.read())\n",
|
480 |
-
"
|
|
|
|
|
|
|
481 |
]
|
482 |
},
|
483 |
{
|
|
|
26 |
},
|
27 |
{
|
28 |
"cell_type": "code",
|
29 |
+
"execution_count": 12,
|
30 |
"metadata": {},
|
31 |
"outputs": [],
|
32 |
"source": [
|
|
|
39 |
},
|
40 |
{
|
41 |
"cell_type": "code",
|
42 |
+
"execution_count": 15,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
"metadata": {},
|
44 |
"outputs": [],
|
45 |
"source": [
|
|
|
65 |
"\n",
|
66 |
" if mapping_prompt[name]['client']=='deepseek':\n",
|
67 |
" client = OpenAI(api_key=keys[\"DEEPSEEK_API_KEY\"], base_url=\"https://api.deepseek.com\")\n",
|
68 |
+
" model=\"deepseek-chat\"\n",
|
69 |
" else:\n",
|
70 |
" client=OpenAI(api_key=keys['OPENAI_API_KEY'])\n",
|
71 |
+
" model=\"gpt-4o\"\n",
|
72 |
"\n",
|
73 |
" df_to_process = df.loc[~df.item_id.isin(out_df.item_id)]\n",
|
74 |
"\n",
|
|
|
87 |
" {\"role\": \"user\", \"content\": text}]\n",
|
88 |
"\n",
|
89 |
" response = client.chat.completions.create(\n",
|
90 |
+
" model=model,\n",
|
91 |
" messages=messages,\n",
|
92 |
" response_format={\n",
|
93 |
" 'type': 'json_object'\n",
|
|
|
116 |
},
|
117 |
{
|
118 |
"cell_type": "code",
|
119 |
+
"execution_count": 19,
|
120 |
"metadata": {},
|
121 |
"outputs": [
|
122 |
+
{
|
123 |
+
"name": "stdout",
|
124 |
+
"output_type": "stream",
|
125 |
+
"text": [
|
126 |
+
"sans_titre_1\n"
|
127 |
+
]
|
128 |
+
},
|
129 |
{
|
130 |
"name": "stderr",
|
131 |
"output_type": "stream",
|
132 |
"text": [
|
133 |
+
"0it [00:00, ?it/s]"
|
134 |
]
|
135 |
},
|
136 |
{
|
137 |
+
"name": "stderr",
|
138 |
+
"output_type": "stream",
|
139 |
+
"text": [
|
140 |
+
"\n"
|
141 |
+
]
|
142 |
+
},
|
143 |
+
{
|
144 |
+
"name": "stdout",
|
145 |
+
"output_type": "stream",
|
146 |
+
"text": [
|
147 |
+
"favarel_et_al\n"
|
148 |
+
]
|
149 |
+
},
|
150 |
+
{
|
151 |
+
"name": "stderr",
|
152 |
+
"output_type": "stream",
|
153 |
+
"text": [
|
154 |
+
" 1%| | 6/516 [00:39<55:50, 6.57s/it]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
]
|
156 |
}
|
157 |
],
|
158 |
"source": [
|
159 |
"with open('mapping_prompts.txt', 'r') as f : \n",
|
160 |
" mapping = json.loads(f.read())\n",
|
161 |
+
"\n",
|
162 |
+
"for name in mapping.keys():\n",
|
163 |
+
" print(name)\n",
|
164 |
+
" retrieve_classifications(name, mapping)"
|
165 |
]
|
166 |
},
|
167 |
{
|
save/output_favarel_et_al.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[{"item_id": "I4OEKQ6MHRBP3LQVVYDDXW6T6U", "categorie_principale": "UPDATE ME", "categorie_secondaire": "EDUCATE ME"}, {"item_id": "LVA4MZBQOBECNPZD323NV6O7K4", "categorie_principale": "INSPIRE ME", "categorie_secondaire": "EDUCATE ME"}, {"item_id": "4FAEHUUZ5ZFAJKLFEV2LT5CBAQ", "categorie_principale": "EDUCATE ME", "categorie_secondaire": "GIVE ME PERSPECTIVE"}, {"item_id": "4S4G6BKFRNER3LB22CLPAEWWKY", "categorie_principale": "GIVE ME PERSPECTIVE", "categorie_secondaire": "INSPIRE ME"}, {"item_id": "ZAFHRNAHJVC6THXRSBMCB4A24I", "categorie_principale": "INSPIRE ME", "categorie_secondaire": "EDUCATE ME"}, {"item_id": "ESEADAHDJVGQRC2S3JHSZEVWHM", "categorie_principale": "UPDATE ME", "categorie_secondaire": "GIVE ME PERSPECTIVE"}]
|
save/output_sans_titre_1.txt
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
save/output_sans_titre_2.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
[{"item_id": "I4OEKQ6MHRBP3LQVVYDDXW6T6U", "categorie_principale": "UPDATE ME", "categorie_secondaire": "EDUCATE ME"}, {"item_id": "LVA4MZBQOBECNPZD323NV6O7K4", "categorie_principale": "EDUCATE ME", "categorie_secondaire": "GIVE ME PERSPECTIVE"}]
|