<?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=6&amp;page=backend" rel="self" type="application/rss+xml" />




<item xml:lang="fr">
		<title>Ingestion : le RAG Manager</title>
		<link>https://ia.dnc.global/Ingestion-le-RAG-Manager.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/Ingestion-le-RAG-Manager.html</guid>
		<dc:date>2025-06-29T17:07:22Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Les applications publiques de LLMs (ChatGPT, Le Chat etc.), ainsi que toute application s'appuyant sur les LLMs sous-jacents (OpenAI GPT, Mistral AI etc.), ont des bases de connaissances g&#233;n&#233;ralistes, tr&#232;s d&#233;velopp&#233;es mais aussi fig&#233;es, incluant des informations p&#233;rim&#233;es ou contradictoires et peu fournies sur un domaine m&#233;tier donn&#233;. &lt;br class='autobr' /&gt;
Le principe du RAG est de traiter les documents d'une entit&#233;. Pour ne pas tomber dans les d&#233;fauts des LLMs, il faut pouvoir saisir facilement toute la documentation et (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Outils-d-IA-textuels-.html" rel="directory"&gt;Outils d'IA textuels&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/L150xH89/arton34-042cf.png?1776300676' width='150' height='89' /&gt;
		&lt;div class='rss_chapo'&gt;&lt;p&gt;Les applications publiques de LLMs (ChatGPT, Le Chat etc.), ainsi que toute application s'appuyant sur les LLMs sous-jacents (OpenAI GPT, Mistral AI etc.), ont des bases de connaissances g&#233;n&#233;ralistes, tr&#232;s d&#233;velopp&#233;es mais aussi fig&#233;es, incluant des informations p&#233;rim&#233;es ou contradictoires et peu fournies sur un domaine m&#233;tier donn&#233;.&lt;/p&gt;
