<?xml
version="1.0" encoding="utf-8"?>
<rss version="2.0" 
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:atom="http://www.w3.org/2005/Atom"
>

<channel xml:lang="fr">
	<title>Les services IA de DnC</title>
	<link>https://ia.dnc.global/</link>
	<description>En mati&#232;re d'intelligence artificielle (IA), DnC met l'accent sur la s&#233;curit&#233; en offrant aux entreprises le moyen de conserver leurs donn&#233;es et les traitements &#224; l'int&#233;rieur de leur r&#233;seau d'entreprise plut&#244;t que dans le Cloud.</description>
	<language>fr</language>
	<generator>SPIP - www.spip.net</generator>
	<atom:link href="https://ia.dnc.global/spip.php?id_rubrique=9&amp;page=backend" rel="self" type="application/rss+xml" />




<item xml:lang="fr">
		<title>Le Daemon Pyro5</title>
		<link>https://ia.dnc.global/Le-Daemon-Pyro5.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Le-Daemon-Pyro5.html</guid>
		<dc:date>2026-07-07T09:30:51Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Dans une architecture multi&#8209;processus et multi&#8209;utilisateur, on ne peut charger un m&#234;me mod&#232;le dans chaque composant (NSOrchestrator, ReActEngine, workers, tests, scripts). Pour cette raison, les mod&#232;les doivent &#234;tre servis via un daemon. &lt;br class='autobr' /&gt;
##Position du probl&#232;me &lt;br class='autobr' /&gt;
Un LLM ou un SLM repr&#233;sente plusieurs gigaoctets en m&#233;moire, et leur rechargement dans chaque processus provoquerait une explosion de la consommation RAM, une fragmentation CUDA, des temps de d&#233;marrage prohibitifs et une instabilit&#233; g&#233;n&#233;rale (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-v200-.html" rel="directory"&gt;Architecture v200&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;Dans une architecture multi&#8209;processus et multi&#8209;utilisateur, on ne peut charger un m&#234;me mod&#232;le dans chaque composant (NSOrchestrator, ReActEngine, workers, tests, scripts).&lt;br class='autobr' /&gt;
Pour cette raison, les mod&#232;les doivent &#234;tre servis via un daemon.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;h2&gt;Position du probl&#232;me&lt;/h2&gt;
&lt;p&gt;Un LLM ou un SLM repr&#233;sente plusieurs gigaoctets en m&#233;moire, et leur rechargement dans chaque processus provoquerait une explosion de la consommation RAM, une fragmentation CUDA, des temps de d&#233;marrage prohibitifs et une instabilit&#233; g&#233;n&#233;rale du syst&#232;me. Le &lt;strong&gt;mode daemon&lt;/strong&gt; r&#233;sout ce probl&#232;me en garantissant qu'&lt;strong&gt;un mod&#232;le n'est charg&#233; qu'une seule fois dans un processus d&#233;di&#233;, puis partag&#233; entre tous les autres via RPC&lt;/strong&gt;. Cela permet un fonctionnement r&#233;ellement concurrent, une gestion propre du streaming token&#8209;par&#8209;token, une isolation des erreurs, et une stabilit&#233; m&#233;moire indispensable en production.&lt;/p&gt;
&lt;p&gt;Pour cette raison, le LLM et le SLM doivent &#234;tre servis via un daemon. Les deux mod&#232;les sont sollicit&#233;s par plusieurs utilisateurs, plusieurs sessions et plusieurs moteurs internes, parfois simultan&#233;ment. Les Thought et les r&#233;ponses finales de ReAct doivent &#234;tre g&#233;n&#233;r&#233;es sans jamais recharger les poids des mod&#232;les, sans bloquer les autres processus, et sans d&#233;pendre de l'environnement local de chaque composant. En les ex&#233;cutant tous deux en daemon, l'architecture v200 devient coh&#233;rente, d&#233;terministe et scalable : un seul chargement, un seul point d'acc&#232;s, un comportement identique pour tous les clients, et une capacit&#233; &#224; monter en charge sans modifier le code des orchestrateurs ou des moteurs internes.&lt;/p&gt;
&lt;p&gt;Ce raisonnement vaut &#233;galement pour les index.&lt;/p&gt;
&lt;h2&gt;R&#244;le du daemon&lt;/h2&gt;
&lt;p&gt;Le daemon Pyro5 est un fournisseur multi-services.&lt;/p&gt;
&lt;p&gt;Via ModelsConfigurator, il :&lt;/p&gt;
&lt;ol class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;Charge les mod&#232;les d&#233;finis dans &lt;code&gt;models.json&lt;/code&gt;,
ce qui initialise AppSettings et les mod&#232;les globaux (embedding, LLM, SLM).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Charge les services d&#233;clar&#233;s dans &lt;code&gt;services.json&lt;/code&gt; et les instancie dynamiquement.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enregistre chaque service dans Pyro5 sous un nom stable :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;llm.server&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;slm.server&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;embedding.server&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;rag.reader&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Puis : Lance la boucle d'&#233;v&#233;nements Pyro5.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Exemple : chargement d'un index par RagRuntime :&lt;/strong&gt;&lt;/p&gt;
&lt;dl class='spip_document_56 spip_documents'&gt; &lt;dt&gt; &lt;a href='https://ia.dnc.global/IMG/png/in_daemon_rag_reader_workflow-2026-07-07-091503.png' class=&#034;mediabox&#034; title=&#034;PNG - 737.1 ko&#034; &gt; &lt;img src='https://ia.dnc.global/local/cache-vignettes/L500xH320/in_daemon_rag_reader_workflow-2026-07-07-091503-2f088.png?1783416584' width='500' height='320' alt=&#034;PNG - 737.1&#160;ko&#034; /&gt; &lt;/a&gt; &lt;/dt&gt; &lt;/dl&gt;
&lt;h2&gt;Composants principaux&lt;/h2&gt;
&lt;h3&gt;1. MemoryManager&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;Arbitre global de la RAM.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Suit les allocations d'objets persistants.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Applique une politique d'&#233;viction (LRU locale).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fournit un &#233;tat m&#233;moire complet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Thread-safe.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;2. InDaemonRagReader&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;Reader interne au daemon.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Encode les requ&#234;tes via le mod&#232;le d'embedding global.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Interroge le backend vectoriel (FAISS, LlamaIndex ...).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Renvoie des &lt;code&gt;RichNode&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Fournit un mode streaming (&lt;code&gt;astream&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Noter qu'une architecture s&#233;parant le mod&#232;le d'embedding et l'index dans des daemons distincts conduirait &#224; un grand nombre d'&#233;changes RCP et &#224; des temps de traitement prohibitifs.&lt;/p&gt;
&lt;h2&gt;Interaction avec le client&lt;/h2&gt;
&lt;p&gt;Le client utilise &lt;strong&gt;InDaemonRagReaderProxy&lt;/strong&gt; pour contacter &lt;code&gt;rag.reader&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Flux typique :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;RagRuntime.retrieve() &#8594; InDaemonRagReaderProxy(&#034;rag.reader&#034;).retrieve(theme, query, top_k) &#8594; InDaemonRagReader.retrieve() &#8594; encode la requ&#234;te &#8594; interroge le backend vectoriel &#8594; renvoie des RichNode&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le client ne voit jamais MemoryManager : tout est encapsul&#233; dans le daemon.&lt;/p&gt;
&lt;h2&gt;Avantages de cette architecture&lt;/h2&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;Un seul daemon &#8594; coh&#233;rence m&#233;moire.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Plusieurs services &#8594; modularit&#233;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;MemoryManager central &#8594; contr&#244;le RAM industriel.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;InDaemonRagReader &#8594; moteur RAG unifi&#233;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Structure simple &#8594; facile &#224; &#233;tendre.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>v200 : Introduction</title>
		<link>https://ia.dnc.global/v200-Introduction.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/v200-Introduction.html</guid>
		<dc:date>2026-07-04T08:16:29Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;La v200 introduit une architecture RAG enti&#232;rement refondue, centr&#233;e sur la modularit&#233;, la performance et la robustesse. Elle s'appuie sur l'&#233;criture de services d&#233;di&#233;s pour les mod&#232;les et les index, un daemon Pyro5 pour l'acc&#232;s rapide aux index en m&#233;moire, et une API interne unifi&#233;e permettant d'abstraire totalement les backends. L'ensemble garantit un moteur RAG totalement ind&#233;pendant de toute biblioth&#232;que (LlamaIndex, LangChain ...) . Cette version fournit ainsi une base industrielle, stable et (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-v200-.html" rel="directory"&gt;Architecture v200&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;La v200 introduit une architecture RAG enti&#232;rement refondue, centr&#233;e sur la modularit&#233;, la performance et la robustesse. Elle s'appuie sur l'&#233;criture de services d&#233;di&#233;s pour les mod&#232;les et les index, un daemon Pyro5 pour l'acc&#232;s rapide aux index en m&#233;moire, et une API interne unifi&#233;e permettant d'abstraire totalement les backends. &lt;br class='autobr' /&gt;
