PageSourceSearch

https://www.ilassur.fr/assets/SettingsPage-d0a6f801.js

js ilassur.fr collected 2026-09-25 22:31:12 UTC 12,224 bytes, 1 lines download raw bytes

1import{G as e,r as p}from"./vendor-9aa0039e.js";import{C as L,B as T}from"./seo-templates-6f8c3622.js";import{I as m}from"./Input-219a73be.js";import{S as f}from"./Select-8845449e.js";import"./AppContext-cdb3a4f1.js";import{u as I}from"./CrmApp-714fc336.js";import"./realtime-9d95d988.js";import"./helmet-1a5b5a98.js";import"./network-0d55e701.js";import"./seo-local-data-04ba360a.js";import"./seo-city-profiles-08a5ed0c.js";import"./index-34e8a738.js";import"./crmApi-ddd9bde6.js";const i=({children:n,className:x="",...d})=>e.jsx("label",{className:`block text-sm font-medium text-slate-700 dark:text-white/80 ${x}`,...d,children:n}),Y=()=>{const{user:n,isAuthenticated:x}=I(),d="Accès réservé aux managers/admin.",[l,u]=p.useState(null),[N,b]=p.useState([]),[M,g]=p.useState(!0),[y,E]=p.useState(!1),[v,c]=p.useState(null),[w,P]=p.useState(null),j="w-full rounded-2xl border border-white/60 bg-white/70 px-4 py-2 text-sm text-slate-700 shadow-[0_8px_24px_rgba(15,23,42,0.05)] focus:outline-none focus:ring-2 focus:ring-cyan-300/70",_=t=>({id:t.id!==void 0&&t.id!==null?Number(t.id):null,modele_courant:t.modele_courant??"",provider:t.provider??"ollama",api_type:t.api_type??t.provider??"ollama",vertex_project_id:t.vertex_project_id??"",vertex_location:t.vertex_location??"",vertex_endpoint:t.vertex_endpoint??"",llm_num_ctx:Number(t.llm_num_ctx??750),llm_num_predict:Number(t.llm_num_predict??80),llm_temperature:Number(t.llm_temperature??.2),llm_top_k:Number(t.llm_top_k??10),llm_top_p:Number(t.llm_top_p??.5),llm_repeat_penalty:Number(t.llm_repeat_penalty??1),is_active:!!(t.is_active??!1)}),h="/crm/backend/crm_settings.php",S=async()=>{try{const t=await fetch(`${h}?action=get_available_models`,{credentials:"include",headers:{Accept:"application/json"}});if(!t.ok){const a=await t.json().catch(()=>null);throw new Error((a==null?void 0:a.error)||`HTTP error! status: ${t.status}`)}const s=await t.json();b(s.data||[])}catch{b(["gemma-3-12b","llama-3.1-8b","mistral-7b","qwen2.5:1.5b"])}};p.useEffect(()=>{const t=(n==null?void 0:n.role)==="manager"||(n==null?void 0:n.role)==="admin";if(!x||!t){g(!1);return}A(),S()},[x,n]);const C=async t=>{if(!t){u(_({id:null,modele_courant:"",provider:"ollama",api_type:"ollama",vertex_project_id:"",vertex_location:"",vertex_endpoint:"",llm_num_ctx:750,llm_num_predict:80,llm_temperature:.2,llm_top_k:10,llm_top_p:.5,llm_repeat_penalty:1,is_active:!1}));return}try{const s=await fetch(`${h}?action=get_model&model_name=${encodeURIComponent(t)}`,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok){const r=await s.json().catch(()=>null);throw new Error((r==null?void 0:r.error)||`HTTP error! status: ${s.status}`)}const a=await s.json();a.success&&a.data?u(_(a.data)):c("Erreur lors du chargement du modèle sélectionné")}catch(s){c(s instanceof Error?s.message:"Erreur lors du chargement du modèle")}},A=async()=>{var t;try{g(!0),c(null);const s=await fetch(h,{credentials:"include",headers:{Accept:"application/json"}});if(!s.ok){const r=await s.json().catch(()=>null);throw new Error((r==null?void 0:r.error)||`HTTP error! status: ${s.status}`)}const a=await s.json();u(_(a))}catch(s){let a=s instanceof Error?s.message:"Erreur lors du chargement des paramètres";if(s instanceof Error)try{const r=JSON.parse(s.message);(r==null?void 0:r.error)==="FORBIDDEN"||(t=r==null?void 0:r.message)!=null&&t.includes("Permissions insuffisantes")?a=d:r!=null&&r.message&&(a=r.message)}catch{(s.message.includes("FORBIDDEN")||s.message.includes("Permissions insuffisantes"))&&(a=d)}c(a)}finally{g(!1)}},k=async()=>{var t;if(l)try{if(E(!0),c(null),P(null),l.llm_num_ctx<1||l.llm_num_ctx>32768){c("LLM_NUM_CTX doit être entre 1 et 32768");return}if(l.llm_num_predict<1||l.llm_num_predict>2048){c("LLM_NUM_PREDICT doit être entre 1 et 2048");return}if(l.llm_temperature<0||l.llm_temperature>2){c("LLM_TEMPERATURE doit être entre 0 et 2");return}if(l.llm_top_k<1||l.llm_top_k>100){c("LLM_TOP_K doit être entre 1 et 100");return}if(l.llm_top_p<0||l.llm_top_p>1){c("LLM_TOP_P doit être entre 0 et 1");return}if(l.llm_repeat_penalty<0||l.llm_repeat_penalty>2){c("LLM_REPEAT_PENALTY doit être entre 0 et 2");return}const s=await fetch(h,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(l)});if(!s.ok){const r=await s.json();throw new Error(r.error||`HTTP error! status: ${s.status}`)}const a=await s.json();a!=null&&a.settings&&u(_(a.settings)),P(a.message||"Paramètres sauvegardés avec succès !")}catch(s){let a=s instanceof Error?s.message:"Erreur lors de la sauvegarde";if(s instanceof Error)try{const r=JSON.parse(s.message);(r==null?void 0:r.error)==="FORBIDDEN"||(t=r==null?void 0:r.message)!=null&&t.includes("Permissions insuffisantes")?a=d:r!=null&&r.message&&(a=r.message)}catch{(s.message.includes("FORBIDDEN")||s.message.includes("Permissions insuffisantes"))&&(a=d)}c(a)}finally{E(!1)}},o=(t,s)=>{l&&u({...l,[t]:s})},F=(n==null?void 0:n.role)==="manager"||(n==null?void 0:n.role)==="admin";return!x||!F?e.jsxs("div",{className:"rounded-2xl border border-amber-200/80 bg-amber-50/80 p-6 text-amber-900 shadow-[0_10px_30px_rgba(251,191,36,0.18)]",children:[e.jsx("p",{className:"font-semibold",children:"Accès restreint"}),e.jsx("p",{className:"text-sm text-amber-800",children:d})]}):M?e.jsx("div",{className:"space-y-6 text-slate-900",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"mb-6 h-8 w-1/4 rounded-full bg-white/60 border border-white/60"}),e.jsx("div",{className:"grid gap-6 md:grid-cols-2",children:Array.from({length:6}).map((t,s)=>e.jsx("div",{className:"h-20 rounded-2xl bg-white/60 border border-white/60"},s))})]})}):e.jsxs("div",{className:"space-y-6 text-slate-900",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl md:text-4xl leading-tight font-semibold text-slate-900",children:"Paramétrage du modèle de chat"}),e.jsx("p",{className:"mt-1 text-slate-500",children:"Configuration des paramètres LLM pour le chatbot"})]}),v&&e.jsx("div",{className:`rounded-2xl border p-4 shadow-[0_10px_30px_rgba(15,23,42,0.08)] ${v===d?"border-amber-200/80 bg-amber-50/80 text-amber-900":"border-rose-200/80 bg-rose-50/80 text-rose-700"}`,children:v}),w&&e.jsx("div",{className:"rounded-2xl border border-emerald-200/80 bg-emerald-50/80 p-4 text-emerald-700",children:w}),l&&e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(L,{className:"p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"model_name_input",children:"Nom du modèle"}),e.jsx(m,{id:"model_name_input",type:"text",value:l.modele_courant,onChange:t=>o("modele_courant",t.target.value),placeholder:"Entrez le nom du nouveau modèle",className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Tapez le nom du modèle (nouveau ou existant)"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"load_existing_model",children:"Charger un modèle existant"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{id:"load_existing_model",onChange:t=>C(t.target.value),className:`mt-1 flex-1 ${j}`,children:[e.jsx("option",{value:"",children:"-- Choisir un modèle à charger --"}),N.length>0&&N.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(T,{type:"button",onClick:()=>C(""),variant:"secondary",className:"mt-1",children:"Nouveau"})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Sélectionnez un modèle pour charger ses paramètres (le nom reste modifiable)"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"provider",children:"Provider"}
1),e.jsxs(f,{id:"provider",value:l.provider,onChange:t=>o("provider",t.target.value),className:`mt-1 w-full ${j}`,children:[e.jsx("option",{value:"ollama",children:"Ollama"}),e.jsx("option",{value:"google",children:"Google (Vertex/PaLM)"}),e.jsx("option",{value:"openai",children:"OpenAI"})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Fournisseur principal pour ce modèle."})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"api_type",children:"Type d'API"}),e.jsxs(f,{id:"api_type",value:l.api_type,onChange:t=>o("api_type",t.target.value),className:`mt-1 w-full ${j}`,children:[e.jsx("option",{value:"ollama",children:"Ollama (locale)"}),e.jsx("option",{value:"google",children:"Google Generative Language"}),e.jsx("option",{value:"vertex",children:"Vertex AI Inference"}),e.jsx("option",{value:"openai",children:"OpenAI"})]}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Sélectionnez l'API utilisée pour appeler le modèle."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"vertex_project_id",children:"Vertex project id"}),e.jsx(m,{id:"vertex_project_id",type:"text",value:l.vertex_project_id,onChange:t=>o("vertex_project_id",t.target.value),placeholder:"project-id (pour Vertex)",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"vertex_location",children:"Vertex location"}),e.jsx(m,{id:"vertex_location",type:"text",value:l.vertex_location,onChange:t=>o("vertex_location",t.target.value),placeholder:"us-central1, europe-west1 ...",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"vertex_endpoint",children:"Vertex endpoint (optionnel)"}),e.jsx(m,{id:"vertex_endpoint",type:"text",value:l.vertex_endpoint,onChange:t=>o("vertex_endpoint",t.target.value),placeholder:"custom endpoint si nécessaire",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_num_ctx",children:"LLM_NUM_CTX"}),e.jsx(m,{id:"llm_num_ctx",type:"number",min:1,max:32768,value:l.llm_num_ctx,onChange:t=>o("llm_num_ctx",parseInt(t.target.value,10)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Contexte maximum (1-32768)"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_num_predict",children:"LLM_NUM_PREDICT"}),e.jsx(m,{id:"llm_num_predict",type:"number",min:1,max:2048,value:l.llm_num_predict,onChange:t=>o("llm_num_predict",parseInt(t.target.value,10)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Nombre maximum de tokens à générer (1-2048)"})]})]})}),e.jsx(L,{className:"p-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_temperature",children:"LLM_TEMPERATURE"}),e.jsx(m,{id:"llm_temperature",type:"number",min:0,max:2,step:.1,value:l.llm_temperature,onChange:t=>o("llm_temperature",parseFloat(t.target.value)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Créativité (0-2, 0.2 recommandé)"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_top_k",children:"LLM_TOP_K"}),e.jsx(m,{id:"llm_top_k",type:"number",min:1,max:100,value:l.llm_top_k,onChange:t=>o("llm_top_k",parseInt(t.target.value,10)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Nombre de tokens candidats (1-100)"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_top_p",children:"LLM_TOP_P"}),e.jsx(m,{id:"llm_top_p",type:"number",min:0,max:1,step:.1,value:l.llm_top_p,onChange:t=>o("llm_top_p",parseFloat(t.target.value)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Probabilité cumulative (0-1)"})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"llm_repeat_penalty",children:"LLM_REPEAT_PENALTY"}),e.jsx(m,{id:"llm_repeat_penalty",type:"number",min:0,max:2,step:.1,value:l.llm_repeat_penalty,onChange:t=>o("llm_repeat_penalty",parseFloat(t.target.value)||0),className:"mt-1"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Pénalité de répétition (0-2)"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("input",{id:"is_active",type:"checkbox",checked:l.is_active||!1,onChange:t=>o("is_active",t.target.checked),className:"rounded border-cyan-200 text-cyan-600 focus:ring-cyan-300/70"}),e.jsx(i,{htmlFor:"is_active",className:"text-sm",children:"Modèle actif (utilisé par le chatbot)"})]})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(T,{onClick:k,disabled:y||!l,children:y?"Sauvegarde...":"Sauvegarder"})})]})};export{Y as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.