&lt;p&gt;Le principe du RAG est de traiter les documents d'une entit&#233;. Pour ne pas tomber dans les d&#233;fauts des LLMs, il faut pouvoir saisir facilement toute la documentation et surtout &lt;i&gt;tenir &#224; jour cette documentation de fa&#231;on continue&lt;/i&gt;. C'est le r&#244;le du RAG Manager.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;p&gt;Voyez l'application en action ici : &lt;a href='https://ia.dnc.global/?page=data_gerer'&gt;RAG Manager&lt;/a&gt; (acc&#232;s r&#233;serv&#233;).&lt;br class='autobr' /&gt; &lt;/p&gt;
&lt;p&gt;Le Rag Manager couvre toute les &#233;tapes de la gestion des documents de l'ingestion &#224; l'indexation, y compris la suppression des documents obsol&#232;tes et la cr&#233;ation d'un index comprim&#233; :&lt;/p&gt;
&lt;dl class='spip_document_17 spip_documents'&gt; &lt;dt&gt; &lt;a href='https://ia.dnc.global/IMG/png/rag_manager_dans_le_flow.png' class=&#034;mediabox&#034; title=&#034;PNG - 152.8 ko&#034; &gt; &lt;img src='https://ia.dnc.global/local/cache-vignettes/L500xH85/rag_manager_dans_le_flow-d06dd.png?1776338122' width='500' height='85' alt=&#034;PNG - 152.8&#160;ko&#034; /&gt; &lt;/a&gt; &lt;/dt&gt; &lt;/dl&gt;
&lt;p&gt;Le plus important peut-&#234;tre : &lt;strong&gt;pouvoir nettoyer les donn&#233;es&lt;/strong&gt;, d'o&#249; le chiffon ;).&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Le dossier 'data' du th&#232;me&lt;/strong&gt;&lt;br class='autobr' /&gt;
Tous les documents ing&#233;r&#233;s (sur lesquels a &#233;t&#233; construit l'index) se trouvent sur l'h&#244;te dans le dossier .../data/'theme'/.&lt;br class='autobr' /&gt;
Le dossier .../data/'theme'/storage/ contient les diff&#233;rents fichiers composant l'index.&lt;br class='autobr' /&gt;
Le fichier 'theme'.txt en est une version comprim&#233;e et s&#233;rialis&#233;e de fa&#231;on &#224; &#234;tre charg&#233;e rapidement par les applications.&lt;/p&gt;
&lt;dl class='spip_document_16 spip_documents'&gt; &lt;dt&gt; &lt;a href='https://ia.dnc.global/IMG/png/data_gerer.png' class=&#034;mediabox&#034; title=&#034;PNG - 125.5 ko&#034; &gt; &lt;img src='https://ia.dnc.global/local/cache-vignettes/L500xH248/data_gerer-4955f.png?1776338122' width='500' height='248' alt=&#034;PNG - 125.5&#160;ko&#034; /&gt; &lt;/a&gt; &lt;/dt&gt; &lt;/dl&gt;
&lt;p&gt;&lt;strong&gt;Ajouter document(s)&lt;/strong&gt;&lt;br class='autobr' /&gt;
Cette action permet de s&#233;lectionner un document dans un dossier local, de l'importer dans le r&#233;pertoire des donn&#233;es et l'indexer. Il est &#233;galement possible d'effectuer une s&#233;lection multiple.&lt;br class='autobr' /&gt;
Cette action n'assure pas l'enregistrement de l'index.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Ajouter Web&lt;/strong&gt;&lt;br class='autobr' /&gt;
Cette action parcourt le site Web d&#233;sign&#233;, importe le contenu dans le dossier .../data/'theme'/ et assure l'indexation. &lt;br class='autobr' /&gt;
L'index est enregistr&#233; &#224; la fin de l'action. &lt;br class='autobr' /&gt;
Dans l'&#233;tat actuel du d&#233;veloppement, le parcours est effectu&#233; avec le param&#232;tre &#8212;forwards, mais sans les param&#232;tres &#8212;all, &#8212;nostore, &#8212;dynamic, &#8212;plan etc. (voir &lt;a href='https://ia.dnc.global/Ingestion-RAG-le-script-ingestcmd-py.html' class='spip_in'&gt;Ingestion RAG : le script ingestcmd.py&lt;/a&gt; ). &lt;br class='autobr' /&gt;
En particulier, l'absence de &#8212;all permet de lancer l'action r&#233;guli&#232;rement pour incr&#233;menter l'index avec les pages nouvelles ou modifi&#233;es.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Indexer&lt;/strong&gt;&lt;br class='autobr' /&gt;
Cette action balaye le dossier data &#224; la recherche de documents non-index&#233;s et les indexe.&lt;br class='autobr' /&gt;
L'ajout d'un document, du contenu d'un r&#233;pertoire ou de tout ou partie d'un site Web assure l'importation des documents dans le dossier .../data/'theme'/ et leur indexation. Mais il est &#233;galement possible d'ajouter des documents par d'autres moyens tels qu'un t&#233;l&#233;versement. Ces documents ne sont pas index&#233;s et devront l'&#234;tre par l'action Indexer. &lt;br class='autobr' /&gt;
L'index est enregistr&#233; &#224; la fin de l'action.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;R&#233;indexer&lt;/strong&gt;&lt;br class='autobr' /&gt;
L'action R&#233;indexer efface l'index en m&#233;moire et sur le disque avant de r&#233;-indexer tous les documents du dossier data/'theme'/. &lt;br class='autobr' /&gt;
L'index est enregistr&#233; &#224; la fin de l'action. &lt;br class='autobr' /&gt;
Cette action n'est pertinente que dans certains cas d'erreur. &lt;br class='autobr' /&gt;
Noter que l'index s&#233;rialis&#233; pr&#233;c&#233;dent est pr&#233;serv&#233; pendant l'ex&#233;cution afin d'&#233;viter les ruptures de service.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Enregistrer&lt;/strong&gt;&lt;br class='autobr' /&gt;
L'index est maintenu dans la m&#233;moire de l'h&#244;te. Pour le rendre persistant et accessible aux applications, il faut l'enregistrer apr&#232;s avoir ajout&#233; des documents.&lt;br class='autobr' /&gt;
Ceci est fait syst&#233;matiquement &#224; la suite des actions Ajouter Web, Indexer et R&#233;indexer.&lt;br class='autobr' /&gt;
L'enregistrement est une action relativement longue et co&#251;teuse en ressources. C'est pourquoi, quand on ajoute un ou plusieurs documents, on laisse &#224; l'utilisateur le soin de provoquer l'enregistrement.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Supprimer&lt;/strong&gt;&lt;br class='autobr' /&gt;
La suppression des documents p&#233;rim&#233;s est essentielle pour assurer des r&#233;sultats fond&#233;s sur des donn&#233;es &#224; jour. C'est une d&#233;cision &#224; prendre fichier par fichier.&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div &lt;div class='rss_ps'&gt;&lt;h3 class=&#034;spip&#034;&gt;A propos du Dashboard&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Pourquoi un Dashboard ?&lt;/strong&gt;&lt;br class='autobr' /&gt;
Les actions lanc&#233;es depuis le RAG Manager sont pour la plupart ex&#233;cut&#233;es en t&#226;che de fond. Une fois la t&#226;che lanc&#233;e, on n'attend pas la fin de l'ex&#233;cution - qui peut durer plusieurs minutes - pour revenir &#224; la page principale. Le Dashboard permet de voir la progression des traitements et de v&#233;rifier leur bonne fin.&lt;/p&gt;
&lt;p&gt;Le Dashboard affiche en temps r&#233;el des messages techniques, des retours syst&#232;me, ou des &#233;tapes de traitements.&lt;br class='autobr' /&gt;
Pour cela, le RAG Manager se connecte &#224; la route /api/stream du Web Service IngestWSG qui g&#233;n&#232;re un flux SSE (Server-Sent Events) de tous les messages g&#233;n&#233;r&#233;s au cours de l'ex&#233;cution des actions.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Chaque log g&#233;n&#233;r&#233; par le Web Service est inject&#233; dynamiquement sous forme de balises HTML &lt;code class='spip_code' dir='ltr'&gt;(&lt;div class=&#034;log ...&#034;&gt;)&lt;/code&gt;
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Les derniers messages s'affichent en haut gr&#226;ce &#224; une inversion du flux c&#244;t&#233; JavaScript
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; L'utilisateur b&#233;n&#233;ficie d'une vue imm&#233;diate sur ce qui se passe sans recharger la page&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Pourquoi une fen&#234;tre ind&#233;pendante est requise pour garantir la persistance du flux SSE ?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Lorsqu'un flux SSE est utilis&#233; pour diffuser des messages en temps r&#233;el depuis un serveur vers le navigateur, celui-ci repose sur une connexion HTTP persistante attach&#233;e &#224; un contexte `window` sp&#233;cifique. Cette connexion pr&#233;sente plusieurs limites fonctionnelles dans un environnement Web :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; le DOM est recharg&#233; &#224; chaque navigation (ex. clic sur un lien, changement d'onglet, ex&#233;cution d'une action AJAX non isol&#233;e), ce qui est exactement ce que l'on fait en lan&#231;ant des actions.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; dans ce cas, le contexte JavaScript est d&#233;truit et la connexion SSE est interrompue.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; m&#234;me lorsque le dashboard est inclus dans un INCLURE, une iFrame, appel&#233; par fetch etc., le comportement reste identique : le flux est interrompu.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution retenue : une fen&#234;tre autonome&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Ouvrir une fen&#234;tre ind&#233;pendante via `window.open()` permet d'isoler le dashboard dans un contexte JavaScript propre et persistant. Cette approche pr&#233;sente plusieurs avantages :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Le flux SSE reste actif tant que la fen&#234;tre est ouverte, ind&#233;pendamment des interactions dans la page principale.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Le dashboard n'est affect&#233; ni par la navigation SPIP, ni par les rechargements li&#233;s au squelette.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;La recopie dans la page principale&lt;/strong&gt;&lt;br class='autobr' /&gt;
Une communication bidirectionnelle est &#233;tablie du dashboard vers la page principale via `postMessage` pour cloner la liste des messages, et dans l'autre sens apr&#232;s un changement de page afin de restituer les messages ant&#233;rieurs.&lt;br class='autobr' /&gt;
D&#232;s qu'un message est g&#233;n&#233;r&#233;, il est :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; transmis &#224; la fen&#234;tre Dashboard ouverte avec window.open
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; affich&#233; dans une zone HTML (#log-miroir)
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; tri&#233; dans l'ordre inverse (dernier en haut), avec scroll automatique en haut&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Alternatives &#233;tudi&#233;es (non retenues)&lt;/strong&gt;&lt;/p&gt;
&lt;table class=&#034;spip&#034;&gt;
&lt;tbody&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;M&#233;thode&lt;/td&gt;
&lt;td&gt;Persistance garantie&lt;/td&gt;
&lt;td&gt;Recommand&#233;e ?&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;Int&#233;gration inline SPIP&lt;/td&gt;
&lt;td&gt;Non&lt;/td&gt;
&lt;td&gt;&#10060;&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;Inclusion via iframe&lt;/td&gt;
&lt;td&gt;Peu fiable&lt;/td&gt;
&lt;td&gt;&#10060;&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;Inclusion avec Javascript + Fetch&lt;/td&gt;
&lt;td&gt;Peu fiable&lt;/td&gt;
&lt;td&gt;&#10060;&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;`window.open()` (fen&#234;tre)&lt;/td&gt;
&lt;td&gt;Oui&lt;/td&gt;
&lt;td&gt;&#9989;&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;SharedWorker (avanc&#233;)&lt;/td&gt;
&lt;td&gt;Complexe, peu support&#233;&lt;/td&gt;
&lt;td&gt;&#128310; Exp&#233;rimental&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Apr&#232;s essais, ce choix d'architecture semble le seul capable de garantir la stabilit&#233; d'un outil de supervision en temps r&#233;el. Il permet de s'affranchir des limites impos&#233;es par le cycle de vie du DOM dans SPIP et assure une communication continue entre client et serveur.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;A propos du verrouillage&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Objectif du verrouillage&lt;/strong&gt;&lt;br class='autobr' /&gt;
Emp&#234;cher certaines actions ou modifications li&#233;es &#224; un th&#232;me lorsqu'une op&#233;ration sensible est en cours (par exemple : ingestion, indexation, etc.). Le verrou agit comme un signal syst&#232;me pour bloquer l'acc&#232;s ou d&#233;sactiver certains &#233;l&#233;ments de l'interface.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fonctionnement&lt;/strong&gt;&lt;br class='autobr' /&gt;
1. Cr&#233;ation du verrou c&#244;t&#233; serveur
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Un fichier .lock est plac&#233; dans /data/(theme)/storage/
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Pr&#233;sence de ce fichier = th&#232;me verrouill&#233;&lt;br class='autobr' /&gt;
2. D&#233;tection c&#244;t&#233; PHP
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Via filtre_verrou_actif_dist($theme) :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_php code&#034;&gt;&lt;div class=&#034;php&#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: #000088;&#034;&gt;$lockfile&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$_SERVER&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&#034;color: #0000ff;&#034;&gt;'DOCUMENT_ROOT'&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;.&lt;/span&gt; &lt;span style=&#034;color: #0000ff;&#034;&gt;&#034;/data/&lt;span style=&#034;color: #006699; font-weight: bold;&#034;&gt;$theme&lt;/span&gt;/storage/.lock&#034;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #b1b100;&#034;&gt;return&lt;/span&gt; &lt;a href=&#034;http://www.php.net/file_exists&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;file_exists&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$lockfile&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&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/eacf8a0ff286dd369460c0bb32fc94c3.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;3. Interrogation c&#244;t&#233; client
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Un script JS appelle r&#233;guli&#232;rement (polling) la page fonds/etat_verrou avec le nom du th&#232;me&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_javascript code&#034;&gt;&lt;div class=&#034;javascript&#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: #000066; font-weight: bold;&#034;&gt;get&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #3366CC;&#034;&gt;&#034;?page=etat_verrou&amp;theme=...&#034;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #000066; font-weight: bold;&#034;&gt;function&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;data&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&#034;color: #009900;&#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: #000066; font-weight: bold;&#034;&gt;const&lt;/span&gt; verrou &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;data.&lt;span style=&#034;color: #660066;&#034;&gt;trim&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;==&lt;/span&gt; &lt;span style=&#034;color: #3366CC;&#034;&gt;&#034;true&#034;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #3366CC;&#034;&gt;&#034;.statusdependant&#034;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&#034;color: #660066;&#034;&gt;prop&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #3366CC;&#034;&gt;&#034;disabled&#034;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; verrou&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #009900;&#034;&gt;&#125;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&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/2f320cc42620a2d9733b6d1ed7ae58b8.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Si verrou actif &#8594; d&#233;sactivation des boutons cibl&#233;s par .statusdependant&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Erreurs et solutions&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;erreur ingestwsg : cURL error : Failed to connect to localhost port 5003 : Connection refused&lt;/strong&gt;&lt;br class='autobr' /&gt;
Il est tr&#232;s probable que le Web Service IngestWsg ne soit pas lanc&#233;. Lancez le WS en ligne de commande avec le script ingestwsg.sh.&lt;br class='autobr' /&gt;
V&#233;rifiez qu'une t&#226;che CRON lance se script, par exemple chaque nuit.&lt;br class='autobr' /&gt;
Voici un exemple d'une s&#233;quence de d&#233;marrage. Les commandes :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_bash code&#034;&gt;&lt;div class=&#034;bash&#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: #7a0874; font-weight: bold;&#034;&gt;cd&lt;/span&gt; &lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iazesite&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.zesite.com&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp&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: #7a0874; font-weight: bold;&#034;&gt;source&lt;/span&gt; PythonAppVenv&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;bin&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;activate&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: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iazesite&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.zesite.coml&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;ingestwsg.sh&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/7e6a3db50d9d2f56e015b7e5c9515760.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;donnent :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;Init class Ingestion 1.2.3 2025/06/03&lt;br /&gt; public_dir_fs= /home/iazesite/public_html/&lt;br /&gt; Using default Embeddings Model: BAAI&lt;br /&gt; Ready to start&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;erreur ingestwsg : HTTP Error 400 : Ingestion start error : Ingestion error, theme &lt;theme&gt; : load_data error, KeyError, '_collections_mappings'&lt;/strong&gt;&lt;br class='autobr' /&gt;
Cette erreur r&#233;sulte d'une incompatibilit&#233; entre versions de Python utilis&#233;es &#224; diff&#233;rents moments de l'ingestion ou de l'exploitation des donn&#233;es. Il s'agit d'une obsolescence qui devrait dispara&#238;tre.&lt;br class='autobr' /&gt;
La solution consiste &#224; r&#233;-indexer le th&#232;me.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Fatal error : embedding (&lt;i&gt;embed_dimension&lt;/i&gt;) and vector dimensions (&lt;i&gt;vector_dimension&lt;/i&gt;) should be the same&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; embed_dimension : la dimension du mod&#232;le d'embeddings actuellement utilis&#233; pour les requ&#234;tes au LLM,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; vector_dimension : la dimension des embeddings de l'index du th&#232;me consid&#233;r&#233;.&lt;br class='autobr' /&gt;
Cette erreur signifie que les mod&#232;les d'embeddings utilis&#233;s pour l'ingestion puis par les applications ont des dimensions diff&#233;rentes, ou qu'une nouvelle indexation utilise un mod&#232;le diff&#233;rent de la pr&#233;c&#233;dente.&lt;br class='autobr' /&gt;
La solution consiste &#224; r&#233;-indexer le th&#232;me.&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>WsgiChatBot</title>
		<link>https://ia.dnc.global/WsgiChatBot-projet-Mint.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/WsgiChatBot-projet-Mint.html</guid>
		<dc:date>2025-04-04T17:38:25Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;Cette application est un serveur HTTP au standard WSGI. Il est statique (restfull) : pour r&#233;aliser une conversation, ceci impose de g&#233;rer l'historique des &#233;changes au niveau de l'application appelante. Loin d'&#234;tre une contrainte, c'est au contraire une facilit&#233; permettant de g&#233;rer finement le contexte dans lequel sera analys&#233;e la question. &lt;br class='autobr' /&gt;