L'ensemble garantit un moteur RAG totalement ind&#233;pendant de toute biblioth&#232;que (LlamaIndex, LangChain ...) . &lt;br class='autobr' /&gt;
Cette version fournit ainsi une base industrielle, stable et extensible pour un pipeline RAG totalement propri&#233;taire.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;hr /&gt;
&lt;p&gt;La &lt;strong&gt;v200&lt;/strong&gt; constitue une r&#233;architecture compl&#232;te du pipeline RAG, con&#231;ue pour offrir une modularit&#233; stricte, une ind&#233;pendance vis&#8209;&#224;&#8209;vis de LlamaIndex ou de toute autre biblioth&#232;que, et une performance accrue gr&#226;ce &#224; un daemon g&#233;rant les index en m&#233;moire persistante. Elle introduit une s&#233;paration nette des responsabilit&#233;s, une normalisation des API internes, et un mod&#232;le d'ex&#233;cution coh&#233;rent pour tous les types d'index et de mod&#232;les.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;1. Objectif : Modularit&#233; syst&#233;mique&lt;/strong&gt;&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;1.1. Modularit&#233; des mod&#232;les&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;La v200 d&#233;finit des services d&#233;di&#233;s pour les mod&#232;les :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;services/llm/&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;services/embeddings/&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chaque service expose une API normalis&#233;e :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;generate()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;astream()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;embed()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cette abstraction permet de remplacer un mod&#232;le (OpenAI, Ollama, HF, local) sans impact sur le reste du pipeline.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;1.2. Modularit&#233; des index&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Les index sont encapsul&#233;s dans des backends interchangeables :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;FaissBackend&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;LlamaIndexBackend&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;DummyBackend&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tous impl&#233;mentent une &lt;strong&gt;API unifi&#233;e&lt;/strong&gt; :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;retrieve(query, top_k)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;query(query)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;astream(query)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;ping()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cette normalisation garantit que le RAG ne d&#233;pend plus du type d'index sous&#8209;jacent.&lt;/p&gt;
&lt;dl class='spip_document_51 spip_documents'&gt; &lt;dt&gt; &lt;a href='https://ia.dnc.global/IMG/png/ragruntime_retrieve-2026-07-04-105144.png' class=&#034;mediabox&#034; title=&#034;PNG - 2.1 Mo&#034; &gt; &lt;img src='https://ia.dnc.global/local/cache-vignettes/L500xH320/ragruntime_retrieve-2026-07-04-105144-63cf4.png?1783163163' width='500' height='320' alt=&#034;PNG - 2.1&#160;Mo&#034; /&gt; &lt;/a&gt; &lt;/dt&gt; &lt;/dl&gt;
&lt;h3&gt;&lt;strong&gt;1.3. Rapidit&#233; via daemon Pyro5&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;La v200 introduit un daemon Pyro5 :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;charg&#233; de maintenir les index en m&#233;moire,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;exposant une API RPC homog&#232;ne,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;permettant un acc&#232;s rapide depuis n'importe quel worker.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le client est minimal :&lt;/p&gt;
&lt;p&gt;IndexesManager &#8594; IndexService &#8594; RemoteIndexBackend&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
Un m&#233;canisme de **fallback local** assure la continuit&#233; de service en cas d'indisponibilit&#233; du daemon. &lt;p&gt;### **1.4. Couche interne de normalisation**
Une couche interne (`internal/`) garantit :&lt;/p&gt;
&lt;p&gt;- la normalisation des r&#233;sultats des backends,
- la conversion des formats h&#233;t&#233;rog&#232;nes en structures standardis&#233;es,
- la coh&#233;rence des donn&#233;es consomm&#233;es par RagRuntime.&lt;/p&gt;
&lt;p&gt;Tous les r&#233;sultats sont convertis en dictionnaires homog&#232;nes :&lt;/p&gt;
&lt;p&gt;```python
{ &#034;text&#034;: &#034;...&#034;, &#034;score&#034;: None, &#034;metadata&#034;: {}
}&lt;/code&gt;&lt;/p&gt;
&lt;/pre&gt;
&lt;h2&gt;&lt;strong&gt;2. Objectif : RAGEngine ind&#233;pendant d'API externes&lt;/strong&gt;&lt;/h2&gt;
&lt;h3&gt;&lt;strong&gt;2.1. Suppression des d&#233;pendances structurelles&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;La v200 &#233;limine toute d&#233;pendance directe &#224; LlamaIndex ( ou autre) dans le moteur RAG :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;plus de &lt;code&gt;QueryEngine&lt;/code&gt;,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;plus de &lt;code&gt;Node&lt;/code&gt;, &lt;code&gt;Document&lt;/code&gt;, &lt;code&gt;Response&lt;/code&gt;,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;plus de formats &#233;trangers.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Par exemple, LlamaIndex est encapsul&#233; dans &lt;code&gt;LlamaIndexBackend&lt;/code&gt;, qui expose l'API unifi&#233;e.
Dans l'&#233;tat actuel du d&#233;veloppement, il existe une adaptation &#224; FAISS.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;2.2. RAGEngine bas&#233; sur une API interne stable&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Le moteur RAG (RagRuntime) ne d&#233;pend plus :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;du type d'index,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;du type de mod&#232;le,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;de LlamaIndex ou FAISS.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Il consomme uniquement l'API unifi&#233;e :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;retrieve()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;query()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;astream()&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;2.3. Normalisation syst&#233;matique des r&#233;sultats&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Les r&#233;sultats bruts des backends (souvent des cha&#238;nes de caract&#232;res) sont syst&#233;matiquement convertis en objets structur&#233;s avant traitement par RagRuntime.&lt;/p&gt;
&lt;p&gt;Cela garantit :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;la stabilit&#233; du pipeline,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;la compatibilit&#233; avec les hooks,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;l'absence d'erreurs li&#233;es &#224; des formats h&#233;t&#233;rog&#232;nes.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;2.4. Fallback local coh&#233;rent&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;En cas d'indisponibilit&#233; du daemon :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;IndexService.connect() &#8594; RemoteIndexBackend (si daemon disponible) &#8594; LocalIndexBackend (si daemon indisponible)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;LocalIndexBackend&lt;/code&gt; est un proxy thread&#8209;safe, totalement ind&#233;pendant du type d'index.&lt;/p&gt;
&lt;h2&gt;&lt;strong&gt;Synth&#232;se&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;La &lt;strong&gt;v200&lt;/strong&gt; est une architecture RAG :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;modulaire&lt;/strong&gt;, gr&#226;ce &#224; des services d&#233;di&#233;s pour les mod&#232;les et les index,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;performante&lt;/strong&gt;, via un daemon Pyro5 servant les index en m&#233;moire,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;normalis&#233;e&lt;/strong&gt;, gr&#226;ce &#224; une API interne unifi&#233;e pour tous les backends,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;r&#233;siliente&lt;/strong&gt;, via un fallback local automatique,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ind&#233;pendante de LlamaIndex&lt;/strong&gt;, gr&#226;ce &#224; l'encapsulation compl&#232;te dans &lt;code&gt;LlamaIndexBackend&lt;/code&gt;,&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;stable&lt;/strong&gt;, gr&#226;ce &#224; une couche de normalisation syst&#233;matique pour RagRuntime.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Elle constitue une base industrielle, coh&#233;rente, et extensible pour un pipeline RAG moderne.&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Politique LRU/MRU</title>
		<link>https://ia.dnc.global/Politique-LRU-MRU.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Politique-LRU-MRU.html</guid>
		<dc:date>2026-06-29T09:04:20Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Dans l'architecture Pyro5, les index ( et certains mod&#232;les ) sont charg&#233;s depuis le disque puis conserv&#233;s en RAM pour &#234;tre accessibles rapidement par les services distants. Le daemon joue le r&#244;le de processus ma&#238;tre. &lt;br class='autobr' /&gt;
Pour les index par exemple, il les expose via IndexServer, et sert de point d'acc&#232;s unique pour tous les RemoteIndexService. Comme ces index peuvent &#234;tre volumineux et que le daemon est con&#231;u pour rester actif longtemps, il doit g&#233;rer sa m&#233;moire de mani&#232;re autonome et efficace. C'est (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-v200-.html" rel="directory"&gt;Architecture v200&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;Dans l'architecture Pyro5, les index ( et certains mod&#232;les ) sont charg&#233;s depuis le disque puis conserv&#233;s en RAM pour &#234;tre accessibles rapidement par les services distants. Le daemon joue le r&#244;le de processus ma&#238;tre.&lt;/p&gt;
&lt;p&gt;Pour les index par exemple, il les expose via IndexServer, et sert de point d'acc&#232;s unique pour tous les RemoteIndexService.&lt;/p&gt;
&lt;p&gt;Comme ces index peuvent &#234;tre volumineux et que le daemon est con&#231;u pour rester actif longtemps, il doit g&#233;rer sa m&#233;moire de mani&#232;re autonome et efficace. C'est pr&#233;cis&#233;ment pour cela qu'une politique LRU/MRU est indispensable : elle permet de conserver en RAM les index les plus r&#233;cemment utilis&#233;s (MRU), tout en &#233;vin&#231;ant automatiquement ceux qui ne sont plus sollicit&#233;s (LRU).&lt;/p&gt;
&lt;p&gt;Cette strat&#233;gie garantit que le flowchart Pyro5 fonctionne de mani&#232;re fluide, sans surcharge m&#233;moire, et que les services distants acc&#232;dent toujours aux index pertinents sans rechargement inutile depuis le disque.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;hr /&gt;
&lt;h1&gt;Politique LRU/MRU&lt;/h1&gt;
&lt;p&gt;La politique &lt;strong&gt;LRU/MRU&lt;/strong&gt; (Least Recently Used / Most Recently Used) est un m&#233;canisme de gestion de la m&#233;moire qui permet de d&#233;cider &lt;strong&gt;quel objet doit &#234;tre &#233;vinc&#233;&lt;/strong&gt; lorsque la RAM atteint sa capacit&#233; maximale. Elle repose sur un principe simple : &lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;MRU&lt;/strong&gt; = objets r&#233;cemment utilis&#233;s &#8594; &#224; conserver &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LRU&lt;/strong&gt; = objets peu utilis&#233;s r&#233;cemment &#8594; candidats &#224; l'&#233;viction &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Dans notre syst&#232;me, cette politique est appliqu&#233;e par le &lt;strong&gt;MemoryManager&lt;/strong&gt;, qui maintient un ordre strict des objets en RAM gr&#226;ce &#224; un &lt;code&gt;OrderedDict&lt;/code&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;MRU &#8212; Most Recently Used&lt;/h2&gt;
&lt;p&gt;Un objet devient &lt;strong&gt;MRU&lt;/strong&gt; lorsqu'il est :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;charg&#233; en RAM,&lt;/li&gt;
&lt;li&gt;acc&#233;d&#233; via &lt;code&gt;get()&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;marqu&#233; via &lt;code&gt;touch()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le MemoryManager d&#233;place alors la cl&#233; &lt;strong&gt;&#224; la fin&lt;/strong&gt; de l'OrderedDict :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[ LRU ... &#8594; ... MRU ]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cela signifie :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;cet index est actif,&lt;/li&gt;
&lt;li&gt;il doit &#234;tre conserv&#233; en priorit&#233;,&lt;/li&gt;
&lt;li&gt;il ne doit pas &#234;tre &#233;vinc&#233; tant que d'autres objets moins utilis&#233;s existent.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;LRU &#8212; Least Recently Used&lt;/h2&gt;
&lt;p&gt;L'objet &lt;strong&gt;LRU&lt;/strong&gt; est celui qui :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;n'a pas &#233;t&#233; utilis&#233; depuis le plus longtemps,&lt;/li&gt;
&lt;li&gt;n'a pas &#233;t&#233; touch&#233; r&#233;cemment,&lt;/li&gt;
&lt;li&gt;se trouve &lt;strong&gt;au d&#233;but&lt;/strong&gt; de l'OrderedDict.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Lorsqu'une &#233;viction est n&#233;cessaire (ex : &lt;code&gt;len(store) &gt; max_items&lt;/code&gt;), le MemoryManager fait :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#034;language-python&#034;&gt;key, _ = self._store.popitem(last=False)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce qui retire &lt;strong&gt;le premier &#233;l&#233;ment&lt;/strong&gt;, donc le LRU.&lt;/p&gt;
&lt;h2&gt;Pourquoi LRU/MRU est id&#233;al dans ton architecture&lt;/h2&gt;
&lt;h3&gt;1. &lt;strong&gt;Les index sont lourds&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Ils peuvent peser plusieurs centaines de Mo.&lt;br /&gt;
Il est donc crucial d'&#233;viter de recharger inutilement depuis le disque.&lt;/p&gt;
&lt;h3&gt;2. &lt;strong&gt;Les RemoteIndexService sont stateless&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Ils ne conservent rien : tout repose sur la RAM du daemon.&lt;br /&gt;
LRU/MRU garantit que les index r&#233;ellement utilis&#233;s restent disponibles.&lt;/p&gt;
&lt;h3&gt;3. &lt;strong&gt;Le daemon est long-lived&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Il doit s'auto-r&#233;guler sans intervention humaine.&lt;br /&gt;
LRU/MRU fournit une politique simple, d&#233;terministe et efficace.&lt;/p&gt;
&lt;h3&gt;4. &lt;strong&gt;Les th&#232;mes ont des patterns d'acc&#232;s naturels&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Certains th&#232;mes sont consult&#233;s souvent (MRU), d'autres rarement (LRU).&lt;br /&gt;
La politique s'adapte automatiquement &#224; ces usages.&lt;/p&gt;
&lt;h2&gt;R&#233;sultat : une m&#233;moire auto-optimis&#233;e&lt;/h2&gt;
&lt;p&gt;Gr&#226;ce &#224; LRU/MRU :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Les index actifs restent en RAM &#8594; &lt;strong&gt;latence minimale&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Les index inactifs sont &#233;vinc&#233;s &#8594; &lt;strong&gt;RAM ma&#238;tris&#233;e&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Le daemon ne recharge que si n&#233;cessaire &#8594; &lt;strong&gt;I/O minimis&#233;es&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;Le syst&#232;me reste stable m&#234;me sous forte charge &#8594; &lt;strong&gt;robustesse&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Construction des mod&#232;les : models.json et services.json</title>
		<link>https://ia.dnc.global/Construction-des-modeles-models-json-et-services-json.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Construction-des-modeles-models-json-et-services-json.html</guid>
		<dc:date>2026-06-23T08:51:00Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;L'architecture v200 repose sur une s&#233;paration stricte entre la d&#233;finition des mod&#232;les, leur construction centralis&#233;e, et la d&#233;claration des services qui les consomment. &lt;br class='autobr' /&gt;
Les mod&#232;les sont d&#233;crits dans un fichier unique (`models.json`), puis construits une seule fois au d&#233;marrage par le `ModelsConfigurator`, avant d'&#234;tre stock&#233;s dans `AppSettings` pour &#234;tre partag&#233;s par l'ensemble du runtime. &lt;br class='autobr' /&gt;
Les services Pyro5, d&#233;clar&#233;s dans `services.json`, ne chargent jamais de mod&#232;les eux&#8209;m&#234;mes : ils se contentent (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-v200-.html" rel="directory"&gt;Architecture v200&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;L'architecture v200 repose sur une s&#233;paration stricte entre la d&#233;finition des mod&#232;les, leur &lt;a href='https://ia.dnc.global/Trois-modes-de-chargement-des-modeles.html' class='spip_in'&gt;construction centralis&#233;e&lt;/a&gt;, et la d&#233;claration des services qui les consomment. &lt;br class='autobr' /&gt;
Les mod&#232;les sont d&#233;crits dans un fichier unique (`models.json`), puis construits une seule fois au d&#233;marrage par le `ModelsConfigurator`, avant d'&#234;tre stock&#233;s dans `AppSettings` pour &#234;tre partag&#233;s par l'ensemble du runtime. &lt;br class='autobr' /&gt;
Les services Pyro5, d&#233;clar&#233;s dans `services.json`, ne chargent jamais de mod&#232;les eux&#8209;m&#234;mes : ils se contentent d'exposer des capacit&#233;s en s'appuyant sur les objets d&#233;j&#224; initialis&#233;s, garantissant ainsi coh&#233;rence, performance et isolation des responsabilit&#233;s.&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div &lt;div class='rss_ps'&gt;&lt;hr /&gt;
&lt;h1&gt;Construction des mod&#232;les : &lt;code&gt;models.json&lt;/code&gt; et &lt;code&gt;services.json&lt;/code&gt;&lt;/h1&gt;
&lt;h2&gt;1. Pr&#233;sentation g&#233;n&#233;rale : comment les mod&#232;les sont construits dans v200&lt;/h2&gt;
&lt;p&gt;L'architecture v200 repose sur une s&#233;paration stricte des responsabilit&#233;s :&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;1. &lt;code&gt;models.json&lt;/code&gt; d&#233;crit les mod&#232;les&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Ce fichier d&#233;clare &lt;em&gt;uniquement&lt;/em&gt; les mod&#232;les utilis&#233;s par le runtime :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;embedding &lt;/li&gt;
&lt;li&gt;slm &lt;/li&gt;
&lt;li&gt;tokenizer &lt;/li&gt;
&lt;li&gt;llm &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Chaque entr&#233;e d&#233;crit :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;code&gt;model_name&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;model_path&lt;/code&gt; (optionnel) &lt;/li&gt;
&lt;li&gt;&lt;code&gt;backend&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;api_key_env&lt;/code&gt; (si backend = API)
etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;2. ModelsConfigurator construit les mod&#232;les&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Le composant &lt;code&gt;ModelsConfigurator&lt;/code&gt; :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;lit &lt;code&gt;models.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;instancie les mod&#232;les (HF, API, local, etc.)&lt;/li&gt;
&lt;li&gt;cr&#233;e les objets Python correspondants&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Il ne conna&#238;t pas les services Pyro5.&lt;/p&gt;
&lt;h3&gt;&lt;strong&gt;3. AppSettingsManager stocke les mod&#232;les&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Une fois construits, les mod&#232;les sont transmis &#224; :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;AppSettingsManager.load_models(...)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ce composant :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;cr&#233;e un objet &lt;code&gt;AppSettings&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;stocke les mod&#232;les dans des attributs statiques&lt;/li&gt;
&lt;li&gt;verrouille la configuration&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&lt;strong&gt;4. Les services Pyro5 consomment les mod&#232;les&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Les services (EmbeddingServer, SLMServer, IndexServer, MemoryManager) :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;ne chargent pas de mod&#232;les&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ne re&#231;oivent pas de param&#232;tres de mod&#232;le&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;r&#233;cup&#232;rent les mod&#232;les via :&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&#034;language-python&#034;&gt;from runtime_v2.settings.app_settings import AppSettings self.embedding = AppSettings.embedding
self.slm = AppSettings.slm
self.tokenizer = AppSettings.tokenizer
self.llm = AppSettings.llm&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&lt;strong&gt;5. &lt;code&gt;services.json&lt;/code&gt; d&#233;crit uniquement les services&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;Ce fichier :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;d&#233;clare les services Pyro5&lt;/li&gt;
&lt;li&gt;indique leur classe Python&lt;/li&gt;
&lt;li&gt;fournit uniquement les param&#232;tres n&#233;cessaires aux RPC (ex : nom d'un autre service)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Il &lt;strong&gt;ne doit jamais contenir de param&#232;tres de mod&#232;le&lt;/strong&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2&gt;2. Comment &#233;crire &lt;code&gt;models.json&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Voici la structure de base :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#034;language-json&#034;&gt;{ &#034;__comment&#034;: &#034;Source de ModelsConfigurator pour la configuration des mod&#232;les du runtime v200.&#034;, &#034;embedding&#034;: { &#034;__comment&#034;: &#034;Embedding local bas&#233; sur SentenceTransformers (ST). Utilise BGE-small en mode l&#233;ger, sans AutoModel/AutoTokenizer, pour &#233;viter la surcharge m&#233;moire des mod&#232;les HF.&#034;, &#034;model_type&#034;: &#034;embedding&#034;, &#034;model_name&#034;: &#034;BAAI/bge-small-en-v1.5&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/bge-small&#034;, &#034;backend&#034;: &#034;st&#034;, &#034;device&#034;: &#034;cpu&#034; }, &#034;slm&#034;: { &#034;__comment&#034;: &#034;SLM local optionnel (TinyLlama, Phi, etc.). Null = d&#233;sactiv&#233;.&#034;, &#034;model_type&#034;: &#034;causal_lm&#034;, &#034;model_name&#034;: null, &#034;model_path&#034;: null, &#034;backend&#034;: null, &#034;device&#034;: null }, &#034;tokenizer&#034;: { &#034;__comment&#034;: &#034;Tokenizer HF externe (Mixtral), t&#233;l&#233;charg&#233; via HF.&#034;, &#034;model_type&#034;: &#034;tokenizer&#034;, &#034;model_name&#034;: &#034;mistralai/Mixtral-8x7B-Instruct-v0.1&#034;, &#034;model_path&#034;: null, &#034;backend&#034;: &#034;hf&#034;, &#034;device&#034;: null }, &#034;llm&#034;: { &#034;__comment&#034;: &#034;LLM principal via Daemon.&#034;, &#034;model_type&#034;: &#034;causal_lm&#034;, &#034;backend&#034;: &#034;mistral_daemon&#034;, &#034;model_name&#034;: &#034;mistral-medium-latest&#034;, &#034;api_key_env&#034;: &#034;MISTRAL_API_KEY&#034;, &#034;daemon_host&#034;: &#034;127.0.0.1&#034;, &#034;daemon_port&#034;: 50050 }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ou, plus ambitieux ( &#224; condition que les backends aient &#233;t&#233; &#233;crits) :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#034;language-json&#034;&gt;{ &#034;__comment&#034;: &#034;Configuration canonique v200 &#8212; aucun champ implicite, aucun type d&#233;duit automatiquement.&#034;, &#034;llm_api&#034;: { &#034;model_name&#034;: &#034;mistral-medium-latest&#034;, &#034;backend&#034;: &#034;mistral_api&#034;, &#034;model_type&#034;: &#034;causal_lm&#034;, &#034;api_key_env&#034;: &#034;MISTRAL_API_KEY&#034;, &#034;max_new_tokens&#034;: 2048, &#034;temperature&#034;: 0.2 }, &#034;llm_daemon&#034;: { &#034;model_name&#034;: &#034;mistral-medium-latest&#034;, &#034;backend&#034;: &#034;mistral_daemon&#034;, &#034;model_type&#034;: &#034;causal_lm&#034;, &#034;api_key&#034;: &#034;env:MISTRAL_API_KEY&#034;, &#034;daemon_host&#034;: &#034;127.0.0.1&#034;, &#034;daemon_port&#034;: 50050, &#034;max_new_tokens&#034;: 2048, &#034;temperature&#034;: 0.0 }, &#034;slm&#034;: { &#034;model_name&#034;: &#034;TinyLlama/TinyLlama-1.1B-Chat-v1.0&#034;, &#034;backend&#034;: &#034;hf_local&#034;, &#034;model_type&#034;: &#034;hf_causal_lm&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/TinyLlama-1.1B-Chat-v1.0&#034;, &#034;device&#034;: &#034;cpu&#034;, &#034;dtype&#034;: &#034;float16&#034;, &#034;max_new_tokens&#034;: 512, &#034;temperature&#034;: 0.0 }, &#034;embedding&#034;: { &#034;model_name&#034;: &#034;BAAI/bge-small-en-v1.5&#034;, &#034;backend&#034;: &#034;st&#034;, &#034;model_type&#034;: &#034;embedding&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/bge-small&#034;, &#034;device&#034;: &#034;cpu&#034; }, &#034;tokenizer&#034;: { &#034;model_name&#034;: &#034;mistralai/Mixtral-8x7B-Instruct-v0.1&#034;, &#034;backend&#034;: &#034;hf&#034;, &#034;model_type&#034;: &#034;tokenizer&#034;, &#034;device&#034;: &#034;cpu&#034; }, &#034;service_router&#034;: { &#034;model_name&#034;: &#034;router-v1&#034;, &#034;backend&#034;: &#034;internal&#034;, &#034;model_type&#034;: &#034;router&#034;, &#034;strategy&#034;: &#034;round_robin&#034;, &#034;targets&#034;: [&#034;llm_api&#034;, &#034;llm_daemon&#034;, &#034;slm&#034;] }, &#034;reranker&#034;: { &#034;model_name&#034;: &#034;colbertv2&#034;, &#034;backend&#034;: &#034;hf_local&#034;, &#034;model_type&#034;: &#034;reranker&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/colbertv2&#034;, &#034;device&#034;: &#034;cuda&#034;, &#034;dtype&#034;: &#034;float16&#034; }, &#034;vision_encoder&#034;: { &#034;model_name&#034;: &#034;openai/clip-vit-base-patch32&#034;, &#034;backend&#034;: &#034;hf_local&#034;, &#034;model_type&#034;: &#034;vision_encoder&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/clip-vit-base-patch32&#034;, &#034;device&#034;: &#034;cuda&#034; }, &#034;audio_encoder&#034;: { &#034;model_name&#034;: &#034;facebook/wav2vec2-base-960h&#034;, &#034;backend&#034;: &#034;hf_local&#034;, &#034;model_type&#034;: &#034;audio_encoder&#034;, &#034;model_path&#034;: &#034;/home/iadnc/.models/wav2vec2&#034;, &#034;device&#034;: &#034;cpu&#034; }, &#034;http_service&#034;: { &#034;model_name&#034;: &#034;custom-service&#034;, &#034;backend&#034;: &#034;http&#034;, &#034;model_type&#034;: &#034;service&#034;, &#034;service_url&#034;: &#034;http://127.0.0.1:8080/infer&#034;, &#034;timeout&#034;: 30 }
}&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;R&#232;gles :&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;Chaque mod&#232;le doit avoir un &lt;code&gt;model_name&lt;/code&gt;&lt;/strong&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;model_path&lt;/code&gt; peut &#234;tre &lt;code&gt;null&lt;/code&gt; si HF doit t&#233;l&#233;charger automatiquement &lt;/li&gt;
&lt;li&gt;&lt;code&gt;backend&lt;/code&gt; d&#233;termine le loader (hf, hf_local, mistral_api, etc.) &lt;/li&gt;
&lt;li&gt;&lt;code&gt;device&lt;/code&gt; peut &#234;tre &lt;code&gt;cpu&lt;/code&gt;, &lt;code&gt;cuda&lt;/code&gt;, ou &lt;code&gt;null&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;code&gt;api_key&lt;/code&gt; est utilis&#233; uniquement pour les backends API &lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2&gt;3. Comment &#233;crire &lt;code&gt;services.json&lt;/code&gt;&lt;/h2&gt;
&lt;p&gt;Voici la version minimale, conforme &#224; v200 :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#034;language-json&#034;&gt;{ &#034;daemon&#034;: { &#034;host&#034;: &#034;127.0.0.1&#034;, &#034;port&#034;: XXX }, &#034;services&#034;: [ { &#034;name&#034;: &#034;llm.server&#034;, &#034;class&#034;: &#034;runtime_v21.services.llm.llm_server.LlmServer&#034;, &#034;params&#034;: {} }, { &#034;name&#034;: &#034;slm.server&#034;, &#034;class&#034;: &#034;runtime_v21.services.llm.slm_server.SlmServer&#034;, &#034;params&#034;: {} }, { &#034;name&#034;: &#034;memory.server&#034;, &#034;class&#034;: &#034;runtime_v21.services.memory_manager.MemoryManager&#034;, &#034;params&#034;: {} } ], &#034;index&#034;: { &#034;loader&#034;: { &#034;class&#034;: &#034;runtime_v21.services.index.loaders.loader_manager.ThemeIndexLoaderManager&#034;, &#034;params&#034;: {} }, &#034;reserved_ram&#034;: 100000000 }
}, &#034;tokenizer&#034;: { &#034;model_name&#034;: &#034;mistralai/Mixtral-8x7B-Instruct-v0.1&#034;, &#034;backend&#034;: &#034;hf&#034;, &#034;model_type&#034;: &#034;tokenizer&#034;, &#034;device&#034;: &#034;cpu&#034; }
}&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;R&#232;gles :&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Aucun service ne doit recevoir de mod&#232;le&lt;/strong&gt;&lt;br /&gt;
&#8594; pas de &lt;code&gt;model&lt;/code&gt;, &lt;code&gt;model_name&lt;/code&gt;, &lt;code&gt;backend&lt;/code&gt;, &lt;code&gt;device&lt;/code&gt;, etc.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Les services doivent recevoir uniquement :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;des noms de services Pyro5 (pour RPC)&lt;/li&gt;
&lt;li&gt;des param&#232;tres m&#233;tier (rare)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Les services doivent r&#233;cup&#233;rer les mod&#232;les via &lt;code&gt;AppSettings&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;4. R&#233;sum&#233;&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&#201;l&#233;ment&lt;/th&gt;
&lt;th&gt;R&#244;le&lt;/th&gt;
&lt;th&gt;Contenu&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;models.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;D&#233;crit les mod&#232;les&lt;/td&gt;
&lt;td&gt;model_name, backend, device, path&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;ModelsConfigurator&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Construit les mod&#232;les&lt;/td&gt;
&lt;td&gt;HF, API, local&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;AppSettingsManager&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Stocke les mod&#232;les&lt;/td&gt;
&lt;td&gt;AppSettings.embedding, etc.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;services.json&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;D&#233;crit les services&lt;/td&gt;
&lt;td&gt;classes, RPC, d&#233;pendances&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Services Pyro5&lt;/td&gt;
&lt;td&gt;Consomment les mod&#232;les&lt;/td&gt;
&lt;td&gt;via AppSettings&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Protocoles des API LLM </title>
		<link>https://ia.dnc.global/Protocoles-des-API-LLM.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Protocoles-des-API-LLM.html</guid>
		<dc:date>2026-06-16T08:12:06Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Ce document d&#233;crit les deux modes d'appel aux API utilis&#233;s par les mod&#232;les LLM dans l'architecture v200 : synchrone et streaming. Protocoles d'appel LLM : synchrone vs streaming &lt;br class='autobr' /&gt;
Ce document d&#233;crit les deux modes d'appel utilis&#233;s par les mod&#232;les LLM dans l'architecture v200 : appel synchrone (generate) appel en streaming (stream_generate) &lt;br class='autobr' /&gt;
Les deux modes utilisent HTTP(S), mais pas le m&#234;me protocole. &lt;br class='autobr' /&gt;
Dans la v200, les InternalLLM sont les seules classes responsables : de la configuration backend (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;Ce document d&#233;crit les deux modes d'appel aux API utilis&#233;s par les mod&#232;les LLM dans l'architecture v200 : synchrone et streaming.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;h1&gt;Protocoles d'appel LLM : synchrone vs streaming&lt;/h1&gt;
&lt;p&gt;Ce document d&#233;crit les deux modes d'appel utilis&#233;s par les mod&#232;les LLM dans l'architecture v200 :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;appel synchrone (&lt;code&gt;generate&lt;/code&gt;)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;appel en streaming (&lt;code&gt;stream_generate&lt;/code&gt;)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Les deux modes utilisent HTTP(S), mais &lt;strong&gt;pas le m&#234;me protocole&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Dans la v200, &lt;strong&gt;les InternalLLM sont les seules classes responsables&lt;/strong&gt; :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;de la configuration backend (client, mod&#232;le, URL si HTTP)&lt;/li&gt;
&lt;li&gt;de l'appel synchrone&lt;/li&gt;
&lt;li&gt;de l'appel streaming&lt;/li&gt;
&lt;li&gt;de la normalisation des r&#233;ponses&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;1. Appel synchrone : HTTP POST classique&lt;/h2&gt;
&lt;p&gt;L'appel synchrone (&lt;code&gt;generate&lt;/code&gt;) utilise un &lt;strong&gt;POST HTTP standard&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;Caract&#233;ristiques&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Une seule requ&#234;te&lt;/li&gt;
&lt;li&gt;Une seule r&#233;ponse&lt;/li&gt;
&lt;li&gt;Format JSON complet&lt;/li&gt;
&lt;li&gt;Pas de flux&lt;/li&gt;
&lt;li&gt;Pas de tokens interm&#233;diaires&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Exemple (OpenAI/Mistral-like)&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;POST /v1/chat/completions
Content-Type: application/json { &#034;model&#034;: &#034;mistral-large&#034;, &#034;messages&#034;: [...]
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;R&#233;ponse :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;200 OK
Content-Type: application/json { &#034;id&#034;: &#034;...&#034;, &#034;choices&#034;: [ { &#034;message&#034;: { &#034;content&#034;: &#034;r&#233;ponse compl&#232;te&#034; } } ]
}&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;2. Appel streaming : HTTP POST + protocole de flux&lt;/h2&gt;
&lt;p&gt;L'appel &lt;code&gt;stream_generate&lt;/code&gt; utilise &#233;galement un &lt;strong&gt;POST HTTP&lt;/strong&gt;, mais la r&#233;ponse n'est pas un JSON unique.&lt;br /&gt;
Le serveur envoie un &lt;strong&gt;flux d'&#233;v&#233;nements&lt;/strong&gt; ou de &lt;strong&gt;chunks&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Deux protocoles sont utilis&#233;s selon les backends :&lt;/p&gt;
&lt;h2&gt;2.1. SSE (Server-Sent Events)&lt;/h2&gt;
&lt;p&gt;C'est le protocole utilis&#233; par :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;OpenAI &lt;/li&gt;
&lt;li&gt;Mistral &lt;/li&gt;
&lt;li&gt;Anthropic &lt;/li&gt;
&lt;li&gt;Groq &lt;/li&gt;
&lt;li&gt;LM Studio (mode OpenAI)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Caract&#233;ristiques&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;code&gt;Content-Type: text/event-stream&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Transfer-Encoding: chunked&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Chaque ligne commence par &lt;code&gt;data:&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Chaque &#233;v&#233;nement contient un fragment (&lt;code&gt;delta&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Le flux se termine par &lt;code&gt;data: [DONE]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Exemple&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;data: {&#034;choices&#034;:[{&#034;delta&#034;:{&#034;content&#034;:&#034;Bon&#034;}}]}
data: {&#034;choices&#034;:[{&#034;delta&#034;:{&#034;content&#034;:&#034;jour&#034;}}]}
data: {&#034;choices&#034;:[{&#034;delta&#034;:{&#034;content&#034;:&#034; !&#034;}}]}
data: [DONE]&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;2.2. Chunked Transfer Encoding (Ollama)&lt;/h2&gt;
&lt;p&gt;Ollama n'utilise pas SSE mais un flux de &lt;strong&gt;JSON successifs&lt;/strong&gt;, un par chunk.&lt;/p&gt;
&lt;h3&gt;Exemple&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;{&#034;response&#034;: &#034;Bon&#034;}
{&#034;response&#034;: &#034;jour&#034;}
{&#034;response&#034;: &#034; Bertrand&#034;}
{&#034;done&#034;: true}&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Caract&#233;ristiques&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Pas de &lt;code&gt;data:&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Pas de SSE&lt;/li&gt;
&lt;li&gt;Chaque chunk est un JSON ind&#233;pendant&lt;/li&gt;
&lt;li&gt;Le client doit lire le flux chunk par chunk&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;3. Pourquoi deux protocoles diff&#233;rents ?&lt;/h2&gt;
&lt;p&gt;Parce que :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;un appel synchrone renvoie &lt;strong&gt;une r&#233;ponse compl&#232;te&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;un streaming renvoie &lt;strong&gt;un flux de tokens&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;HTTP classique ne permet pas d'envoyer plusieurs r&#233;ponses successives.&lt;br /&gt;
Les serveurs utilisent donc :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;SSE&lt;/strong&gt; &#8594; flux d'&#233;v&#233;nements textuels&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;chunked transfer&lt;/strong&gt; &#8594; flux de JSON partiels&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;WebSocket&lt;/strong&gt; (rare) &#8594; flux bidirectionnel&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;4. Cons&#233;quences pour l'architecture v200&lt;/h2&gt;
&lt;h3&gt;4.1. &lt;code&gt;generate()&lt;/code&gt;&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;utilise un &lt;strong&gt;appel HTTP simple&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;renvoie un JSON complet&lt;/li&gt;
&lt;li&gt;normalisation effectu&#233;e dans la classe LLM&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;4.2. &lt;code&gt;stream_generate()&lt;/code&gt;&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;utilise &lt;strong&gt;SSE&lt;/strong&gt; ou &lt;strong&gt;chunked transfer&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;lit les fragments au fur et &#224; mesure&lt;/li&gt;
&lt;li&gt;normalise chaque fragment en format v200 :&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;{ &#034;delta&#034;: &#034;texte&#034; }
...
{ &#034;delta&#034;: &#034;&#034;, &#034;meta&#034;: {...} }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Retourne un flux de chunks repr&#233;sentant la r&#233;ponse en streaming.
Contrat de l'interface :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;La m&#233;thode doit produire un it&#233;rable de chunks.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code&gt;Convention v200 (obligatoire pour toutes les impl&#233;mentations) :
- Les chunks interm&#233;diaires sont des dicts contenant : { &#034;delta&#034;: &#034;&lt;texte incr&#233;mental&gt;&#034; }
- Le dernier chunk contient en plus des m&#233;tadonn&#233;es : { &#034;delta&#034;: &#034;&#034;, &#034;meta&#034;: {...} } Cette convention garantit un format standardis&#233; pour toutes les
impl&#233;mentations InternalLLM, ind&#233;pendamment du backend utilis&#233;.&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;5. R&#233;sum&#233;&lt;/h2&gt;
&lt;p&gt;| Mode | Protocole | Format | Usage |
| &lt;code&gt;generate()&lt;/code&gt; | HTTP POST classique | JSON complet | r&#233;ponse unique |
| &lt;code&gt;stream_generate&lt;/code&gt; | SSE ou chunked transfer | flux de tokens | streaming |&lt;/p&gt;
&lt;h2&gt;6. Exemple&lt;/h2&gt;&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_python code&#034;&gt;&lt;div class=&#034;python&#034;&gt;&lt;ol&gt;&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;from&lt;/span&gt; commons.&lt;span style=&#034;color: black;&#034;&gt;models&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;internal&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;base&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;import&lt;/span&gt; BaseGenerativeModel&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;from&lt;/span&gt; commons.&lt;span style=&#034;color: black;&#034;&gt;models&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;response&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;import&lt;/span&gt; Response&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;class&lt;/span&gt; MistralAPIInternalLLM&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;BaseGenerativeModel&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Impl&#233;mentation Mistral API pour v200.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Cette classe contient :&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - la configuration backend (client, mod&#232;le)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - generate() : appel synchrone&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - stream_generate() : appel SSE&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - normalisation des r&#233;ponses&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; &#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;def&lt;/span&gt; &lt;span style=&#034;color: #0000cd;&#034;&gt;__init__&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; client&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; model_name: &lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;client&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; client&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;model_name&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; model_name&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;def&lt;/span&gt; generate&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; prompt: &lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; **kwargs&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; -&lt;span style=&#034;color: #66cc66;&#034;&gt;&gt;&lt;/span&gt; Response:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Appel synchrone : requ&#234;te HTTP compl&#232;te, pas de streaming.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Le format exact de la r&#233;ponse d&#233;pend du backend.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; &#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; raw &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;client&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;chat&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;completions&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;create&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; model&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;model_name&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; messages&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;role&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;user&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;content&#034;&lt;/span&gt;: prompt&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; stream&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;False&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; **kwargs&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; text &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; raw&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;choices&#034;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;0&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;message&#034;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;content&#034;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;except&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;Exception&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; text &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;raw&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;return&lt;/span&gt; Response&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; response&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;text&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; raw_response&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;raw&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; source_nodes&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; metadata&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;def&lt;/span&gt; stream_generate&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; prompt: &lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; **kwargs&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Retourne un flux de chunks.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Le format exact d&#233;pend de l'impl&#233;mentation.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Convention interne v200 :&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - chunks interm&#233;diaires : {&#034;delta&#034;: &#034;...&#034;}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; - chunk final : {&#034;delta&#034;: &#034;&#034;, &#034;meta&#034;: {...}}&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; &#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; stream &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;client&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;chat&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;completions&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;create&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; model&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;self&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;model_name&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; messages&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;role&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;user&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;content&#034;&lt;/span&gt;: prompt&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; stream&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;True&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; **kwargs&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; final_message &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;for&lt;/span&gt; &lt;span style=&#034;color: #dc143c;&#034;&gt;chunk&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;in&lt;/span&gt; stream:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; delta &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; &lt;span style=&#034;color: #dc143c;&#034;&gt;chunk&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;choices&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; c &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #dc143c;&#034;&gt;chunk&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;choices&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;0&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;getattr&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;delta&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;and&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;getattr&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;c.&lt;span style=&#034;color: black;&#034;&gt;delta&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;content&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; delta &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; c.&lt;span style=&#034;color: black;&#034;&gt;delta&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;content&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;or&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;getattr&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;message&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; final_message &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; c.&lt;span style=&#034;color: black;&#034;&gt;message&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;yield&lt;/span&gt; &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;delta&#034;&lt;/span&gt;: delta&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;yield&lt;/span&gt; &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;delta&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;meta&#034;&lt;/span&gt;: &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;raw_response&#034;&lt;/span&gt;: final_message&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;nodes&#034;&lt;/span&gt;: &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;metadata&#034;&lt;/span&gt;: &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class='download code_download'&gt;&lt;a href='https://ia.dnc.global/local/cache-code/07a1958561fb31461b02b12920adbad1.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>Comment ReActAgent s'ins&#232;re dans le Workflow LlamaIndex</title>
		<link>https://ia.dnc.global/Comment-ReActAgent-s-insere-dans-le-Workflow-LlamaIndex.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Comment-ReActAgent-s-insere-dans-le-Workflow-LlamaIndex.html</guid>
		<dc:date>2026-04-13T10:15:10Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Dans LlamaIndex, la boucle ReAct repose sur un principe simple : le workflow orchestre, l'agent raisonne. &#192; chaque appel, g&#233;n&#232;re un prompt, interroge le LLM, reconstruit une &#233;tape de raisonnement et laisse le finalizer d&#233;cider de la suite. Une m&#233;canique minimale c&#244;t&#233; workflow, une intelligence maximale c&#244;t&#233; agent. &lt;br class='autobr' /&gt; #La boucle de raisonnement ReAct &lt;br class='autobr' /&gt;
##Comment `ReActAgent` s'ins&#232;re dans le Workflow LlamaIndex &lt;br class='autobr' /&gt;
LlamaIndex ReActAgent, construit sur Workflow, fournit le code du **step** dans un workflow. (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;Dans LlamaIndex, la boucle ReAct repose sur un principe simple : le workflow orchestre, l'agent raisonne. &#192; chaque appel, g&#233;n&#232;re un prompt, interroge le LLM, reconstruit une &#233;tape de raisonnement et laisse le finalizer d&#233;cider de la suite. Une m&#233;canique minimale c&#244;t&#233; workflow, une intelligence maximale c&#244;t&#233; agent.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;hr /&gt;
&lt;h1&gt;La boucle de raisonnement ReAct&lt;/h1&gt;
&lt;h2&gt;Comment &lt;code&gt;ReActAgent&lt;/code&gt; s'ins&#232;re dans le Workflow LlamaIndex&lt;/h2&gt;
&lt;p&gt;LlamaIndex ReActAgent, construit sur Workflow, fournit le code du &lt;strong&gt;step&lt;/strong&gt; dans un workflow. Le workflow appelle :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;BaseAgent.run_agent_step() &#8594; ReActAgent.take_step()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Donc :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;le workflow = &lt;strong&gt;chef d'orchestre&lt;/strong&gt; (encore un !)&lt;/li&gt;
&lt;li&gt;l'agent = &lt;strong&gt;une &#233;tape du workflow&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;take_step()&lt;/code&gt; = &lt;strong&gt;la logique ReAct pour une &#233;tape&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Comment sont construites les steps ReAct ?&lt;/h2&gt;
&lt;p&gt;En v&#233;rit&#233; : Le Workflow ne construit pas des steps ReAct. C'est ReActAgent qui les fait construire par le LLM.
Le Workflow ne fait que :&lt;/p&gt;
&lt;ol class=&#034;spip&#034;&gt;
&lt;li&gt;appeler &lt;code&gt;take_step()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;attendre un &lt;code&gt;AgentStepOutput&lt;/code&gt; (Thought, Action, Action Input ...)&lt;/li&gt;
&lt;li&gt;d&#233;cider avec ReActFinalizer si une nouvelle &#233;tape doit &#234;tre ex&#233;cut&#233;e&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Voici ce qui se passe dans &lt;code&gt;ReActAgent.take_step()&lt;/code&gt; pour construire une &#233;tape :&lt;/p&gt;
&lt;h3&gt;&#201;tape 1 &#8212; Construire le prompt ReAct&lt;/h3&gt;
&lt;p&gt;L'agent g&#233;n&#232;re le prompt ReAct qui fixe les r&#232;gles que devra suivre le LLM pour &#233;laborer les THOUGHT, ACTION et ACTION INPUT, pour appeler les outils etc. Le prompt contient &#233;galement l'historique des &#233;changes et, in fine, la question de l'utilisateur. Voici un exemple tr&#232;s na&#239;f :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;You are a ReAct agent.
First, think step-by-step and write:
THOUGHT:
Then, if needed, write:
ACTION:
ACTION INPUT:
&lt;context&gt;
&lt;query&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&#201;tape 2 &#8212; Appeler le LLM&lt;/h3&gt;
&lt;p&gt;L'agent appelle :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;llm.stream(prompt)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Le LLM g&#233;n&#232;re la r&#233;ponse au prompt. &#8594; Le LLM produit progressivement, par petits fragments, les &lt;strong&gt;deltas&lt;/strong&gt;. &lt;/p&gt;
&lt;h3&gt;&#201;tape 3 &#8212; Le parser reconstruit les blocs&lt;/h3&gt;
&lt;p&gt;Le &lt;code&gt;ReActStreamParser&lt;/code&gt; transforme les deltas en blocs :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;THOUGHT: ...
ACTION: ...
OBSERVATION: ...
...
FINAL_ANSWER: ...&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;&#201;tape 4 &#8212; Le ReActFinalizer d&#233;cide si l'&#233;tape est termin&#233;e&lt;/h3&gt;
&lt;p&gt;Le finalizer :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;valide les blocs&lt;/li&gt;
&lt;li&gt;d&#233;tecte les erreurs&lt;/li&gt;
&lt;li&gt;emp&#234;che les boucles&lt;/li&gt;
&lt;li&gt;d&#233;cide si une nouvelle &#233;tape doit &#234;tre lanc&#233;e&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;&#201;tape 5 &#8212; Le workflow relance &lt;code&gt;take_step()&lt;/code&gt; si n&#233;cessaire&lt;/h3&gt;
&lt;p&gt;Si le finalizer dit &#8220;continue&#8221;, alors :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;workflow &#8594; BaseAgent.run_agent_step &#8594; ReActAgent.take_step()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Et une nouvelle &#233;tape ReAct est produite.&lt;/p&gt;
&lt;h3&gt;En r&#233;sum&#233; : r&#244;le du Workflow&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Le workflow LlamaIndex ne fait qu'appeler &lt;code&gt;take_step()&lt;/code&gt; en boucle.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ReActAgent.take_step()&lt;/code&gt; g&#233;n&#232;re une &lt;em&gt;&#233;tape ReAct&lt;/em&gt; en appelant le LLM.&lt;/li&gt;
&lt;li&gt;Le &lt;code&gt;ReActStreamParser&lt;/code&gt; reconstruit les blocs ReAct &#224; partir des deltas.&lt;/li&gt;
&lt;li&gt;Le &lt;code&gt;ReActFinalizer&lt;/code&gt; d&#233;cide si une nouvelle &#233;tape doit &#234;tre lanc&#233;e.&lt;/li&gt;
&lt;li&gt;Le workflow relance &lt;code&gt;take_step()&lt;/code&gt; si n&#233;cessaire.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span class='spip_document_26 spip_documents spip_documents_center'&gt;
&lt;img src='https://ia.dnc.global/local/cache-vignettes/L428xH753/bouclereact_1-e5172.png?1776293294' width='428' height='753' alt=&#034;&#034; /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Voyez aussi :&lt;/strong&gt;
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; &lt;a href='https://ia.dnc.global/ReActEngine-v1-Modules-et-traitements.html' class='spip_in'&gt;ReActEngine v1 : Modules et traitements&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>RAG : Compression contextuelle</title>
		<link>https://ia.dnc.global/RAG-Compression-contextuelle.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/RAG-Compression-contextuelle.html</guid>
		<dc:date>2026-02-12T08:19:12Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;La contextual compression est un sujet qui est devenu central dans les RAG modernes. &lt;br class='autobr' /&gt;
C'est une technique qui permet de r&#233;duire dynamiquement - c'est &#224; dire en fonction du contexte - la quantit&#233; de texte envoy&#233;e au LLM en ne gardant que ce qui est pertinent pour la requ&#234;te. &lt;br class='autobr' /&gt; On ne renvoit pas les documents bruts, mais une version compress&#233;e, filtr&#233;e, ou r&#233;sum&#233;e, adapt&#233;e &#224; la question. &lt;br class='autobr' /&gt;
C'est un *pr&#233;&#8209;processing intelligent* du contexte. &lt;br class='autobr' /&gt;
#C'est devenu indispensable &lt;br class='autobr' /&gt;
Parce que : les fen&#234;tres de contexte (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;La contextual compression est un sujet qui est devenu central dans les RAG modernes.&lt;/p&gt;
&lt;p&gt;C'est une technique qui permet de r&#233;duire dynamiquement - c'est &#224; dire en fonction du contexte - la quantit&#233; de texte envoy&#233;e au LLM en ne gardant que ce qui est pertinent pour la requ&#234;te.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;p&gt;On ne renvoit pas les documents bruts, mais une version compress&#233;e, filtr&#233;e, ou r&#233;sum&#233;e, adapt&#233;e &#224; la question.&lt;/p&gt;
&lt;p&gt;C'est un &lt;em&gt;pr&#233;&#8209;processing intelligent&lt;/em&gt; du contexte.&lt;/p&gt;
&lt;h1&gt;C'est devenu indispensable&lt;/h1&gt;
&lt;p&gt;Parce que :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;les fen&#234;tres de contexte sont grandes mais pas infinies,&lt;/li&gt;
&lt;li&gt;les chunks bruts sont souvent trop verbeux,&lt;/li&gt;
&lt;li&gt;les embeddings r&#233;cup&#232;rent parfois trop de documents,&lt;/li&gt;
&lt;li&gt;les mod&#232;les hallucinent moins quand le contexte est &lt;em&gt;pr&#233;cis&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;La contextual compression permet :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;d'augmenter la pr&#233;cision,&lt;/li&gt;
&lt;li&gt;de r&#233;duire le bruit,&lt;/li&gt;
&lt;li&gt;d'am&#233;liorer la factualit&#233;,&lt;/li&gt;
&lt;li&gt;de diminuer le co&#251;t.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Les 3 grandes familles de contextual compression&lt;/h1&gt;
&lt;h2&gt;1. Compression par r&#233;sum&#233; (LLM summarization)&lt;/h2&gt;
&lt;p&gt;On r&#233;cup&#232;re les documents pertinents, puis on demandes au LLM :&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&#171; R&#233;sume uniquement les parties utiles pour r&#233;pondre &#224; la requ&#234;te X. &#187;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;C'est la version la plus simple et la plus efficace.&lt;/p&gt;
&lt;h3&gt;Exemple&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Document : 3 pages&lt;/li&gt;
&lt;li&gt;Requ&#234;te : &#171; Quels sont les effets secondaires du m&#233;dicament ? &#187;&lt;/li&gt;
&lt;li&gt;R&#233;sum&#233; compress&#233; : 4 lignes cibl&#233;es&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;2. Compression par extraction (LLM extraction)&lt;/h2&gt;
&lt;p&gt;Le LLM ne r&#233;sume pas : il &lt;strong&gt;extrait&lt;/strong&gt; les passages pertinents.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&#171; Extrait uniquement les phrases qui r&#233;pondent &#224; la question X. &#187;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;C'est plus pr&#233;cis et moins risqu&#233; que le r&#233;sum&#233;.&lt;/p&gt;
&lt;h2&gt;3. Compression par filtrage s&#233;mantique (embedding&#8209;based filtering)&lt;/h2&gt;
&lt;p&gt;On fait un &lt;em&gt;re&#8209;ranking&lt;/em&gt; interne :&lt;/p&gt;
&lt;ol class=&#034;spip&#034;&gt;
&lt;li&gt;r&#233;cup&#233;rer les chunks via embeddings.&lt;/li&gt;
&lt;li&gt;re&#8209;embed de chaque chunk &lt;strong&gt;par rapport &#224; la requ&#234;te&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&#233;limination des chunks peu pertinents.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;C'est du &lt;em&gt;semantic pruning&lt;/em&gt;.&lt;/p&gt;
&lt;h1&gt;Comment &#231;a s'int&#232;gre dans un pipeline RAG ?&lt;/h1&gt;
&lt;p&gt;Voici le pipeline classique :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;User query
&#8594; embedding de la requ&#234;te
&#8594; retrieval (top&#8209;k documents)
&#8594; contextual compression (r&#233;sum&#233; / extraction / filtrage)
&#8594; Prompt final = system + historique + requ&#234;te + contexte compress&#233;
&#8594; LLM&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;La compression intervient entre le retrieval et le prompt final.&lt;/p&gt;
&lt;h1&gt;Pourquoi c'est sup&#233;rieur au RAG na&#239;f ?&lt;/h1&gt;
&lt;h3&gt;Sans compression :&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;envoit trop de texte,&lt;/li&gt;
&lt;li&gt;d&#233;passe la fen&#234;tre,&lt;/li&gt;
&lt;li&gt;ajoute du bruit,&lt;/li&gt;
&lt;li&gt;augmente les hallucinations.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Avec compression :&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;n'envoie que l'essentiel,&lt;/li&gt;
&lt;li&gt;reste dans la fen&#234;tre,&lt;/li&gt;
&lt;li&gt;augmente la pr&#233;cision,&lt;/li&gt;
&lt;li&gt;r&#233;duit le co&#251;t.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le point cl&#233; : la compression est contextuelle&lt;br /&gt;
Ce n'est pas un r&#233;sum&#233; g&#233;n&#233;rique.&lt;br /&gt;
C'est un r&#233;sum&#233; &lt;strong&gt;conditionn&#233; par la requ&#234;te&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Exemple :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Requ&#234;te A : &#171; Quels sont les risques ? &#187;&lt;/li&gt;
&lt;li&gt;Requ&#234;te B : &#171; Quels sont les b&#233;n&#233;fices ? &#187;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Le m&#234;me document donnera &lt;strong&gt;deux compressions diff&#233;rentes&lt;/strong&gt; pour des requ&#234;tes diff&#233;rentes.&lt;/p&gt;
&lt;p&gt;Notons que, par requ&#234;te, on peut entendre historique + question. Ainsi, la m&#234;me question de l'utilisateur, apr&#232;s avoir pos&#233; diff&#233;rentes questions et obtenu diff&#233;rentes r&#233;ponses, une nouvelle question sera trait&#233;e en tenant compte des pr&#233;c&#233;dentes.&lt;/p&gt;
&lt;p&gt;C'est ce qui rend la technique si puissante.&lt;/p&gt;
&lt;h1&gt;Les erreurs fr&#233;quentes&lt;/h1&gt;
&lt;p&gt;-r&#233;sumer les documents &lt;em&gt;avant&lt;/em&gt; le retrieval&lt;br /&gt;
&#8594; tu perds de l'information utile&lt;/p&gt;
&lt;p&gt;-compresser sans conditionner sur la requ&#234;te&lt;br /&gt;
&#8594; tu obtiens un r&#233;sum&#233; g&#233;n&#233;rique, inutile&lt;/p&gt;
&lt;p&gt;-compresser trop t&#244;t dans le pipeline&lt;br /&gt;
&#8594; tu risques de biaiser la recherche&lt;/p&gt;
&lt;p&gt;-compresser avec un mod&#232;le trop faible&lt;br /&gt;
&#8594; tu introduis des erreurs dans le contexte&lt;/p&gt;
&lt;h1&gt;Comment faire une contextual compression robuste ?&lt;/h1&gt;
&lt;h3&gt;&#201;tape 1 &#8212; Retrieval large (top&#8209;20 ou top&#8209;50)&lt;/h3&gt;
&lt;p&gt;On r&#233;cup&#232;re large pour ne rien rater.&lt;/p&gt;
&lt;h3&gt;&#201;tape 2 &#8212; Re&#8209;ranking (embedding ou cross&#8209;encoder)&lt;/h3&gt;
&lt;p&gt;On r&#233;duit &#224; top&#8209;5 ou top&#8209;10.&lt;/p&gt;
&lt;h3&gt;&#201;tape 3 &#8212; Compression LLM (r&#233;sum&#233;/extraction)&lt;/h3&gt;
&lt;p&gt;On produit un contexte propre, court, pr&#233;cis.&lt;/p&gt;
&lt;h3&gt;&#201;tape 4 &#8212; Prompt final&lt;/h3&gt;
&lt;p&gt;On injecte uniquement la version compress&#233;e.&lt;/p&gt;
&lt;p&gt;Ce pipeline est beaucoup plus stable que le RAG na&#239;f.&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>ReAct : le nommage des outils.</title>
		<link>https://ia.dnc.global/ReAct-le-nommage-des-outils.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/ReAct-le-nommage-des-outils.html</guid>
		<dc:date>2026-01-28T10:00:52Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Dans la s&#233;lection d'un outil par le LLM, il appara&#238;t que le nom de l'outil est prioritaire, et que la description est secondaire. De toute &#233;vidence, la description ne peut compl&#233;ter un nom de fonction ambigu et ne servira au LLM qu'en deuxi&#232;me intention. Quelles sont les r&#232;gles &#224; appliquer pour le nommage des outils ? &lt;br class='autobr' /&gt; Dans le choix de l'outil par le LLM, il apparait que le nom de la fonction (= le nom de l'outil) est totalement prioritaire, que la la Docstring vient ensuite, elle-m&#234;me prioritaire sur (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;img class='spip_logo spip_logo_right spip_logos' alt=&#034;&#034; style='float:right' src='https://ia.dnc.global/local/cache-vignettes/L150xH137/arton58-33bf4.png?1776303657' width='150' height='137' /&gt;
		&lt;div class='rss_chapo'&gt;&lt;p&gt;Dans la s&#233;lection d'un outil par le LLM, il appara&#238;t que le nom de l'outil est prioritaire, et que la description est secondaire. De toute &#233;vidence, la description ne peut compl&#233;ter un nom de fonction ambigu et ne servira au LLM qu'en deuxi&#232;me intention.&lt;br class='autobr' /&gt;
Quelles sont les r&#232;gles &#224; appliquer pour le nommage des outils ?&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;p&gt;Dans le choix de l'outil par le LLM, il apparait que le nom de la fonction (= le nom de l'outil) est totalement prioritaire, que la la Docstring vient ensuite, elle-m&#234;me prioritaire sur la m&#233;tadonn&#233;e 'description'&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb1' class='spip_note' rel='appendix' title='La distinction entre Docstring et m&#233;tadonn&#233;e 'description' existe dans l'objet (...)' id='nh1'&gt;1&lt;/a&gt;]&lt;/span&gt; . De toute &#233;vidence, ni la Docstring ni la description ne peuvent corriger un nom de fonction ambigu, elle ne serviront qu'en cas de deuxi&#232;me intention du LLM, apr&#232;s avoir constat&#233; une erreur.&lt;/p&gt;
&lt;h2&gt;Exemple d'ambigu&#239;t&#233;&lt;/h2&gt;
&lt;p&gt;Consid&#233;rons un outil qui convertit une date lisible par un humain (human-readable date) en timestamp. Initialement nomm&#233; 'convert_date_to_timestamp'. On peut constater que l'usage de l'outil est mal compris par le LLM qui, notamment, peut tenter de l'utiliser &#224; l'envers.&lt;/p&gt;
&lt;p&gt;Le mot &#034;date&#034; est trop g&#233;n&#233;rique, et dans un contexte LLM, il peut d&#233;signer aussi bien une date lisible qu'un timestamp. &lt;/p&gt;
&lt;p&gt;Pour &#233;viter toute ambigu&#239;t&#233;, il faut que le nom de l'outil encode clairement :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;le &lt;strong&gt;type d'entr&#233;e attendu&lt;/strong&gt; (ex. : texte lisible par un humain),&lt;/li&gt;
&lt;li&gt;le &lt;strong&gt;type de sortie produit&lt;/strong&gt; (ex. : timestamp num&#233;rique),&lt;/li&gt;
&lt;li&gt;et id&#233;alement, la &lt;strong&gt;direction de la conversion&lt;/strong&gt; : l'entr&#233;e en t&#234;te, la sortie en queue.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Un meilleur choix serait : &lt;strong&gt;&lt;code&gt;readable_date_to_timestamp&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;code&gt;readable_date&lt;/code&gt; d&#233;sambigu&#239;se imm&#233;diatement : ce n'est pas un timestamp.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;to_timestamp&lt;/code&gt; indique clairement la direction.&lt;/li&gt;
&lt;li&gt;C'est court, typiquement LLM-friendly, et sans ambigu&#239;t&#233;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ce qu'il faut &#233;viter :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Des noms ambigus comme &lt;code&gt;convert_dates&lt;/code&gt; ou &lt;code&gt;parse_date&lt;/code&gt; (trop flous)&lt;/li&gt;
&lt;li&gt;Des noms au singulier pour des fonctions vectoris&#233;es (ex. &lt;code&gt;date_to_timestamp&lt;/code&gt; qui prend une liste)&lt;/li&gt;
&lt;li&gt;Des noms inverses (&lt;code&gt;timestamp_to_date&lt;/code&gt;) qui risquent d'&#234;tre utilis&#233;s &#224; contresens si mal nomm&#233;s&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Distinction entre fonction unitaire et vectoris&#233;e&lt;/h2&gt;
&lt;p&gt;L'outil &lt;code&gt;readable_date_to_timestamp&lt;/code&gt; est 'unitaire' dans le sens o&#249; il n'effectue qu'une seule conversion. &lt;/p&gt;
&lt;p&gt;Prenons le cas d'un outil qui transformerait une liste de dates humainement lisibles en la liste des timestamps correspondants. Comment nommer un tel outil ?
Un nom comme &lt;strong&gt;&lt;code&gt;readable_dates_to_timestamps&lt;/code&gt;&lt;/strong&gt; sera bien interpr&#233;t&#233; par un LLM comme une op&#233;ration &lt;strong&gt;vectoris&#233;e&lt;/strong&gt; (liste &#8594; liste), surtout si :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;le nom est au &lt;strong&gt;pluriel&lt;/strong&gt; (&lt;code&gt;dates&lt;/code&gt;, &lt;code&gt;timestamps&lt;/code&gt;),&lt;/li&gt;
&lt;li&gt;il suit une convention claire et r&#233;guli&#232;re dans l'ensemble des outils,&lt;/li&gt;
&lt;li&gt;la Docstring ou l'intension associ&#233; confirme ce comportement,&lt;/li&gt;
&lt;li&gt;on &#233;vite (faut-il le pr&#233;ciser ?) de cr&#233;er des outils d'intention diff&#233;rente avec un nom similaire.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Pourquoi ce nom est bien compris :&lt;/h3&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;readable_dates&lt;/code&gt;&lt;/strong&gt; &#8594; explicite que l'entr&#233;e est une liste de dates lisibles.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;to_timestamps&lt;/code&gt;&lt;/strong&gt; &#8594; sugg&#232;re une transformation vers une liste de timestamps.&lt;/li&gt;
&lt;li&gt;Le pluriel des deux c&#244;t&#233;s &lt;strong&gt;induit une correspondance &#233;l&#233;ment par &#233;l&#233;ment&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Mais il y a quelques subtilit&#233;s &#224; garder en t&#234;te pour &#233;viter toute confusion. C'est une convention que les LLM comprennent bien, surtout si :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;on l'applique syst&#233;matiquement (ex. : &lt;code&gt;texts_to_embeddings&lt;/code&gt;, &lt;code&gt;urls_to_titles&lt;/code&gt;, etc.),&lt;/li&gt;
&lt;li&gt;il existe (comme dans notre exemple) la version unitaire.&lt;/li&gt;
&lt;li&gt;l'outil expose une Docstring explicite et non contradictoire :&lt;pre&gt;&lt;code class=&#034;language-python&#034;&gt;&#034;&#034;&#034;
Converts a list of human-readable date strings into a list of UNIX timestamps in milliseconds.
&#034;&#034;&#034;&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;on expose aussi une version unitaire :
&lt;code&gt;readable_date_to_timestamp&lt;/code&gt; &#8594; pour une seule date
&lt;code&gt;readable_dates_to_timestamps&lt;/code&gt; &#8594; pour une liste&lt;/li&gt;
&lt;li&gt;on &#233;vite les inversions en exposant les outils inverses :
&lt;code&gt;timestamp_to_readable_date&lt;/code&gt; &#8594; pour une seule date
&lt;code&gt;timestamp_to_readable_date&lt;/code&gt; &#8594; pour une liste&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Encore un d&#233;faut !&lt;/h3&gt;
&lt;p&gt;Cependant, notre exemple pr&#233;sente encore un d&#233;faut : la Docstring fait appara&#238;tre le timestamp comme &#233;tant un 'UNIX timestamps in milliseconds'. Or, fin 1990-d&#233;but 2000 sont apparus les timestamp en microsecondes puis, dans les ann&#233;es 2010, en nanosecondes.&lt;/p&gt;
&lt;p&gt;Le LLM risque de d&#233;couvrir trop tard (en reprenant le raisonnement apr&#232;s avoir constat&#233; l'erreur, si elle est d&#233;tect&#233;e) que l'outil ne fonctionne qu'avec des timestamps en millisecondes !&lt;/p&gt;
&lt;p&gt;Prenant mod&#232;le sur Python, il faut renommer nos fonctions avec timestamp_ms ou timestamp_ns&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb2' class='spip_note' rel='appendix' title='Cependant, Python n'a pas de fonction pour traiter les microsecondes ; on (...)' id='nh2'&gt;2&lt;/a&gt;]&lt;/span&gt; . Voici donc le jeu complet (pour un format millisecondes) :
&lt;code&gt;readable_date_to_timestamp_ms&lt;/code&gt; &lt;code&gt;readable_dates_to_timestamps_ms&lt;/code&gt; &lt;code&gt;timestamp_ms_to_readable_date&lt;/code&gt;
&lt;code&gt;timestamp_ms_to_readable_date&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Sur ce sujet, voir &#233;galement : &lt;a href='https://ia.dnc.global/ReAct-l-Intent-Map.html' class='spip_in'&gt;ReAct : la carte des intentions : Intent Map&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;div id='nb1'&gt;
&lt;p&gt;&lt;span class=&#034;spip_note_ref&#034;&gt;[&lt;a href='#nh1' class='spip_note' title='Notes 1' rev='appendix'&gt;1&lt;/a&gt;] &lt;/span&gt;La distinction entre Docstring et m&#233;tadonn&#233;e 'description' existe dans l'objet FunctionTool mais pas dans le mod&#232;le de donn&#233;es MCP dans lequel il n'existe que la description de l'outil.&lt;/p&gt;
&lt;/div&gt;&lt;div id='nb2'&gt;
&lt;p&gt;&lt;span class=&#034;spip_note_ref&#034;&gt;[&lt;a href='#nh2' class='spip_note' title='Notes 2' rev='appendix'&gt;2&lt;/a&gt;] &lt;/span&gt;Cependant, Python n'a pas de fonction pour traiter les microsecondes ; on adoptera timestamp_us ?&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>ReAct : la carte des intentions : Intent Map</title>
		<link>https://ia.dnc.global/ReAct-l-Intent-Map.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/ReAct-l-Intent-Map.html</guid>
		<dc:date>2025-12-15T12:31:00Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Dans la s&#233;lection d'un outil par le LLM, le nom de l'outil est prioritaire, la description est secondaire. Il va falloir op&#233;rer une pr&#233;-s&#233;lection des outils sur une meilleure base, avant de les passer au LLM. C'est ici qu'appara&#238;t la carte des intentions (Intent Map). &lt;br class='autobr' /&gt; Dans la s&#233;lection d'un outil par le LLM, il appara&#238;t que le nom de l'outil est prioritaire, et que la description est secondaire. De toute &#233;vidence, la description ne sert au LLM qu'en deuxi&#232;me intention, le plus souvent sur une reprise (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;img class='spip_logo spip_logo_right spip_logos' alt=&#034;&#034; style='float:right' src='https://ia.dnc.global/local/cache-vignettes/L150xH137/arton61-70a30.png?1776388474' width='150' height='137' /&gt;
		&lt;div class='rss_chapo'&gt;&lt;p&gt;Dans la s&#233;lection d'un outil par le LLM, le nom de l'outil est prioritaire, la description est secondaire. Il va falloir op&#233;rer une pr&#233;-s&#233;lection des outils sur une meilleure base, avant de les passer au LLM. &lt;br class='autobr' /&gt;
C'est ici qu'appara&#238;t la carte des intentions (Intent Map).&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;hr /&gt;
&lt;p&gt;Dans la s&#233;lection d'un outil par le LLM, il appara&#238;t que le nom de l'outil est prioritaire, et que la description est secondaire&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb1' class='spip_note' rel='appendix' title='En revanche, la description sera utile pour d&#233;finir le sch&#233;ma d'entr&#233;es (...)' id='nh1'&gt;1&lt;/a&gt;]&lt;/span&gt;. De toute &#233;vidence, la description ne sert au LLM qu'en deuxi&#232;me intention, le plus souvent sur une reprise apr&#232;s erreur. La premi&#232;re s&#233;lection de l'outil est fond&#233;e sur une base trop sommaire. &lt;/p&gt;
&lt;h2&gt;La carte des intentions (Intent Map)&lt;/h2&gt;
&lt;p&gt;Puisque le LLM ne fait pas le travail avec suffisamment de discernement, il va falloir op&#233;rer une pr&#233;-s&#233;lection des outils au niveau de l'orchestrateur, avant de les passer au LLM. Il convient &#233;galement de limiter le nombre d'outils pass&#233;s avec le prompt afin de ma&#238;triser le nombre de tokens envoy&#233;s au LLM.&lt;/p&gt;
&lt;p&gt;C'est ici qu'appara&#238;t la carte des intentions (Intent Map). &lt;/p&gt;
&lt;p&gt;L'&lt;strong&gt;Intent Map&lt;/strong&gt; fait le lien entre les &lt;strong&gt;noms techniques des outils&lt;/strong&gt; et leur &lt;strong&gt;intention m&#233;tier explicite&lt;/strong&gt;. C'est un dictionnaire de la forme :&lt;/p&gt;&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_python code&#034;&gt;&lt;div class=&#034;python&#034;&gt;&lt;ol&gt;&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;```&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;intent_map &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;readable_dates_to_timestamps_ms&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Convert a list of human-readable dates into a list of UNIX timestamp expressed in milliseconds.&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;extract_dates&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Extraire une plage de dates &#224; partir d'un texte&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;filter_by_range&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Filtrer une liste d'interventions selon une p&#233;riode&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;summarize_notes&#034;&lt;/span&gt;: &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;R&#233;sumer une s&#233;rie de notes m&#233;dicales&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: black;&#034;&gt;&#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;``` &lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class='download code_download'&gt;&lt;a href='https://ia.dnc.global/local/cache-code/77941835a50bc433ed7669f28fdb6d00.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;Pour les toolbox que nous g&#233;rons, l'Intent Map pourra &#234;tre g&#233;n&#233;r&#233;e automatiquement &#224; partir d'une m&#233;tadonn&#233;e 'intent' des outils, ou d'une propri&#233;t&#233; 'intent_map' de la toolbox.
Sinon, l'Intent Map devra &#234;tre &#233;crite manuellement.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;L'Intent Map permet &#224; l'orchestrateur (classe ToolRouter) de s&#233;lectionner les outils selon l'intention.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;De plus, notre outil de cr&#233;ation de macro-outil (classe MacroToolBuilder) pourra cr&#233;er automatiquement la Docstring macroscopique en se fondant sur les intentions des outils qui la composent. &lt;/p&gt;
&lt;h2&gt;Des cas o&#249; l'Intent Map est essentielle !&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;ToolFactory&lt;/strong&gt; : Dans cet article &lt;a href='https://ia.dnc.global/ReAct-Tool-Factory.html' class='spip_in'&gt;ReAct : ToolFactory&lt;/a&gt; nous montrons comment la classe ToolFactory peut cr&#233;er automatiquement des outils &#224; partir de fonctions des biblioth&#232;ques Python. On peut constater que les descriptions des fonctions sont particuli&#232;rement pauvres et parfois inadapt&#233;es &#224; la s&#233;lection par un LLM.
Dans ce cas, une Intent Map sera essentielle &#224; la bonne s&#233;lection des outils. Il est &#224; craindre qu'il faille la construire manuellement !&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;MCP&lt;/strong&gt; : Dans le cas des outils MCP (Model Context Protocole), les noms d'outils et leur description sont g&#233;r&#233;s du c&#244;t&#233; du serveur MCP, possiblement hors de port&#233;e de l'organisation. Si les descriptions sont mal r&#233;dig&#233;es, ou r&#233;dig&#233;es avec un vocabulaire hors du m&#233;tier, une Intent Map sera essentielle &#224; la bonne s&#233;lection des outils.
Il faudra &#233;videmment la construire manuellement. &lt;/p&gt;
&lt;h2&gt;Comprendre la s&#233;lection des outils&lt;/h2&gt;
&lt;p&gt;Il est important de consid&#233;rer la mani&#232;re dont un agent ReAct s&#233;lectionne et priorise les outils. Ce sera la m&#234;me m&#233;thode pour la pr&#233;-s&#233;lection au niveau de l'orchestrateur. &lt;/p&gt;
&lt;p&gt;C'est &lt;strong&gt;tool.metadata.description&lt;/strong&gt; qui est envoy&#233;e au LLM. &lt;/p&gt;
&lt;p&gt;Le LLM lit la description pour choisir un outil, pas pour comprendre toute la documentation. Lorsqu'un agent ReAct doit choisir un outil, il cherche une correspondance s&#233;mantique forte sur les points suivants :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&lt;em&gt;Quel est le nom de l'outil ?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Quelle est l'action principale ?&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Sur quel type d'objet travaille-t-il ?&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Seule l'intention est r&#233;ellement utile pour la s&#233;lection d'outil.&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Le reste (d&#233;tails, param&#232;tres, avertissements) n'aide pas &#224; la s&#233;lection, au contraire : plus la description est longue, plus on augmente le risque d'erreurs de s&#233;lection. &lt;strong&gt;Une description longue rend l'outil moins distinctif dans l'espace vectoriel du mod&#232;le&lt;/strong&gt; et abouti &#224; une moindre pr&#233;cision dans la s&#233;lection.&lt;/p&gt;
&lt;h2&gt;Bonnes pratiques pour la r&#233;daction des Intentions :**&lt;/h2&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Les valeurs doivent &#234;tre des &lt;strong&gt;descriptions m&#233;tier claires&lt;/strong&gt;, pas des signatures techniques.&lt;/li&gt;
&lt;li&gt;Elles doivent &#234;tre &lt;strong&gt;formul&#233;es &#224; l'infinitif&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Elles doivent &lt;strong&gt;&#233;viter les termes ambigus&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Bien d&#233;finir le vocabulaire (les mots et leur s&#233;mantique) dans un &lt;strong&gt;lexique du m&#233;tier&lt;/strong&gt;, et s'y conformer.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Exemple concret (de ce qu'il ne faut pas faire) :&lt;/h3&gt;
&lt;p&gt;Si on envoie ceci :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;extract_values_by_key(dict_list, key)
Extract all values associated with a given key from a list of dictionaries.
Retrieve the values corresponding to a specific key within a collection of objects.
Iterates through a list of items and returns only the values for which:
- the item is a dictionary
- the key exists&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On augmente les collisions avec d'autres outils. :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;&#8220;collection of objects&#8221; &#8594; outil g&#233;n&#233;rique &lt;/li&gt;
&lt;li&gt;&#8220;iterate through items&#8221; &#8594; ressemble &#224; un filtre &lt;/li&gt;
&lt;li&gt;&#8220;values&#8221; &#8594; ressemble &#224; un extracteur &lt;/li&gt;
&lt;li&gt;&#8220;dictionary&#8221; &#8594; structure sp&#233;cifique &lt;/li&gt;
&lt;li&gt;&#8220;key exists&#8221; &#8594; condition logique &lt;/li&gt;
&lt;li&gt;&#8220;list&#8221; &#8594; structure s&#233;quentielle &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ce qu'il faut &#233;crire :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;extract_values_by_key(dict_list, key)
Extract all values associated with a given key from a list of dictionaries.&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;C'est tout !&lt;/p&gt;
&lt;h2&gt;La g&#233;n&#233;ration syst&#233;matique de la description&lt;/h2&gt;
&lt;p&gt;Il faut consid&#233;rer deux champs : tool.description et tool.metadata.description.&lt;/p&gt;
&lt;p&gt;Si on ne d&#233;finit pas le champ 'description' de l'outil, tool.metadata.description sera &#233;labor&#233; par LlamaIndex &#224; partir de la Docstring, en lui appliquant des heuristiques qui ajoutent parfois la signature, reformate, supprime certains &#233;l&#233;ments, interpr&#232;te le Markdown, modifie l'ordre des lignes etc.. Bref : on ne peut se fonder dessus pour fournir l'intention.&lt;/p&gt;
&lt;p&gt;Pour garantir que la premi&#232;re ligne soit un r&#233;sum&#233; clair, LlamaIndex ajoute parfois la signature en appliquant cette heuristique :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Si la docstring commence par une phrase simple &#8594; pas de signature&lt;/li&gt;
&lt;li&gt;Si la docstring commence par du Markdown, une ligne vide, un titre, du gras, etc. &#8594; signature ajout&#233;e.
Ce comportement est : non document&#233;, non stable, diff&#233;rent selon les versions, influenc&#233; par le format de la docstring. De plus, la signature est sans valeur s&#233;mantique, elle ajoute du bruit et d&#233;gradera la s&#233;lection.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;metadata.description doit n'avoir que l'intention sur une ligne&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Pour reprendre le contr&#244;le, &lt;strong&gt;il faut toujours d&#233;finir le champ description, et ce, sous la forme d'une Intention&lt;/strong&gt;.
cela &#233;crasera metadata.description. Le LLM verra exactement ce que l'on veut qu'il voie.&lt;/p&gt;
&lt;p&gt;La meilleure pratique :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Garder la docstring pour les humains et pour la deuxi&#232;me intention. &lt;/li&gt;
&lt;li&gt;Pour le LLM, fournir explicitement `metadata.description='intention' en une phrase. &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Le r&#244;le de la docstring pour la deuxi&#232;me intention&lt;/h2&gt;
&lt;p&gt;Il s'agit d'un un autre m&#233;canisme de LlamaIndex qui entre en jeu &lt;strong&gt;uniquement apr&#232;s une erreur&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Quand un outil &#233;choue (exception Python, mauvais arguments, etc.), LlamaIndex renvoie au LLM un &lt;em&gt;Tool Error Message&lt;/em&gt;.
Ce message contient :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;l'erreur Python, &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;la docstring compl&#232;te de l'outil&lt;/strong&gt; (ou une version nettoy&#233;e), &lt;/li&gt;
&lt;li&gt;parfois la signature, &lt;/li&gt;
&lt;li&gt;parfois des instructions suppl&#233;mentaires.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;En effet, pour poursuivre le raisonnement en le modifiant (ne pas r&#233;p&#233;ter l'erreur), le LLM doit &#234;tre capable de :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;comprendre pourquoi l'appel a &#233;chou&#233;, &lt;/li&gt;
&lt;li&gt;reformuler un appel correct, &lt;/li&gt;
&lt;li&gt;r&#233;essayer avec les bons arguments, &lt;/li&gt;
&lt;li&gt;ajuster son comportement.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Et pour &#231;a, il a besoin d'informations plus d&#233;taill&#233;es que celles utilis&#233;es pour la s&#233;lection initiale.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Premi&#232;re intention : s&#233;lection d'outil &#8594; intention courte&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Deuxi&#232;me intention : correction d'erreur &#8594; docstring d&#233;taill&#233;e&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;En r&#233;sum&#233; :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;Le LLM ne voit que &lt;code&gt;metadata.description&lt;/code&gt; pour choisir un outil. &lt;/li&gt;
&lt;li&gt;Le LLM voit la docstring compl&#232;te uniquement apr&#232;s une erreur. &lt;/li&gt;
&lt;li&gt;il faut &#233;crire des docstrings d&#233;taill&#233;es. &lt;/li&gt;
&lt;li&gt;on doit mettre uniquement l'intention dans &lt;code&gt;metadata.description&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Sur ce sujet, voir &#233;galement :&lt;/strong&gt;
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; &lt;a href='https://ia.dnc.global/ReAct-le-nommage-des-outils.html' class='spip_in'&gt;ReAct : le nommage des outils.&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div class='rss_notes'&gt;&lt;div id='nb1'&gt;
&lt;p&gt;&lt;span class=&#034;spip_note_ref&#034;&gt;[&lt;a href='#nh1' class='spip_note' title='Notes 1' rev='appendix'&gt;1&lt;/a&gt;] &lt;/span&gt;En revanche, la description sera utile pour d&#233;finir le sch&#233;ma d'entr&#233;es attendues par l'outil.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>ReAct : ToolFactory</title>
		<link>https://ia.dnc.global/ReAct-Tool-Factory.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/ReAct-Tool-Factory.html</guid>
		<dc:date>2025-12-02T13:30:48Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;ToolFactory est une biblioth&#232;que d'utilitaires permettant de cr&#233;er des Outils de Fonction (FunctionTool) &#224; partir d'une biblioth&#232;que de fonctions Python. La fonction auto_toolkit &lt;br class='autobr' /&gt;
Cette fonction g&#233;n&#232;re dynamiquement une liste de `FunctionTool` LlamaIndex &#224; partir des fonctions publiques d'un module Python. &lt;br class='autobr' /&gt;
Elle inspecte les fonctions du module fourni, applique des filtres d'inclusion/exclusion, et transforme chaque fonction retenue en outil agentifiable (`FunctionTool`) via l'examen de sa signature (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Architecture-et-traitements-.html" rel="directory"&gt;Architecture et traitements&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_chapo'&gt;&lt;p&gt;ToolFactory est une biblioth&#232;que d'utilitaires permettant de cr&#233;er des Outils de Fonction (FunctionTool) &#224; partir d'une biblioth&#232;que de fonctions Python.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;h3 class=&#034;spip&#034;&gt;La fonction auto_toolkit&lt;/h3&gt;
&lt;p&gt;Cette fonction g&#233;n&#232;re dynamiquement une liste de `FunctionTool` LlamaIndex &#224; partir des fonctions publiques d'un module Python.&lt;/p&gt;
&lt;p&gt;Elle inspecte les fonctions du module fourni, applique des filtres d'inclusion/exclusion, et transforme chaque fonction retenue en outil agentifiable (`FunctionTool`) via l'examen de sa signature et de sa documentation.&lt;/p&gt;
&lt;p&gt; Param&#232;tres :&lt;br class='autobr' /&gt; module (ModuleType) :&lt;br class='autobr' /&gt; Le module Python &#224; analyser (ex. : `statistics`, `math`, ou un module m&#233;tier).&lt;br class='autobr' /&gt; include (List[str], optionnel) :&lt;br class='autobr' /&gt; Liste blanche : noms de fonctions &#224; inclure explicitement. Si None, inclut toutes les fonctions publiques.&lt;br class='autobr' /&gt; exclude (List[str], optionnel) :&lt;br class='autobr' /&gt; Liste noire : noms de fonctions &#224; ignorer. Prioritaire sur `include`.&lt;br class='autobr' /&gt; verbose (bool, optionnel) :&lt;br class='autobr' /&gt; Si True, affiche dans la console les outils ajout&#233;s et les erreurs &#233;ventuelles.&lt;/p&gt;
&lt;p&gt; Retour :&lt;br class='autobr' /&gt; List[FunctionTool] :&lt;br class='autobr' /&gt; Liste des objets `FunctionTool` g&#233;n&#233;r&#233;s &#224; partir des fonctions s&#233;lectionn&#233;es.&lt;/p&gt;
&lt;p&gt; Usage :&lt;br class='autobr' /&gt; from modules.tools.tool_factory import auto_toolkit&lt;br class='autobr' /&gt; tools = auto_toolkit(&lt;br class='autobr' /&gt; statistics,&lt;br class='autobr' /&gt; include=[&#034;mean&#034;, &#034;stdev&#034;, &#034;median&#034;],&lt;br class='autobr' /&gt; tags=[&#034;statistique&#034;],&lt;br class='autobr' /&gt; verbose=True&lt;/p&gt;
&lt;p&gt;Voici l'essentiel du code :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_python code&#034;&gt;&lt;div class=&#034;python&#034;&gt;&lt;ol&gt;&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;## Usinage ##&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;def&lt;/span&gt; auto_toolkit&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; module: ModuleType&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; *&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; include: List&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; exclude: List&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;str&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;None&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; verbose: &lt;span style=&#034;color: #008000;&#034;&gt;bool&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;False&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; **kwargs&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; -&lt;span style=&#034;color: #66cc66;&#034;&gt;&gt;&lt;/span&gt; List&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;FunctionTool&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; G&#233;n&#232;re une liste de FunctionTool LlamaIndex &#224; partir des fonctions publiques d'un module.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Applique automatiquement les d&#233;corateurs d'entr&#233;e/sortie pour compatibilit&#233; agentique.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; &lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Test : test_auto_toolkit.py&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Param&#232;tres&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; ----------&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; module : ModuleType&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Module Python &#224; inspecter (ex. statistics, math, ou module maison)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; include : list of str, optional&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Liste blanche : noms de fonctions &#224; inclure (si sp&#233;cifi&#233;)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; exclude : list of str, optional&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Liste noire : noms de fonctions &#224; ignorer&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; verbose : bool&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Si True, affiche les outils ajout&#233;s&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; **kwargs : dict&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; M&#233;tadonn&#233;es suppl&#233;mentaires &#224; passer &#224; `as_llama_tool` (ex. tags, metadata, etc.)&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Returns&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; -------&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; List[FunctionTool]&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; Liste d'outils LlamaIndex pr&#234;ts &#224; &#234;tre enregistr&#233;s dans un agent&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt; &#034;&#034;&#034;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; tools &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; total &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #ff4500;&#034;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; success &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #ff4500;&#034;&gt;0&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;for&lt;/span&gt; name&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; fn &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;in&lt;/span&gt; &lt;span style=&#034;color: #dc143c;&#034;&gt;inspect&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;getmembers&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;module&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #dc143c;&#034;&gt;inspect&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;isfunction&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; name.&lt;span style=&#034;color: black;&#034;&gt;startswith&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;_&#034;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;continue&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; include &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;and&lt;/span&gt; name &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;not&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;in&lt;/span&gt; include:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;continue&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; exclude &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;and&lt;/span&gt; name &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;in&lt;/span&gt; exclude:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;continue&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; total +&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;try&lt;/span&gt;:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Application des d&#233;corateurs d'entr&#233;e et de sortie&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; decorated_fn &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; react_tool_output&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;react_tool_input&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;fn&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; decorated_fn &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; react_tool_output&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;name&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;decorated_fn &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Cr&#233;ation du FunctionTool avec m&#233;tadonn&#233;es&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; tool &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; as_llama_tool&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; name&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;name&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; **kwargs&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;decorated_fn&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; tools.&lt;span style=&#034;color: black;&#034;&gt;append&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;tool&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; success +&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;if&lt;/span&gt; verbose:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; trace&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;f&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Outil ajout&#233; : {get_tool_name(tool)}&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; logger&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;except&lt;/span&gt; &lt;span style=&#034;color: #008000;&#034;&gt;Exception&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;as&lt;/span&gt; e:&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; trace&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;f&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Erreur lors de l'ajout de l'outil '{name}': {e}&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; logger&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; trace&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;f&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;{success} outils ajout&#233;s avec succ&#232;s sur {total} fonctions inspect&#233;es.&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; logger&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;return&lt;/span&gt; tools&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class='download code_download'&gt;&lt;a href='https://ia.dnc.global/local/cache-code/d1f04eaec18f44b6538d4fec8b8cab29.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Voici le code pour g&#233;n&#233;rer automatiquement des outils de fonction &#224; partir du module 'statistiques. Noter que l'on peut choisir les fonctions &#224; importer.&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_python code&#034;&gt;&lt;div class=&#034;python&#034;&gt;&lt;ol&gt;&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;from&lt;/span&gt; modules.&lt;span style=&#034;color: black;&#034;&gt;tools&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;tool_factory&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;import&lt;/span&gt; auto_toolkit&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; tools +&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; auto_toolkit&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; statistics&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; include&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;mean&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;stdev&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;median&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;variance&#034;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; verbose&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #008000;&#034;&gt;True&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; &lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;p class='download code_download'&gt;&lt;a href='https://ia.dnc.global/local/cache-code/70785e05cc149f1bfa72e008e197d19b.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;h3 class=&#034;spip&#034;&gt;Modules Python et fonctions utilisables&lt;/h3&gt;&lt;p&gt;Tous les modules Python ne sont pas pertinents pour produire des &lt;em&gt;FunctionTool&lt;/em&gt; exploitables dans un agent. Voici une &lt;strong&gt;s&#233;lection affin&#233;e&lt;/strong&gt;, class&#233;e selon leur **pertinence, c'est-&#224;-dire leur capacit&#233; &#224; fournir des fonctions :&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;
&lt;li&gt;publiques&lt;/li&gt;
&lt;li&gt;pures ou quasi-pures&lt;/li&gt;
&lt;li&gt;typ&#233;es&lt;/li&gt;
&lt;li&gt;document&#233;es&lt;/li&gt;
&lt;li&gt;auto-validables via &lt;em&gt;fn_schema&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Module&lt;/th&gt;
&lt;th&gt;Pertinence&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;statistics&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions bien typ&#233;es, docstring claires, signatures simples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;math&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions scalaires pures, typ&#233;es, robustes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;cmath&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Idem, mais pour les complexes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;decimal&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions pr&#233;cises pour calculs financiers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;fractions&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Manipulation exacte de rationnels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;datetime&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions de manipulation de dates (attention &#224; la mutabilit&#233;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;calendar&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions pures sur les jours, semaines, ann&#233;es&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;itertools&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;G&#233;n&#233;rateurs utiles, mais n&#233;cessite des wrappers pour &#234;tre agentifiables&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;functools&lt;/em&gt; (partiellement)&lt;/td&gt;
&lt;td&gt;Quelques fonctions d&#233;corables (ex. &lt;em&gt;reduce&lt;/em&gt;) si bien encapsul&#233;es&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Voici un tableau synth&#233;tique des fonctions principales pour chaque module Python standard qui peuvent &#234;tre transform&#233;s en FunctionTool par &lt;em&gt;tool_factory&lt;/em&gt;, avec leur description.*&lt;em&gt; Ces fonctions sont typ&#233;es, document&#233;es, et g&#233;n&#233;ralement compatibles avec &lt;/em&gt;FunctionTool*.&lt;/p&gt;
&lt;h3&gt;&lt;em&gt;statistics&lt;/em&gt; &#8212; Statistiques descriptives&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;mean(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Moyenne arithm&#233;tique&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;fmean(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Moyenne arithm&#233;tique rapide (float uniquement)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;geometric_mean(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Moyenne g&#233;om&#233;trique&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;harmonic_mean(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Moyenne harmonique&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;median(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;M&#233;diane&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;median_low(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Plus grande valeur &#8804; m&#233;diane&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;median_high(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Plus petite valeur &#8805; m&#233;diane&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;median_grouped(data, interval=1)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;M&#233;diane pour donn&#233;es group&#233;es&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;mode(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Valeur la plus fr&#233;quente&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;multimode(data)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Liste des valeurs les plus fr&#233;quentes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;pstdev(data, mu=None)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&#201;cart-type de la population&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;stdev(data, xbar=None)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&#201;cart-type de l'&#233;chantillon&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;pvariance(data, mu=None)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Variance de la population&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;variance(data, xbar=None)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Variance de l'&#233;chantillon&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;quantiles(data, &lt;/em&gt;, n=4, method='exclusive')*&lt;/td&gt;
&lt;td&gt;D&#233;coupe en quantiles&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;covariance(x, y)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Covariance entre deux s&#233;ries&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;correlation(x, y)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Corr&#233;lation de Pearson&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;linear_regression(x, y)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;R&#233;gression lin&#233;aire (renvoie pente et intercept)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;math&lt;/em&gt; &#8212; Math&#233;matiques de base&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;sqrt(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Racine carr&#233;e&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;exp(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Exponentielle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;log(x, base=math.e)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Logarithme (base e par d&#233;faut)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;log10(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Logarithme d&#233;cimal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;log2(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Logarithme base 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;pow(x, y)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Puissance ( x^y )&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;fabs(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Valeur absolue&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;factorial(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Factorielle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;gcd(a, b)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Plus grand commun diviseur&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;lcm(a, b)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Plus petit commun multiple&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;ceil(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Arrondi sup&#233;rieur&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;floor(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Arrondi inf&#233;rieur&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;trunc(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Troncature (partie enti&#232;re)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;sin(x), cos(x), tan(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Fonctions trigonom&#233;triques&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;degrees(x), radians(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Conversion angle &#8596; radians&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;isclose(a, b)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Comparaison flottante&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;isnan(x), isinf(x), isfinite(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Tests num&#233;riques&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;cmath&lt;/em&gt; &#8212; Math&#233;matiques complexes&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;sqrt(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Racine carr&#233;e complexe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;exp(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Exponentielle complexe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;log(x, base=math.e)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Log complexe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;phase(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Argument (angle) d'un nombre complexe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;polar(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Coordonn&#233;es polaires&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;rect(r, phi)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Conversion polaire &#8594; cart&#233;sien&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;sin(x), cos(x), tan(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Trigonom&#233;trie complexe&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;decimal&lt;/em&gt; &#8212; Calculs d&#233;cimaux pr&#233;cis&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Decimal(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Cr&#233;e un nombre d&#233;cimal pr&#233;cis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;getcontext()&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Acc&#232;s au contexte (pr&#233;cision, arrondi)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;setcontext(ctx)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;D&#233;finit un contexte personnalis&#233;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;localcontext()&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Contexte temporaire&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M&#233;thodes : &lt;em&gt;sqrt()&lt;/em&gt;, &lt;em&gt;ln()&lt;/em&gt;, &lt;em&gt;exp()&lt;/em&gt;, &lt;em&gt;quantize()&lt;/em&gt;, etc.&lt;/td&gt;
&lt;td&gt;Op&#233;rations pr&#233;cises sur &lt;em&gt;Decimal&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;fractions&lt;/em&gt; &#8212; Calculs exacts avec fractions&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;Fraction(x)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Cr&#233;e une fraction exacte&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;limit_denominator(max_denominator)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Approximation avec d&#233;nominateur born&#233;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Op&#233;rations : &lt;em&gt;+&lt;/em&gt;, &lt;em&gt;-&lt;/em&gt;, *&lt;strong&gt;, &lt;em&gt;/&lt;/em&gt;, **&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Calculs exacts entre fractions ou entiers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;datetime&lt;/em&gt; &#8212; Dates et heures&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;datetime(year, month, day, ...)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Objet date-heure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;date(year, month, day)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Objet date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;time(hour, minute, ...)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Objet heure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;timedelta(...)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Dur&#233;e&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;now(), today(), utcnow()&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Horodatages actuels&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;M&#233;thodes : &lt;em&gt;isoformat()&lt;/em&gt;, &lt;em&gt;weekday()&lt;/em&gt;, &lt;em&gt;strftime()&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Formatage et manipulation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3&gt;&lt;em&gt;calendar&lt;/em&gt; &#8212; Calendriers&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fonction&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;isleap(year)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Ann&#233;e bissextile ?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;monthrange(year, month)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Premier jour et nombre de jours&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;monthcalendar(year, month)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Matrice des semaines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;weekday(year, month, day)&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Jour de la semaine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;em&gt;month_name&lt;/em&gt;, &lt;em&gt;day_name&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;Noms localis&#233;s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Sources :&lt;/strong&gt; &lt;a href=&#034;https://docs.python.org/3/library/index.html&#034;&gt;Python 3.14 Standard Library Documentation&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>



</channel>

</rss>
