Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Comprendre les agents à travers le cycle Réflexion-Action-Observation","local":"comprendre-les-agents-à-travers-le-cycle-réflexion-action-observation","sections":[{"title":"Les composants de base","local":"les-composants-de-base","sections":[],"depth":2},{"title":"Le cycle Réflexion-Action-Observation","local":"le-cycle-réflexion-action-observation","sections":[],"depth":2},{"title":"Alfred, l’agent météorologiste","local":"alfred-lagent-météorologiste","sections":[{"title":"Réflexion","local":"réflexion","sections":[],"depth":3},{"title":"Action","local":"action","sections":[],"depth":3},{"title":"Observation","local":"observation","sections":[],"depth":3},{"title":"Raisonnement mis à jour","local":"raisonnement-mis-à-jour","sections":[],"depth":3},{"title":"Action finale","local":"action-finale","sections":[],"depth":3}],"depth":2}],"depth":1}"> | |
| <link href="/docs/agents-course/pr_653/fr/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/entry/start.6d47ec1b.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/scheduler.505acc25.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/singletons.05e80c54.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/index.001f95d5.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/paths.057989d7.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/entry/app.422aa231.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/preload-helper.3307fcb7.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/index.b1175496.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/nodes/0.e1f9a6c5.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/nodes/22.3b59e71f.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/Heading.5a909328.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.c8924854.js"> | |
| <link rel="modulepreload" href="/docs/agents-course/pr_653/fr/_app/immutable/chunks/CodeBlock.368e9095.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Comprendre les agents à travers le cycle Réflexion-Action-Observation","local":"comprendre-les-agents-à-travers-le-cycle-réflexion-action-observation","sections":[{"title":"Les composants de base","local":"les-composants-de-base","sections":[],"depth":2},{"title":"Le cycle Réflexion-Action-Observation","local":"le-cycle-réflexion-action-observation","sections":[],"depth":2},{"title":"Alfred, l’agent météorologiste","local":"alfred-lagent-météorologiste","sections":[{"title":"Réflexion","local":"réflexion","sections":[],"depth":3},{"title":"Action","local":"action","sections":[],"depth":3},{"title":"Observation","local":"observation","sections":[],"depth":3},{"title":"Raisonnement mis à jour","local":"raisonnement-mis-à-jour","sections":[],"depth":3},{"title":"Action finale","local":"action-finale","sections":[],"depth":3}],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="comprendre-les-agents-à-travers-le-cycle-réflexion-action-observation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#comprendre-les-agents-à-travers-le-cycle-réflexion-action-observation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Comprendre les agents à travers le cycle Réflexion-Action-Observation</span></h1> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/whiteboard-check-3.jpg" alt="Planification de l'Unité 1"> <p data-svelte-h="svelte-w5p9ev">Dans les sections précédentes, nous avons appris :</p> <ul data-svelte-h="svelte-1oxry82"><li><strong>Comment les outils sont mis à disposition de l’agent dans le <em>prompt</em> système</strong>.</li> <li><strong>Comment les agents sont des systèmes capables de « raisonner », planifier et interagir avec leur environnement</strong>.</li></ul> <p data-svelte-h="svelte-1ma6ock">Dans cette section, <strong>nous explorerons l’ensemble du <em>workflow</em> de l’agent</strong>, un cycle que nous avons défini comme Réflexion-Action-Observation (<em>Thought-Action-Observation</em>).</p> <p data-svelte-h="svelte-yauhvf">Puis, nous approfondirons chacune de ces étapes.</p> <h2 class="relative group"><a id="les-composants-de-base" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#les-composants-de-base"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Les composants de base</span></h2> <p data-svelte-h="svelte-1j9gh32">Les agents fonctionnent selon un cycle continu : <strong>réfléchir (Réflexion) → agir (Action) et observer (Observation)</strong> (<strong><em>thinking (Thought) → acting (Act) and observing (Observe)</em></strong>).</p> <p data-svelte-h="svelte-m4nsqt">Décomposons ensemble ces actions :</p> <ol data-svelte-h="svelte-10cmhik"><li><strong>Réflexion</strong> : La partie LLM de l’agent décide de la prochaine étape.</li> <li><strong>Action</strong> : L’agent passe à l’action en appelant les outils avec les arguments associés.</li> <li><strong>Observation</strong> : Le modèle analyse la réponse renvoyée par l’outil.</li></ol> <h2 class="relative group"><a id="le-cycle-réflexion-action-observation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#le-cycle-réflexion-action-observation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Le cycle Réflexion-Action-Observation</span></h2> <p data-svelte-h="svelte-sylgq">Les trois composants fonctionnent ensemble dans une boucle continue. Pour utiliser une analogie issue de la programmation, l’agent utilise une <strong>boucle while</strong> : la boucle continue jusqu’à ce que l’objectif de l’agent soit atteint.</p> <p data-svelte-h="svelte-b28f0g">Visuellement, cela ressemble à ceci :</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/AgentCycle.gif" alt="Cycle Réflexion, Action, Observation"> <p data-svelte-h="svelte-1fjzyhw">Dans de nombreux <em>frameworks</em> d’agents, <strong>les règles et directives sont intégrées directement dans le <em>prompt</em> système</strong>, garantissant que chaque cycle respecte une logique définie.</p> <p data-svelte-h="svelte-yswlk5">Dans une version simplifiée, notre <em>prompt</em> système pourrait ressembler à ceci :</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/system_prompt_cycle.png" alt="Cycle Réflexion, Action, Observation"> <p data-svelte-h="svelte-zugc6z">Nous voyons ici que dans le message système, nous avons défini :</p> <ul data-svelte-h="svelte-y3wo5c"><li>Le <em>comportement de l’agent</em>.</li> <li>Les <em>outils auxquels il a accès</em>, comme nous l’avons décrit dans la section précédente.</li> <li>Le <em>cycle Réflexion-Action-Observation</em>, que nous intégrons dans les instructions du LLM.</li></ul> <p data-svelte-h="svelte-1je6m3n">Prenons un petit exemple pour comprendre le processus avant d’approfondir chacune des étapes.</p> <h2 class="relative group"><a id="alfred-lagent-météorologiste" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#alfred-lagent-météorologiste"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Alfred, l’agent météorologiste</span></h2> <p data-svelte-h="svelte-1mwl93b">Nous avons créé Alfred, l’agent météorologiste.</p> <p data-svelte-h="svelte-1dpdnt7">Un utilisateur demande à Alfred : « Quel temps fait-il à New York aujourd’hui ? »</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent.jpg" alt="Agent Alfred"> <p data-svelte-h="svelte-1lflkpy">La mission d’Alfred est de répondre à cette question en utilisant un outil d’API météo.</p> <p data-svelte-h="svelte-z26pde">Voici comment le cycle se déroule :</p> <h3 class="relative group"><a id="réflexion" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#réflexion"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Réflexion</span></h3> <p data-svelte-h="svelte-1ebit9l"><strong>Raisonnement interne :</strong></p> <p data-svelte-h="svelte-2xoky3">Après avoir reçu la requête, le dialogue interne d’Alfred pourrait être :</p> <p data-svelte-h="svelte-1wwzk0u"><em>“L’utilisateur a besoin d’informations météorologiques actuelles pour New York. J’ai accès à un outil qui récupère les données météo. D’abord, je dois appeler l’API météo pour obtenir des détails à jour.”</em></p> <p data-svelte-h="svelte-1c8dpbp">Cette étape montre l’agent décomposant le problème en étapes : d’abord, rassembler les données nécessaires.</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent-1.jpg" alt="Agent Alfred"> <h3 class="relative group"><a id="action" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#action"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Action</span></h3> <p data-svelte-h="svelte-al7d8x"><strong>Utilisation d’un outil :</strong></p> <p data-svelte-h="svelte-d1xzmt">En se basant sur son raisonnement et sur le fait qu’Alfred connaît l’outil <code>get_weather</code>, Alfred prépare une commande au format JSON qui appelle l’outil API météo. Par exemple, sa première action pourrait être :</p> <p data-svelte-h="svelte-6rva1y">Raisonnement : Je dois vérifier la météo actuelle pour New York.</p> <div class="code-block relative "><div class="absolute top-2.5 right-4"><button class="inline-flex items-center relative text-sm focus:text-green-500 cursor-pointer focus:outline-none transition duration-200 ease-in-out opacity-0 mx-0.5 text-gray-600 " title="code excerpt" type="button"><svg class="" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg> <div class="absolute pointer-events-none transition-opacity bg-black text-white py-1 px-2 leading-tight rounded font-normal shadow left-1/2 top-full transform -translate-x-1/2 translate-y-2 opacity-0"><div class="absolute bottom-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-black border-4 border-t-0" style="border-left-color: transparent; border-right-color: transparent; "></div> Copied</div></button></div> <pre class=""><!-- HTML_TAG_START --><span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"action"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"get_weather"</span><span class="hljs-punctuation">,</span> | |
| <span class="hljs-attr">"action_input"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">{</span> | |
| <span class="hljs-attr">"location"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"New York"</span> | |
| <span class="hljs-punctuation">}</span> | |
| <span class="hljs-punctuation">}</span><!-- HTML_TAG_END --></pre></div> <p data-svelte-h="svelte-7wj3bq">Ici, l’action précise clairement quel outil appeler (par exemple, <code>get_weather</code>) et quel paramètre passer (la « location » : « New York »).</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent-2.jpg" alt="Agent Alfred"> <h3 class="relative group"><a id="observation" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#observation"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Observation</span></h3> <p data-svelte-h="svelte-xul5jd"><strong>Retour d’information de l’environnement :</strong></p> <p data-svelte-h="svelte-z96q1">Après l’appel à l’outil, Alfred reçoit une observation. Cela pourrait être les données météo brutes renvoyées par l’API, par exemple :</p> <p data-svelte-h="svelte-1r3qv69"><em>“Météo actuelle à New York : partiellement nuageux, 15°C, 60% d’humidité.”</em></p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent-3.jpg" alt="Agent Alfred"> <p data-svelte-h="svelte-1irc2xx">Cette observation est ensuite ajoutée au <em>prompt</em> en tant que contexte supplémentaire. Elle agit comme un retour du monde réel, confirmant si l’action a réussi et fournissant les détails nécessaires.</p> <h3 class="relative group"><a id="raisonnement-mis-à-jour" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#raisonnement-mis-à-jour"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Raisonnement mis à jour</span></h3> <p data-svelte-h="svelte-1iky6j"><strong>Réflexion :</strong></p> <p data-svelte-h="svelte-ekej46">Avec l’observation en main, Alfred met à jour son raisonnement interne :</p> <p data-svelte-h="svelte-6wr4my"><em>“Maintenant que j’ai les données météo pour New York, je peux préparer une réponse pour l’utilisateur.”</em></p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent-4.jpg" alt="Agent Alfred"> <h3 class="relative group"><a id="action-finale" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#action-finale"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Action finale</span></h3> <p data-svelte-h="svelte-nqem7p">Alfred génère ensuite une réponse finale formatée comme nous le lui avons indiqué :</p> <p data-svelte-h="svelte-26nwt2">Raisonnement : J’ai maintenant les données météo. La météo actuelle à New York est partiellement nuageuse avec une température de 15°C et 60% d’humidité.</p> <p data-svelte-h="svelte-1i9rvvs">Réponse finale : La météo actuelle à New York est partiellement nuageuse avec une température de 15°C et 60% d’humidité.</p> <p data-svelte-h="svelte-3q1z5m">Cette action finale renvoie la réponse à l’utilisateur, bouclant ainsi le cycle.</p> <img src="https://huggingface.co/datasets/agents-course/course-images/resolve/main/en/unit1/alfred-agent-5.jpg" alt="Agent Alfred"> <p data-svelte-h="svelte-xcn4w">Ce que nous voyons dans cet exemple :</p> <ul data-svelte-h="svelte-12fi4ic"><li><p><strong>Les agents itèrent dans une boucle jusqu’à ce que l’objectif soit atteint :</strong><br> | |
| Le processus d’Alfred est cyclique. Il commence par un raisonnement, passe à l’action en appelant un outil, puis observe le résultat. Si l’observation avait indiqué une erreur ou des données incomplètes, Alfred aurait pu reprendre le cycle pour corriger son approche.</p></li> <li><p><strong>Intégration des outils :</strong><br> | |
| La capacité d’appeler un outil (comme une API météo) permet à Alfred d’aller <strong>au-delà de la connaissance statique et de récupérer des données en temps réel</strong>, un aspect essentiel de nombreux agents.</p></li> <li><p><strong>Adaptation dynamique :</strong><br> | |
| Chaque cycle permet à l’agent d’intégrer des informations fraîches (observations) dans son raisonnement (réflexions), garantissant que la réponse finale est bien informée et précise.</p></li></ul> <p data-svelte-h="svelte-ucaddc">Cet exemple illustre le concept fondamental du <em>cycle ReAct</em> (un concept que nous allons développer dans la section suivante) : <strong>l’interaction entre Réflexion, Action et Observation permet aux agents de résoudre de manière itérative des tâches complexes</strong>.</p> <p data-svelte-h="svelte-j452el">En comprenant et en appliquant ces principes, vous pouvez concevoir des agents qui non seulement réfléchissent à leurs tâches, mais utilisent également efficacement des outils externes pour les accomplir, tout en affinant continuellement leur production en fonction des retours de l’environnement.</p> <hr> <p data-svelte-h="svelte-18gzabl">Plongeons maintenant plus en profondeur dans le Réflexion, l’Action et l’Observation en tant qu’étapes individuelles du processus.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/agents-course/blob/main/units/fr/unit1/agent-steps-and-structure.mdx" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_1ql597g = { | |
| assets: "/docs/agents-course/pr_653/fr", | |
| base: "/docs/agents-course/pr_653/fr", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/agents-course/pr_653/fr/_app/immutable/entry/start.6d47ec1b.js"), | |
| import("/docs/agents-course/pr_653/fr/_app/immutable/entry/app.422aa231.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 22], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 28.7 kB
- Xet hash:
- 5e52a7c0f6b226ece7c7f01e88f12d83b79668767b01c7145685c6b308619272
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.