Tester WsgiChatBot (retour JSON)
&lt;br class='autobr' /&gt;
Tester WsgiChatBot (r&#233;ponse textuelle) Routes &lt;br class='autobr' /&gt;
WsgiChatBot est un web service au standard WSGI (Web Server Gateway Interface) (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Outils-d-IA-textuels-.html" rel="directory"&gt;Outils d'IA textuels&lt;/a&gt;


		</description>


 <content:encoded>&lt;div class='rss_texte'&gt;&lt;p&gt;Cette application est un serveur HTTP au standard WSGI. Il est statique (restfull) : pour r&#233;aliser une conversation, ceci impose de g&#233;rer l'historique des &#233;changes au niveau de l'application appelante. Loin d'&#234;tre une contrainte, c'est au contraire une facilit&#233; permettant de g&#233;rer finement le contexte dans lequel sera analys&#233;e la question.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#034;https://ia.dnc.global/?page=test_wsgi_chatbot_1&#034;&gt;Tester WsgiChatBot (retour JSON)&lt;/a&gt;&lt;br class='autobr' /&gt;
&lt;a href=&#034;https://ia.dnc.global/?page=test_wsgi_chatbot_2&#034;&gt;Tester WsgiChatBot (r&#233;ponse textuelle)&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Routes&lt;/h3&gt;
&lt;p&gt;WsgiChatBot est un web service au standard WSGI (Web Server Gateway Interface) r&#233;pondant en JSON &#224; chaque question qui lui est pos&#233;e par HTTP.&lt;/p&gt;
&lt;p&gt;Les routes comprennent principalement :&lt;/p&gt;
&lt;table class=&#034;spip&#034;&gt;
&lt;tbody&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;GET /api/&lt;/td&gt;
&lt;td&gt;Message d'accueil&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;GET /api/version/&lt;/td&gt;
&lt;td&gt;Version du service&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;GET /api/ping&lt;/td&gt;
&lt;td&gt;Test fonctionnel. Retourne le temps d'ex&#233;cution (ms) ou 0 en cas d'erreur&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;GET /api/themes/&lt;/td&gt;
&lt;td&gt;Liste les th&#232;mes (ensemble de donn&#233;es d'une entit&#233;) disponibles.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;GET /api/details/&lt;/td&gt;
&lt;td&gt;Liste les diff&#233;rents niveaux d'&#233;laboration de la r&#233;ponse.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;GET /api/history/&lt;/td&gt;
&lt;td&gt;Retourne l'historique de la conversation comprim&#233;.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;POST /api/post/&lt;/td&gt;
&lt;td&gt;Ex&#233;cute la requ&#234;te pass&#233;e par POST. param&#232;tres du post : voir ci-dessous.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;h3 class=&#034;spip&#034;&gt;POST, action = 'query'&lt;/h3&gt;
&lt;p&gt;Tous les param&#232;tres du post sont du type String.&lt;/p&gt;
&lt;table class=&#034;spip&#034;&gt;
&lt;tbody&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;Param&#232;tre&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Description&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;action&lt;/td&gt;
&lt;td&gt;obligatoire&lt;/td&gt;
&lt;td&gt;'query' : La seule action dans l'&#233;tat actuel du d&#233;veloppement.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;theme&lt;/td&gt;
&lt;td&gt;obligatoire&lt;/td&gt;
&lt;td&gt;Espace de donn&#233;es (un r&#233;pertoire sur le serveur).&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;prompt&lt;/td&gt;
&lt;td&gt;obligatoire&lt;/td&gt;
&lt;td&gt;La requ&#234;te de l'utilisateur&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;detail&lt;/td&gt;
&lt;td&gt;option&lt;/td&gt;
&lt;td&gt;Niveau de d&#233;tail de la r&#233;ponse (voir la route 'details').&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;history&lt;/td&gt;
&lt;td&gt;option&lt;/td&gt;
&lt;td&gt;Contexte (ou historique) dans lequel la question est analys&#233;e.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;language&lt;/td&gt;
&lt;td&gt;option&lt;/td&gt;
&lt;td&gt;Langage impos&#233; pour la r&#233;ponse.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;La &lt;strong&gt;r&#233;ponse&lt;/strong&gt; au format JSON est un tableau de trois &#233;l&#233;ments : &lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; response : une cha&#238;ne au format MarkDown,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; history : une cha&#238;ne au format JSON,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; ws_error : une simple cha&#238;ne d&#233;crivant une &#233;ventuelle erreur.&lt;/p&gt;
&lt;p&gt;En l'absence d'un proxy inverse, WsgiChatBot ne r&#233;pond qu'&#224; l'h&#244;te (localhost ou 127.0.0.1) sur le port 5002.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Exemple d'appel (PHP)&lt;/h3&gt;&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_php code&#034;&gt;&lt;div class=&#034;php&#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: #000088;&#034;&gt;$data&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/array&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#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; &lt;span style=&#034;color: #0000ff;&#034;&gt;'action'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #0000ff;&#034;&gt;'query'&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #0000ff;&#034;&gt;'theme'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$theme&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// Theme du chat&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: #0000ff;&#034;&gt;'prompt'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$prompt&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// Qu'est-ce que OAuthSD ?&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: #0000ff;&#034;&gt;'detail'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #0000ff;&#034;&gt;'Normal'&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #0000ff;&#034;&gt;'history'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$history&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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: #0000ff;&#034;&gt;'language'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #0000ff;&#034;&gt;&#034;Fran&#231;ais&#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: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;/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: #000088;&#034;&gt;$h&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/curl_init&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_init&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #0000ff;&#034;&gt;&#034;localhost:5002/api/post&#034;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;# local&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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_POST&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_POSTFIELDS&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;a href=&#034;http://www.php.net/http_build_query&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;http_build_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$data&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_RETURNTRANSFER&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_TIMEOUT&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;100&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// 100 secondes&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: #000088;&#034;&gt;$result&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/curl_exec&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_exec&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&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/b14042247ef5734b43728752e974fd99.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div &lt;div class='rss_ps'&gt;&lt;h3 class=&#034;spip&#034;&gt;Lancement du serveur WSGI en ligne de commande&lt;/h3&gt;
&lt;p&gt;Le &lt;strong&gt;script wsgi_chatbot.sh&lt;/strong&gt; permet de lancer le serveur tout en s'assurant qu'il n'y a qu'un seul process en route :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_bash code&#034;&gt;&lt;div class=&#034;bash&#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: #666666; font-style: italic;&#034;&gt;#!/usr/bin/env bash&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: #666666; font-style: italic;&#034;&gt;# contourner l'erreur &#034;ImportError: /lib64/libstdc++.so.6: cannot allocate memory in static TLS block&#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: #7a0874; font-weight: bold;&#034;&gt;export&lt;/span&gt; &lt;span style=&#034;color: #007800;&#034;&gt;LD_PRELOAD&lt;/span&gt;=&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;lib64&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;libstdc++.so.6&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: #666666; font-style: italic;&#034;&gt;# stop any process running on port 5002&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: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;usr&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;sbin&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;&lt;span style=&#034;color: #c20cb9; font-weight: bold;&#034;&gt;fuser&lt;/span&gt; &lt;span style=&#034;color: #660033;&#034;&gt;-k&lt;/span&gt; &lt;span style=&#034;color: #000000;&#034;&gt;5002&lt;/span&gt;&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;tcp;&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: #666666; font-style: italic;&#034;&gt;# change to virtual python env &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: #7a0874; font-weight: bold;&#034;&gt;cd&lt;/span&gt; &lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iadnc&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.dnc.global&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp &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: #7a0874; font-weight: bold;&#034;&gt;source&lt;/span&gt; PythonAppVenv&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;bin&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;activate;&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: #666666; font-style: italic;&#034;&gt;# run &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: #c20cb9; font-weight: bold;&#034;&gt;nohup&lt;/span&gt; &lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iadnc&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.dnc.global&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;wsgi_chatbot.py &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;# pour debugger : pas de nohup &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/9637f06c58133416df61fbea72553209.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Il est important d'utiliser ce script pour &#233;viter l'accumulation de process et la saturation de la m&#233;moire du serveur.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Quelques d&#233;tails du code&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Lancement de l'application Flask comme serveur WSGI s&#233;curis&#233; et local &lt;/strong&gt;&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;if&lt;/span&gt; __name__ &lt;span style=&#034;color: #66cc66;&#034;&gt;==&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;'__main__'&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;# Connection behind a local proxy&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: #808080; font-style: italic;&#034;&gt;# @see: https://flask.palletsprojects.com/en/2.3.x/deploying/proxy_fix/&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;from&lt;/span&gt; werkzeug.&lt;span style=&#034;color: black;&#034;&gt;middleware&lt;/span&gt;.&lt;span style=&#034;color: black;&#034;&gt;proxy_fix&lt;/span&gt; &lt;span style=&#034;color: #ff7700;font-weight:bold;&#034;&gt;import&lt;/span&gt; ProxyFix&lt;/div&gt;&lt;/li&gt;
&lt;li style=&#034;font-weight: normal; vertical-align:top;&#034;&gt;&lt;div style=&#034;&#034;&gt; app.&lt;span style=&#034;color: black;&#034;&gt;wsgi_app&lt;/span&gt; &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; ProxyFix&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; app.&lt;span style=&#034;color: black;&#034;&gt;wsgi_app&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; x_for&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Header to determine the originating IP of the client.&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; x_proto&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Trust the header for knowing whether the client used HTTP or HTTPS.&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; x_host&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Trust the header for the original request's host value. &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; x_prefix&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: #ff4500;&#034;&gt;1&lt;/span&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Trust the header for URL prefix adjustments.&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: #808080; font-style: italic;&#034;&gt;# Allow cross-origin requests, restrict to local clients.&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; CORS&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;app&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; resources&lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;r&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;/api/*&#034;&lt;/span&gt;: &lt;span style=&#034;color: black;&#034;&gt;&#123;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;origins&#034;&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;http://localhost&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;http://127.0.0.1&#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;span style=&#034;color: #483d8b;&#034;&gt;&#034;methods&#034;&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;GET&#034;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;POST&#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;&#125;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&#125;&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;/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;# Serve on localhost&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; http_server &lt;span style=&#034;color: #66cc66;&#034;&gt;=&lt;/span&gt; WSGIServer&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #483d8b;&#034;&gt;'localhost'&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; PORT_SERVER&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #66cc66;&#034;&gt;,&lt;/span&gt; app&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;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; http_server.&lt;span style=&#034;color: black;&#034;&gt;serve_forever&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: black;&#034;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# continuously listen for incoming requests.&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;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; &lt;span style=&#034;color: #808080; font-style: italic;&#034;&gt;# Handle server-level exceptions gracefully&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; trace&lt;span style=&#034;color: black;&#034;&gt;&amp;#40;&lt;/span&gt;f&lt;span style=&#034;color: #483d8b;&#034;&gt;&#034;Server error: {str(e)}&#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;/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/2fcf1f234891ffed5edb11938413f54a.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Ce bloc de code :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Configure l'application Flask pour fonctionner derri&#232;re un &#233;ventuel proxy tout en ajustant les attributs des requ&#234;tes.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Autorise uniquement les clients locaux &#224; effectuer des requ&#234;tes via les r&#232;gles 'CORS'.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; D&#233;marre un serveur WSGI s&#233;curis&#233; et local pour servir l'application.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Intercepte toute exception pour ne pas stopper le serveur. Les erreurs sont inscrites dans un fichier contigu &#224; l'application.&lt;/p&gt;
&lt;p&gt;Notes &#224; propos de la s&#233;curit&#233; :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Bien qu'il s'agisse d'une connexion locale, la r&#232;gle 'CORS' est n&#233;cessaire ; elle permet de plus de pr&#233;ciser les origines et les m&#233;thodes.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Sans proxy inverse, ce serveur ne peut &#234;tre interrog&#233; que depuis 'localhost'. S'il existe un proxy inverse ouvert sur le WAN, celui-ci ne peut qu'&#234;tre local et on peut lui faire confiance, d'o&#249; les attributs de requ&#234;tes na&#239;fs. Il revient au proxy inverse d'assurer la s&#233;curit&#233; de l'acc&#232;s depuis le WAN.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Gestion de l'historique : param&#232;tre 'history'&lt;/h3&gt;
&lt;p&gt;Ainsi qu'il est mentionn&#233; dans l'introduction, le service est statique. Pour donner l'illusion d'une conversation, l'application appelante doit poster par le param&#232;tre 'history' une cha&#238;ne repr&#233;sentative de l'historique des &#233;changes. Cette cha&#238;ne est stock&#233;e dans la session de l'utilisateur.&lt;/p&gt;
&lt;p&gt;Exemple de cha&#238;ne 'history' :&lt;/p&gt;
&lt;p&gt;history = &#034; &lt;br class='autobr' /&gt;
User : What is the best way to learn Python ?&lt;br class='autobr' /&gt;
Assistant : Start with basic syntax and practice with small projects.&lt;/p&gt;
&lt;p&gt;User : Can you suggest a beginner project ?&lt;br class='autobr' /&gt;
Assistant : Try creating a simple to-do list app using Python.&lt;br class='autobr' /&gt;
&#034;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Elaboration de l'historique par le client&lt;/strong&gt;&lt;br class='autobr' /&gt;
L'exp&#233;rience montre que, si on passe tout l'historique (depuis le lancement ou depuis le dernier Reset), il y a un 'effet d'entonnoir' : les question successives &#233;tant noy&#233;es dans l'historique, les r&#233;ponses deviennent courtes et tendent &#224; &#234;tre identiques.&lt;br class='autobr' /&gt;
Diff&#233;rents proc&#233;d&#233;s peuvent &#234;tre appliqu&#233;s :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; n'inclure dans l'historique que le dernier &#233;change,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; inclure la premi&#232;re question et le dernier &#233;change.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; se limiter aux derniers &#233;changes,&lt;br class='autobr' /&gt;
etc.&lt;/p&gt;
&lt;p&gt;Les questions et r&#233;ponses doivent &#234;tre balis&#233;es respectivement par les titres &#034;User : &#034; et &#034;Assistant : &#034;&lt;/p&gt;
&lt;p&gt;Dans tous les cas, le volume de chaque &#233;change doit &#234;tre limit&#233;. Limiter la r&#233;ponse de l'assistant &#224; la premi&#232;re phrase peut s'av&#233;rer suffisant.&lt;/p&gt;
&lt;p&gt;Exemple de construction d'un historique tr&#232;s simple :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_php code&#034; data-clipboard-text=&#034; ...&#034;&gt;&lt;div class=&#034;php&#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: #339933;&#034;&gt;...&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Elaboration de l'historique par le serveur&lt;/strong&gt;&lt;br class='autobr' /&gt;
Le serveur ne peut stocker l'historique, mais il peut, apr&#232;s la requ&#234;te courante, en &#233;laborer une version synth&#233;tique. &lt;br class='autobr' /&gt;
Le client lit le nouvel historique &#224; l'aide de la route GET history et se contente de le repasser au prochain appel.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;'Reset' de l'historique&lt;/strong&gt;&lt;br class='autobr' /&gt;
Puisque le service n'a pas de m&#233;moire des &#233;changes et que l'historique doit &#234;tre g&#233;r&#233; par l'application appelante, le 'Reset' de l'historique est g&#233;r&#233; par cette derni&#232;re. Cela peut se r&#233;sumer &#224; l'effacement du contexte dans la session de l'utilisateur.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Elaboration de l'historique par le serveur : d&#233;veloppements&lt;/h3&gt;
&lt;p&gt;Managing token limits effectively is key when handling conversation history as a single string, especially with models like `mistralai-small`. Here's how you can optimize it :&lt;/p&gt;
&lt;p&gt;### **1. Limit the Number of Past Exchanges**&lt;br class='autobr' /&gt;
Since models have a token limit, you should only keep **the most relevant past exchanges**. You can do this by :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Keeping only the **last N exchanges** (e.g., last 3 conversations).
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; Trimming older history beyond a certain character/token limit.&lt;/p&gt;
&lt;p&gt;Example :&lt;br class='autobr' /&gt;
```python&lt;br class='autobr' /&gt;
MAX_TOKENS = 1024 # Adjust based on model limits&lt;/p&gt;
&lt;p&gt;def trim_history(history) :&lt;br class='autobr' /&gt; &#034;&#034;&#034;Trims conversation history if it exceeds max token limit.&#034;&#034;&#034;&lt;br class='autobr' /&gt; if len(history) &gt; MAX_TOKENS :&lt;br class='autobr' /&gt; # Keep only the last N exchanges&lt;br class='autobr' /&gt; trimmed_history = &#034;\n&#034;.join(history.split(&#034;\n&#034;)[-10 :]) # Keep last 10 exchanges&lt;br class='autobr' /&gt; return trimmed_history&lt;br class='autobr' /&gt; return history&lt;br class='autobr' /&gt;
```&lt;/p&gt;
&lt;p&gt;&#8212; -&lt;/p&gt;
&lt;p&gt;### **2. Use Summary-Based Compression**&lt;br class='autobr' /&gt;
Instead of keeping full conversations, generate **summarized versions** of prior exchanges and store those instead.&lt;/p&gt;
&lt;p&gt;Example using OpenAI's GPT-4-turbo for summarization :&lt;br class='autobr' /&gt;
```python&lt;br class='autobr' /&gt;
import openai&lt;/p&gt;
&lt;p&gt;def summarize_history(history) :&lt;br class='autobr' /&gt; &#034;&#034;&#034;Generate a concise summary of past conversations.&#034;&#034;&#034;&lt;br class='autobr' /&gt; prompt = f&#034;Summarize the following conversation for context preservation :\n\n&lt;i&gt;history&lt;/i&gt;&#034;&lt;/p&gt;
&lt;p&gt; response = openai.ChatCompletion.create(&lt;br class='autobr' /&gt; model=&#034;gpt-4-turbo&#034;,&lt;br class='autobr' /&gt; messages=[&lt;i&gt;&#034;role&#034; : &#034;system&#034;, &#034;content&#034; : prompt&lt;/i&gt;]&lt;br class='autobr' /&gt; )&lt;/p&gt;
&lt;p&gt; return response[&#034;choices&#034;][0][&#034;message&#034;][&#034;content&#034;]&lt;br class='autobr' /&gt;
```&lt;/p&gt;
&lt;p&gt;Then, when querying :&lt;br class='autobr' /&gt;
```python&lt;br class='autobr' /&gt;
history = summarize_history(history)&lt;br class='autobr' /&gt;
new_query = &#034;What libraries would be useful for that project ?&#034;&lt;br class='autobr' /&gt;
final_query = f&#034;&lt;i&gt;history&lt;/i&gt;\nUser : &lt;i&gt;new_query&lt;/i&gt;&#034;&lt;br class='autobr' /&gt;
```&lt;/p&gt;
&lt;p&gt;&#8212; -&lt;/p&gt;
&lt;p&gt;### **3. Use Rolling History Buffer**&lt;br class='autobr' /&gt;
Instead of maintaining **one big string**, store history as a **rolling buffer** that automatically removes older entries.&lt;/p&gt;
&lt;p&gt;Example using Python `deque` :&lt;br class='autobr' /&gt;
```python&lt;br class='autobr' /&gt;
from collections import deque&lt;/p&gt;
&lt;p&gt;chat_history = deque(maxlen=10) # Keep only the last 10 exchanges&lt;/p&gt;
&lt;p&gt;def add_to_history(user_msg, assistant_msg) :&lt;br class='autobr' /&gt; &#034;&#034;&#034;Adds conversation entries while maintaining rolling buffer.&#034;&#034;&#034;&lt;br class='autobr' /&gt; chat_history.append(f&#034;User : &lt;i&gt;user_msg&lt;/i&gt;&#034;)&lt;br class='autobr' /&gt; chat_history.append(f&#034;Assistant : &lt;i&gt;assistant_msg&lt;/i&gt;&#034;)&lt;/p&gt;
&lt;p&gt;# Example usage&lt;br class='autobr' /&gt;
add_to_history(&#034;Tell me about Python&#034;, &#034;Python is a powerful programming language.&#034;)&lt;br class='autobr' /&gt;
add_to_history(&#034;How do I install it ?&#034;, &#034;Use the official website or package manager.&#034;)&lt;/p&gt;
&lt;p&gt;# Convert deque to a string before querying&lt;br class='autobr' /&gt;
formatted_history = &#034;\n&#034;.join(chat_history)&lt;br class='autobr' /&gt;
print(formatted_history) # Keeps only the last 10 exchanges&lt;br class='autobr' /&gt;
```&lt;/p&gt;
&lt;p&gt;&#8212; -&lt;/p&gt;
&lt;p&gt;### **Which Approach Works Best ?**
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; **Short conversations ?** &#8594; Keep last N exchanges (`trim_history()`).
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; **Long conversations ?** &#8594; Use summarization (`summarize_history()`).
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; **Dynamic conversations ?** &#8594; Use rolling history buffer (`deque`).&lt;/p&gt;&lt;/div&gt;
		
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>ChattyBot</title>
		<link>https://ia.dnc.global/ChattyBot.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/ChattyBot.html</guid>
		<dc:date>2024-11-27T13:30:00Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;ChattyBot est un robot conversationnel. C'est une application Web autonome qui traite des donn&#233;es sanctuaris&#233;es dans un espace priv&#233;. &lt;br class='autobr' /&gt;
RAG plut&#244;t que Fine Tuning &lt;br class='autobr' /&gt;
Les donn&#233;es de l'entit&#233; (th&#232;me) sont trait&#233;es et conserv&#233;es sur un serveur d&#233;di&#233;. Ce serveur peut appartenir &#224; l'entit&#233; (on premise). Cela est rendu possible par l'application de la m&#233;thode RAG (Retrieval Augmented Generation ou g&#233;n&#233;ration augment&#233;e de r&#233;cup&#233;ration). RAG s'oppose aux m&#233;thodes d'entra&#238;nement du LLM comme le &#034;fine tuning&#034;. Bien (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Outils-d-IA-textuels-.html" rel="directory"&gt;Outils d'IA textuels&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/L76xH150/arton2-2efc6.png?1776300676' width='76' height='150' /&gt;
		&lt;div class='rss_chapo'&gt;&lt;p&gt;ChattyBot est un robot conversationnel. C'est une application Web autonome qui traite des donn&#233;es sanctuaris&#233;es dans un espace priv&#233;.&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;h3 class=&#034;spip&#034;&gt;RAG plut&#244;t que Fine Tuning&lt;/h3&gt;
&lt;p&gt;Les donn&#233;es de l'entit&#233; (th&#232;me) sont trait&#233;es et conserv&#233;es sur un serveur d&#233;di&#233;. Ce serveur peut appartenir &#224; l'entit&#233; (on premise). &lt;br class='autobr' /&gt;
Cela est rendu possible par l'application de la m&#233;thode RAG (Retrieval Augmented Generation ou g&#233;n&#233;ration augment&#233;e de r&#233;cup&#233;ration). &lt;br class='autobr' /&gt;
RAG s'oppose aux m&#233;thodes d'entra&#238;nement du LLM comme le &#034;fine tuning&#034;. Bien que ChattyBot fasse appel &#224; des APIs pour une partie des traitements s&#233;mantiques, les donn&#233;es ne sont pas utilis&#233;es par celles-ci pour alimenter leur mod&#232;le de langage (LLM).&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Th&#232;mes&lt;/h3&gt;
&lt;p&gt;ChattyBot est capable de &lt;strong&gt;s&#233;curiser les donn&#233;es de plusieurs entit&#233;s en les isolant dans des espaces de donn&#233;es sp&#233;cifiques&lt;/strong&gt;, mat&#233;rialis&#233;s sur le serveur par un r&#233;pertoire portant le nom du th&#232;me&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb1' class='spip_note' rel='appendix' title='Les th&#232;mes disponibles dans le prototype comprennent actuellement : &#034;itego&#034;, (...)' id='nh1'&gt;1&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;S&#233;parer les donn&#233;es appartenant &#224; des univers diff&#233;rents permet &#233;galement d'&lt;strong&gt;&#233;liminer l'hallucination&lt;/strong&gt;, fl&#233;au de l'IA g&#233;n&#233;rative : la g&#233;n&#233;ration de r&#233;ponses totalement incoh&#233;rentes r&#233;sultant de la confusion de concepts diff&#233;rents dans une m&#234;me signature s&#233;mantique.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Les avantages exclusifs de ChattyBot&lt;/h3&gt;
&lt;p&gt;Outre la gestion de diff&#233;rents th&#232;mes, ChattyBot offre des avanc&#233;es techniques remarquables en pr&#233;sentant dans ses r&#233;ponses :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; des &lt;strong&gt;images&lt;/strong&gt; extraites des document. &lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; les &lt;strong&gt;sources&lt;/strong&gt; utilis&#233;es pour l'&#233;laboration de la r&#233;ponse.
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; au niveau de d&#233;tail 'Long', des &lt;strong&gt;questions&lt;/strong&gt; pertinentes pour aider l'utilisateur &#224; creuser son sujet .&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;TesterChattyBot&lt;/h3&gt;
&lt;p&gt;Une application de ChattyBot est sur le Web &#224; l'adresse : &lt;br class='autobr' /&gt; &lt;a href=&#034;https://chat.ia.whatiswhat.cloud&#034; class='spip_out' rel='external'&gt;https://chat.ia.whatiswhat.cloud/?theme=thewiw-help&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;Les th&#232;mes disponibles dans le prototype comprennent actuellement : &lt;i&gt;&#034;itego&#034;, &#034;thewiw-help&#034;, &#034;securite&#034; ...&lt;/i&gt; :&lt;br class='autobr' /&gt;
itego : (th&#232;me par d&#233;faut) int&#232;gre la totalit&#233; des donn&#233;es d'i-Tego diffus&#233;es sur le Web (plus de 500 pages A4). &lt;br class='autobr' /&gt;
ardennes : int&#232;gre une extraction des donn&#233;es de DATAtourisme pour le d&#233;partement des Ardennes (plus de 2500 points d'int&#233;r&#234;t), ainsi que quelques documents historiques et culturels pertinents.&lt;br class='autobr' /&gt;
securite : des documents portant sur la s&#233;curit&#233; du travail dans l'industrie et les contr&#244;les techniques.&lt;br class='autobr' /&gt;
thewiw : le contenu du &lt;a href=&#034;https://thewiw.com/&#034; class='spip_out' rel='external'&gt;site web de What is What&lt;/a&gt; et de son aide en ligne.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
		</content:encoded>


		

	</item>
<item xml:lang="fr">
		<title>WsgiAgent</title>
		<link>https://ia.dnc.global/ChattyWS.html</link>
		<guid isPermaLink="true">https://ia.dnc.global/ChattyWS.html</guid>
		<dc:date>2024-11-07T15:45:00Z</dc:date>
		<dc:format>text/html</dc:format>
		<dc:language>fr</dc:language>
		<dc:creator>Bertrand Degoy</dc:creator>



		<description>
&lt;p&gt;WsgiAgent est le d&#233;monstrateur d'un service web d'IA g&#233;n&#233;rative con&#231;u pour &#234;tre int&#233;gr&#233; &#224; une application textuelle. Par exemple, il peut r&#233;pondre aux questions, apporter automatiquement des corrections aux textes fournis et s'opposer aux contenus inappropri&#233;s. Et beaucoup plus encore ... &lt;br class='autobr' /&gt;
WsgiAgent (ex ChattyWS) est un web service au standard WSGI (Web Server Gateway Interface) r&#233;pondant &#224; chaque question qui lui est pos&#233;e par HTTP. Comme ChattyBot, il int&#232;gre les donn&#233;es d'une entit&#233; selon la m&#233;thode (...)&lt;/p&gt;


-
&lt;a href="https://ia.dnc.global/-Outils-d-IA-textuels-.html" rel="directory"&gt;Outils d'IA textuels&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/L150xH119/arton3-0b555.png?1776300676' width='150' height='119' /&gt;
		&lt;div class='rss_chapo'&gt;&lt;p&gt;WsgiAgent est le d&#233;monstrateur d'un service web d'IA g&#233;n&#233;rative con&#231;u pour &#234;tre int&#233;gr&#233; &#224; une application textuelle. Par exemple, il peut r&#233;pondre aux questions, apporter automatiquement des corrections aux textes fournis et s'opposer aux contenus inappropri&#233;s. Et beaucoup plus encore ...&lt;/p&gt;&lt;/div&gt;
		&lt;div class='rss_texte'&gt;&lt;p&gt;WsgiAgent (ex ChattyWS) est un &lt;strong&gt;web service au standard WSGI &lt;/strong&gt; (Web Server Gateway Interface) r&#233;pondant &#224; chaque question qui lui est pos&#233;e par HTTP.&lt;br class='autobr' /&gt;
Comme ChattyBot, il int&#232;gre les donn&#233;es d'une entit&#233; selon la m&#233;thode RAG (Retrivial Augmented Generation).&lt;/p&gt;
&lt;p&gt;Le service est construit en Python avec LLama Index et avec Flask + Gevent pour r&#233;pondre au standard WSGI (Web Server Gateway Interface). Il est fait appel &#224; des APIs pour l'analyse s&#233;mantique et la g&#233;n&#233;ration du texte.&lt;/p&gt;
&lt;p&gt;Ce service est purement statique (RestFull) : aucun statut (&#233;tat, param&#232;tre) n'est m&#233;moris&#233;, il n'y a donc pas de session ni de cookie. C'est une diff&#233;rence importante avec ChattyBot qui prend en compte le dialogue ant&#233;rieur dans le contexte de la question, ce qui n&#233;cessite session et cookie.&lt;/p&gt;
&lt;p&gt;WsgiAgent est un service &lt;strong&gt;multilingue&lt;/strong&gt;, r&#233;pondant dans la langue dans laquelle il est interrog&#233; et capable d'effectuer des traductions.&lt;/p&gt;
&lt;p&gt;Les &lt;strong&gt;Th&#232;mes &lt;/strong&gt; et les &lt;strong&gt;Modes &lt;/strong&gt; permettent de configurer WsgiAgent afin d'effectuer toutes t&#226;ches d'IA g&#233;n&#233;rative sur les donn&#233;es de diff&#233;rentes entit&#233;s.&lt;/p&gt;
&lt;p&gt;Le d&#233;monstrateur est plus particuli&#232;rement configur&#233; pour appliquer automatiquement des corrections au texte fourni et s'opposer aux contenus inappropri&#233;s. &lt;br class='autobr' /&gt;
Ceci en fait un composant id&#233;al pour, par exemple :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; assurer la qualit&#233; de r&#233;daction d'un site Web,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; assurer automatiquement la mod&#233;ration d'un forum, &lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; r&#233;pondre &#224; une question dans le cas d'une FAQ etc.&lt;/p&gt;
&lt;p&gt;&lt;a id=&#034;themes&#034;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Th&#232;mes&lt;/h3&gt;
&lt;p&gt;ChattyBot et WsgiAgent utilisent les m&#234;mes donn&#233;es (le m&#234;me Vector Store). Ces deux services sont capables de &lt;strong&gt;s&#233;curiser les donn&#233;es de plusieurs entit&#233;s en les isolant dans des espaces de donn&#233;es sp&#233;cifiques&lt;/strong&gt;, mat&#233;rialis&#233;s sur le serveur par un r&#233;pertoire portant le nom du th&#232;me : &lt;br class='autobr' /&gt;
/home/iadnc/public_html/data/&lt;i&gt;theme&lt;/i&gt;&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb1' class='spip_note' rel='appendix' title='Les th&#232;mes disponibles dans le prototype comprennent notamment : &#034;itego&#034;, (...)' id='nh1'&gt;1&lt;/a&gt;]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Les donn&#233;es de l'entit&#233; (th&#232;me) sont conserv&#233;es sur le serveur d'i-Tego ou un serveur d&#233;di&#233; &#224; l'entit&#233;. Elles ne sont pas utilis&#233;es par OpenAI pour alimenter le mod&#232;le de langage (LLM). Cela est possible gr&#226;ce &#224; la m&#233;thode RAG (Retrieval Augmented Generation ou g&#233;n&#233;ration augment&#233;e de r&#233;cup&#233;ration), contrairement &#224; des m&#233;thodes d'entra&#238;nement du LLM comme le &#034;fine tuning&#034;.&lt;/p&gt;
&lt;p&gt;Diff&#233;rents th&#232;mes pourraient &#234;tre utilis&#233;s par une m&#234;me entit&#233; pour segmenter des groupes de donn&#233;es. Cela peut &#234;tre fait pour s&#233;parer des domaines tr&#232;s diff&#233;rents et &#233;viter des hallucinations. Cela peut &#233;galement &#234;tre utilis&#233; pour s&#233;parer des donn&#233;es r&#233;serv&#233;es &#224; l'usage interne de l'entreprise de celles destin&#233;es au public.&lt;/p&gt;
&lt;p&gt;&lt;a id=&#034;modes&#034;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Modes&lt;/h3&gt;
&lt;p&gt;WsgiAgent est hautement configurable afin de &lt;strong&gt;r&#233;pondre aux objectifs particuliers d'une application donn&#233;e&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Dans le cadre de ce d&#233;monstrateur&lt;/i&gt;, WsgiAgent a permis de configurer les &lt;strong&gt;modes&lt;/strong&gt; suivants :&lt;br class='autobr' /&gt; - &lt;strong&gt;answer&lt;/strong&gt; : L'assistant doit fournir une r&#233;ponse &#224; la question pos&#233;e.&lt;br class='autobr' /&gt; - &lt;strong&gt;summarize&lt;/strong&gt; : L'assistant doit r&#233;sumer et corriger un texte donn&#233;.&lt;br class='autobr' /&gt; - &lt;strong&gt;correct&lt;/strong&gt; : L'assistant doit corriger l'orthographe et la grammaire d'un texte.&lt;br class='autobr' /&gt; - &lt;strong&gt;improve&lt;/strong&gt; : L'assistant doit am&#233;liorer un texte en &#233;liminant les r&#233;p&#233;titions.&lt;br class='autobr' /&gt; - &lt;strong&gt;complete&lt;/strong&gt; : L'assistant doit compl&#233;ter une question en se basant sur un contexte donn&#233;.&lt;br class='autobr' /&gt; - &lt;strong&gt;extend&lt;/strong&gt; : L'assistant doit d&#233;velopper un texte en tentant de d&#233;tailler chaque phrase.&lt;/p&gt;
&lt;p&gt;Tous les modes s'opposent &#224; une question inappropri&#233;e (vulgarit&#233;, racisme, sexisme, conflictualit&#233; etc.) en g&#233;n&#233;rant un message d'erreur.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Tester WsgiAgent : R&#233;ponse au format JSON &#224; un POST&lt;/h3&gt;
&lt;p&gt;La page &lt;a href=&#034;https://ia.dnc.global/?page=test_wsgi_1&#034;&gt;Test WsgiAgent 1&lt;/a&gt; pr&#233;sente un formulaire qui permet d'adresser une requ&#234;te HTTP POST au web service.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Tester WsgiAgent : mod&#233;ration et traduction&lt;/h3&gt;
&lt;p&gt;La page &lt;a href=&#034;https://ia.dnc.global/?page=test_wsgi_2&#034;&gt;Test WsgiAgent 2&lt;/a&gt; pr&#233;sente un formulaire qui permet d'effectuer un traitement de mod&#233;ration et de traduction sur les donn&#233;es du th&#232;me 'securite'.&lt;/p&gt;
&lt;p&gt;La configuration de WsgiAgent pour cette application de d&#233;monstration est d&#233;crite ici : &lt;a href='https://ia.dnc.global/ChattyWS-2-exemple-de-configuration-et-de-codage.html' class='spip_in'&gt;WsgiAgent 2 : exemple de configuration et de codage&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;
		&lt;hr /&gt;
		&lt;div &lt;div class='rss_ps'&gt;&lt;h3 class=&#034;spip&#034;&gt;Lancement&lt;/h3&gt;
&lt;p&gt;Dans la configuration de ce d&#233;monstrateur, le lancement est effectu&#233; par l'ex&#233;cution du &lt;strong&gt;script wsgitego.sh&lt;/strong&gt; de la fa&#231;on suivante :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_bash code&#034;&gt;&lt;div class=&#034;bash&#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: #666666; font-style: italic;&#034;&gt;#!/usr/bin/env bash&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: #666666; font-style: italic;&#034;&gt;# contourner l'erreur &#034;ImportError: /lib64/libstdc++.so.6: cannot allocate memory in static TLS block&#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: #7a0874; font-weight: bold;&#034;&gt;export&lt;/span&gt; &lt;span style=&#034;color: #007800;&#034;&gt;LD_PRELOAD&lt;/span&gt;=&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;lib64&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;libstdc++.so.6&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: #666666; font-style: italic;&#034;&gt;# stop any process running on port 5000&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: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;usr&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;sbin&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;&lt;span style=&#034;color: #c20cb9; font-weight: bold;&#034;&gt;fuser&lt;/span&gt; &lt;span style=&#034;color: #660033;&#034;&gt;-k&lt;/span&gt; &lt;span style=&#034;color: #000000;&#034;&gt;5000&lt;/span&gt;&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;tcp;&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: #666666; font-style: italic;&#034;&gt;# change to virtual python env &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: #7a0874; font-weight: bold;&#034;&gt;cd&lt;/span&gt; &lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iadnc&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.dnc.global&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp &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: #7a0874; font-weight: bold;&#034;&gt;source&lt;/span&gt; PythonAppVenv&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;bin&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;activate;&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: #666666; font-style: italic;&#034;&gt;# run &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: #c20cb9; font-weight: bold;&#034;&gt;nohup&lt;/span&gt; &lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;home&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;iadnc&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;domains&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;chat.ia.dnc.global&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;PythonApp&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;llama&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;test&lt;span style=&#034;color: #000000; font-weight: bold;&#034;&gt;/&lt;/span&gt;wsgitego.py &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;# pour debugger : pas de nohup &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/e7e29bd4324c5c631543993bf192d36e.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Une fois lanc&#233;, le service web fonctionne de fa&#231;on continue. &lt;br class='autobr' /&gt;
Une bonne pratique est de configurer une t&#226;che CRON pour lancer le script toutes les nuits.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Interrogation, proxy inverse&lt;/h3&gt;
&lt;p&gt;Pens&#233; pour &#234;tre int&#233;gr&#233; dans une application, ou &#234;tre interrog&#233; &#224; travers un proxy inverse, ChattyWS ne r&#233;pond qu'en local &#224; l'URL :&lt;br class='autobr' /&gt; localhost:5000/ &lt;br class='autobr' /&gt;
Cela est favorable &#224; la protection des donn&#233;es de l'entit&#233; et permet de restreindre l'usage, notamment pour ma&#238;triser la cadence d'interrogation au niveau de l'application ou d'un proxy s&#233;curis&#233;.&lt;/p&gt;
&lt;p&gt;Le prototype est accessible depuis le Web au travers d'un simple &lt;a href='https://ia.dnc.global/Securisation-de-l-acces-a-ChattyWS.html#web' class='spip_in'&gt;proxy inverse Apache&lt;/a&gt; &#224; l'url :&lt;br class='autobr' /&gt; &lt;a href=&#034;https://wsgi.ia.dnc.global/&#034; class='spip_url spip_out auto' rel='nofollow external'&gt;https://wsgi.ia.dnc.global/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Comme il se doit, la s&#233;curit&#233; est assur&#233;e par le proxy en TLS sur le port 443.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Routes &lt;/h3&gt;
&lt;p&gt;ChattyWS est un web service au standard WSGI (Web Server Gateway Interface) r&#233;pondant &#224; chaque question qui lui est pos&#233;e par HTTP.&lt;/p&gt;
&lt;p&gt;Les routes comprennent principalement :&lt;/p&gt;
&lt;table class=&#034;spip&#034;&gt;
&lt;tbody&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;GET /api/&lt;/td&gt;
&lt;td&gt;Message d'accueil&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;GET /api/version/&lt;/td&gt;
&lt;td&gt;Version de l'API&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;GET /api/themes/&lt;/td&gt;
&lt;td&gt;Liste les th&#232;mes (ensemble de donn&#233;es d'une entit&#233;) disponibles.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_even even'&gt;
&lt;td&gt;GET /api/get/ ?theme=&lt;theme&gt;&amp;mode=&lt;mode&gt;&amp;query=&lt;query&gt;&lt;/td&gt;
&lt;td&gt;Ex&#233;cute la requ&#234;te avec les param&#232;tres pass&#233;s par l'URL.&lt;/td&gt;&lt;/tr&gt;
&lt;tr class='row_odd odd'&gt;
&lt;td&gt;POST /api/post/&lt;/td&gt;
&lt;td&gt;Ex&#233;cute la requ&#234;te pass&#233;e par POST. &lt;br class='autobr' /&gt;
param&#232;tres : &lt;br class='autobr' /&gt;
theme : facultatif - espace de donn&#233;es (un r&#233;pertoire sur le serveur). Les th&#232;mes du prototype sont actuellement :&lt;i&gt;&#034;itego&#034;, &#034; ardennes&#034; ...&lt;/i&gt;. D&#233;faut : &#034;itego&#034;.&lt;br class='autobr' /&gt;
mode : facultatif - type de traitement : &lt;i&gt; &#034;answer&#034;, &#034;summarize&#034;, &#034;correct&#034;, &#034;improve&#034;, &#034;complete&#034;, &#034;extend&#034;&lt;/i&gt;. D&#233;faut : &#034;improve&#034;.&lt;br class='autobr' /&gt;
instructions : facultatif - compl&#233;ment aux instructions g&#233;n&#233;rales.&lt;br class='autobr' /&gt;
query : obligatoire - la requ&#234;te (attention, doit &#234;tre &#034;URL encoded&#034;).&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Exemple d'appel distant en PHP :&lt;/p&gt;
&lt;div class=&#034;coloration_code code&#034;&gt;&lt;div class=&#034;spip_php code&#034;&gt;&lt;div class=&#034;php&#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: #000088;&#034;&gt;$data&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/array&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#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; &lt;span style=&#034;color: #0000ff;&#034;&gt;'theme'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$theme&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// Theme du chat.&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: #0000ff;&#034;&gt;'mode'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$mode&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// answer,summarize,correct,improve,complete,extend &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: #0000ff;&#034;&gt;'query'&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&gt;&lt;/span&gt; &lt;span style=&#034;color: #000088;&#034;&gt;$query&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// Qu'est-ce que OAuthSD ? &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: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;/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: #000088;&#034;&gt;$h&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/curl_init&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_init&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #0000ff;&#034;&gt;&#034;https://wsgi.ia.dnc.global/api/post&#034;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_POST&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_POSTFIELDS&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;a href=&#034;http://www.php.net/http_build_query&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;http_build_query&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$data&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_RETURNTRANSFER&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;1&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#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;a href=&#034;http://www.php.net/curl_setopt&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_setopt&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; CURLOPT_TIMEOUT&lt;span style=&#034;color: #339933;&#034;&gt;,&lt;/span&gt; &lt;span style=&#034;color: #cc66cc;&#034;&gt;100&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&lt;/span&gt; &lt;span style=&#034;color: #666666; font-style: italic;&#034;&gt;// 100 secondes&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: #000088;&#034;&gt;$result&lt;/span&gt; &lt;span style=&#034;color: #339933;&#034;&gt;=&lt;/span&gt; &lt;a href=&#034;http://www.php.net/curl_exec&#034;&gt;&lt;span style=&#034;color: #990000;&#034;&gt;curl_exec&lt;/span&gt;&lt;/a&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&#034;color: #000088;&#034;&gt;$h&lt;/span&gt;&lt;span style=&#034;color: #009900;&#034;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&#034;color: #339933;&#034;&gt;;&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/b87f37a457a1aa63bab5ad723bfad032.txt'&gt;T&#233;l&#233;charger&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;h3 class=&#034;spip&#034;&gt;R&#233;ponse&lt;/h3&gt;
&lt;p&gt;ChattyWS r&#233;pond par un objet JSON &lt;i&gt;&#034;response&#034;, &#034;chat_error&#034;&lt;/i&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;response&lt;/strong&gt;&lt;br class='autobr' /&gt;
La r&#233;ponse est un texte cod&#233; UTF8 sans markup, faiblement structur&#233;, ne comportant que :
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; des retours &#224; la ligne,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; parfois du &lt;a href=&#034;https://fr.wikipedia.org/wiki/Markdown&#034; class='spip_out' rel='external'&gt;markdown&lt;/a&gt;, par exemple : **H&#244;tel &#034;Campanile&#034; Charleville**,
&lt;br /&gt;&lt;span class=&#034;spip-puce ltr&#034;&gt;&lt;b&gt;&#8211;&lt;/b&gt;&lt;/span&gt; &#233;ventuellement, une num&#233;rotation des paragraphes.&lt;/p&gt;
&lt;p&gt;Notes :&lt;br class='autobr' /&gt;
&#8226;	Le mode answer permet d'ins&#233;rer des instructions pour la recherche et la pr&#233;sentation. Se r&#233;f&#233;rer &#224; la documentation g&#233;n&#233;rale traitant de la formulations des questions pos&#233;es &#224; ChattyBot (prompt). &lt;br class='autobr' /&gt;
&#8226;	Une r&#233;ponse structur&#233;e peut &#234;tre produite en se fondant sur la d&#233;finition de sch&#233;mas de sortie (output schemas). Cependant, les sch&#233;mas ne peuvent &#234;tre d&#233;finis que dans le cadre d'une application donn&#233;e.&lt;br class='autobr' /&gt;
&#8226;	Le texte est encod&#233; UTF-8.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;chat_error&lt;/strong&gt;&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;&lt;li&gt; Erreurs d&#233;tect&#233;es par IA&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Les d&#233;finitions de ce type d'erreurs et de leur libell&#233; font partie de la configuration. Dans le cadre de ce d&#233;monstration, les erreurs suivantes ont &#233;t&#233; programm&#233;es :&lt;/p&gt;
&lt;p&gt;Erreur 1 - Je manque de documentation pour r&#233;pondre :&lt;br class='autobr' /&gt;
Il n'existe aucun document source sur lequel appuyer la r&#233;ponse, ou la question sort totalement du th&#232;me.&lt;/p&gt;
&lt;p&gt;Erreur 2 - Veuillez pr&#233;ciser la question :&lt;br class='autobr' /&gt;
La question n'est pas assez pr&#233;cise pour permettre la s&#233;lection de sources.&lt;/p&gt;
&lt;p&gt;Erreur 3 - Formulation inappropri&#233;e :&lt;br class='autobr' /&gt;
La question est inappropri&#233;e ou comporte des mots grossiers. &lt;br class='autobr' /&gt;
Par &#034;inappropri&#233;e&#034; il faut entendre : injurieuse, d&#233;plac&#233;e, vulgaire, &#224; connotation sexuelle, raciste, politique etc. Mais ce peut &#233;galement &#234;tre une question sans signification comme : &#034;Tu y comprends quelque chose ?&#034;.&lt;/p&gt;
&lt;p&gt;Il convient de noter que ChattyWS est plus strict que ChattyBot, car il ne s'agit pas d'un robot conversationnel, mais d'un automate r&#233;pondant de mani&#232;re pertinente &#224; des questions, par exemple dans le cadre d'une FAQ.&lt;/p&gt;
&lt;ul class=&#034;spip&#034;&gt;&lt;li&gt; Erreurs techniques &#224; l'appel du web service&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Ces erreurs sont g&#233;n&#233;r&#233;es par l'ex&#233;cution du code. Par exemple :&lt;span class=&#034;spip_note_ref&#034;&gt; [&lt;a href='#nb2' class='spip_note' rel='appendix' title='Dans l'&#233;tat actuel du d&#233;veloppement, toutes les erreurs ne sont pas signal&#233;es (...)' id='nh2'&gt;2&lt;/a&gt;]&lt;/span&gt; :&lt;/p&gt;
&lt;p&gt;ws_llmquery : cURL error : Failed to connect to localhost port 5000 : Connection refused.&lt;br class='autobr' /&gt;
S'agissant d'une connexion locale, il est tr&#232;s probable que le process ChattyWS.py soit arr&#234;t&#233;, en cours de (re-)d&#233;marrage ou que les param&#232;tres de la connexion soient erron&#233;s.&lt;/p&gt;
&lt;p&gt;ws_llmquery : HTTP Error 400 : The browser (or proxy) sent a request that this server could not understand.&lt;br class='autobr' /&gt; Requ&#234;te erron&#233;e, v&#233;rifier la route et les param&#232;tres.&lt;/p&gt;
&lt;p&gt;Toutes les erreurs signal&#233;es par chat_error s'accompagnent d' une valeur de response nulle.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;Configuration des traitements de ChattyWS&lt;/h3&gt;
&lt;p&gt;La possibilit&#233; de red&#233;finir les traitements en fonction d'objectifs donn&#233;s est une des originalit&#233;s que l'on retrouve dans tous les d&#233;veloppements d'IA de DnC.&lt;/p&gt;
&lt;p&gt;Voici des informations utiles pour la configuration des traitements internes (system prompt) :&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;System prompt, instructions&lt;/strong&gt;&lt;br class='autobr' /&gt;
Le syst&#232;me prompt est compos&#233; d'une suite d'instructions, dans l'ordre : instructions g&#233;n&#233;rales, instructions pass&#233;es par URL ou instructions du mode.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Instructions g&#233;n&#233;rales&lt;/strong&gt; &lt;br class='autobr' /&gt;
Les instructions g&#233;n&#233;rales d&#233;finissent le r&#244;le du robot, le contexte g&#233;n&#233;ral et des instructions. &lt;br class='autobr' /&gt;
La d&#233;finition par d&#233;faut peut &#234;tre red&#233;finie par le &lt;strong&gt;param&#232;tre general_instructions&lt;/strong&gt; du &lt;strong&gt;fichier parametres.json&lt;/strong&gt;.&lt;br class='autobr' /&gt;
Exemple :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code&gt;You are a faithfull QA assistant, expert about {theme}. &lt;br /&gt; If you don't have enough source material to support your answer on, say: 'Error 1 - I lack documentation to answer.&lt;br /&gt; If the question is not specific enough to allow source selection, say: 'Error 2 - Please clarify the question.&lt;br /&gt; If the question contains rude or inappropriate words, say: 'Error 3 - Inappropriate wording.'&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Il faut noter que le mode 'answer' ne tient pas compte des instructions g&#233;n&#233;rales, mais seulement des instructions pass&#233;es par URL ou, par d&#233;faut, des instructions du mode. Ceci afin de permettre la plus large latitude dans le fonctionnement du mode.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Instructions pass&#233;es par URL&lt;/strong&gt;&lt;br class='autobr' /&gt;
De mani&#232;re facultative, des instructions peuvent &#234;tre pass&#233;es par le &lt;strong&gt;param&#232;tre d'URL instructions&lt;/strong&gt; lors de l'appel au web service. Elles compl&#232;tent (ne remplacent pas) les instructions g&#233;n&#233;rales et se substituent aux instructions des modes du fichier parameters.json.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Instruction du mode &lt;/strong&gt; &lt;br class='autobr' /&gt;
Ce sont les instructions particuli&#232;res du mode. La d&#233;finition par d&#233;faut (fig&#233;e dans le code) peut &#234;tre red&#233;finie par le &lt;strong&gt;param&#232;tre mode_instructions&lt;/strong&gt; du &lt;strong&gt;fichier parametres.json&lt;/strong&gt;. Ceci est applicable &#224; tous les modes. Il est recommand&#233; d'utiliser cette possibilit&#233; avec discernement sous peine de s'&#233;carter de l'objectif du mode.&lt;/p&gt;
&lt;p&gt;Notes :&lt;br class='autobr' /&gt;
&#8226;	Le robot ne retient aucun contexte (contrairement au ChattyBot). La question pass&#233;e au Query engine n'est compos&#233;e que des instructions d&#233;finies ci-dessus et de la question pass&#233;e en param&#232;tre d'URL query.&lt;/p&gt;
&lt;h3 class=&#034;spip&#034;&gt;fichier parameters.json&lt;/h3&gt;
&lt;p&gt;Le fichier se trouve dans le r&#233;pertoire .../data/&lt;i&gt;theme&lt;/i&gt;/configuration.&lt;br class='autobr' /&gt;
En plus des instructions, le fichier permet de d&#233;finir des constantes propres au th&#232;me consid&#233;r&#233;. &lt;br class='autobr' /&gt;
Exemple pour le th&#232;me ardennes :&lt;/p&gt;
&lt;div style='text-align: left;' class='spip_code' dir='ltr'&gt;&lt;code class=&#034;json&#034;&gt;{&lt;br /&gt; &#034;directory&#034;: &#034;ardennes&#034;,&lt;br /&gt; &#034;title&#034;: &#034;Les Ardennes&#034;,&lt;br /&gt; &#034;description&#034;: {&lt;br /&gt; &#034;en&#034;: &#034;Talk about the history and geography of the Ardennes (France) and the various tourist activities&#034;,&lt;br /&gt; &#034;fr&#034;: &#034;Parler de l'histoire et de la g&#233;ographie des Ardennes (France) et des diverses activit&#233;s touristiques&#034;&lt;br /&gt; },&lt;br /&gt; &#034;modes&#034;: &#034;'answer','summarize','correct','improve','complete','extend'&#034;,&lt;br /&gt; &#034;general_instructions&#034;: &#034;You are a chatty tour guide, ...&lt;br /&gt; &#034;mode_instructions&#034;: {&lt;br /&gt; &#034;extend&#034;: &#034; You are a faithfull QA assistant, expert about {theme}.\nContext information is below...&#034;&lt;br /&gt; }&lt;br /&gt; }&lt;/code&gt;&lt;/div&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;Les th&#232;mes disponibles dans le prototype comprennent notamment : &lt;i&gt;&#034;itego&#034;, &#034;ardennes&#034;, ...&lt;/i&gt; :&lt;br class='autobr' /&gt;
itego : (th&#232;me par d&#233;faut) int&#232;gre la totalit&#233; des donn&#233;es d'i-Tego diffus&#233;es sur le Web (plus de 500 pages A4). &lt;br class='autobr' /&gt;
ardennes : int&#232;gre une extraction des donn&#233;es de DATAtourisme pour le d&#233;partement des Ardennes (plus de 2500 points d'int&#233;r&#234;t), ainsi que quelques documents historiques et culturels pertinents.&lt;br class='autobr' /&gt;
.&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;Dans l'&#233;tat actuel du d&#233;veloppement, toutes les erreurs ne sont pas signal&#233;es par chat_error. C'est notamment le cas des dysfonctionnements internes signal&#233;s par une valeur de retour http_code = 500 ou des erreurs du groupe 4. Un test de la valeur de retour HTTP code = 200 est donc la meilleure fa&#231;on de s'assurer qu'il n'y a pas d'erreur.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
		</content:encoded>


		

	</item>



</channel>

</rss>
