Files
igny8/frontend/dist/assets/js/Prompts-R_ZfvWlm.js
IGNY8 VPS (Salman) 3c100be1cf more
2025-11-13 14:12:36 +00:00

2 lines
9.8 KiB
JavaScript

import{j as e,r as f}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{u as w,T as k,P as N,g as P,B as p}from"./main-af3pcbZa.js";const v=({placeholder:n="Enter your message",rows:l=3,value:y="",onChange:u,className:b="",disabled:a=!1,error:d=!1,hint:c=""})=>{const x=g=>{u&&u(g.target.value)};let i=`w-full rounded-lg border px-4 py-2.5 text-sm shadow-theme-xs focus:outline-hidden ${b} `;return a?i+=" bg-gray-100 opacity-50 text-gray-500 border-gray-300 cursor-not-allowed opacity40 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700":d?i+=" bg-transparent border-gray-300 focus:border-error-300 focus:ring-3 focus:ring-error-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-error-800":i+=" bg-transparent text-gray-900 dark:text-gray-300 text-gray-900 border-gray-300 focus:border-brand-300 focus:ring-3 focus:ring-brand-500/10 dark:border-gray-700 dark:bg-gray-900 dark:text-white/90 dark:focus:border-brand-800",e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{placeholder:n,rows:l,value:y,onChange:x,disabled:a,className:i}),c&&e.jsx("p",{className:`mt-2 text-sm ${d?"text-error-500":"text-gray-500 dark:text-gray-400"}`,children:c})]})},h=[{key:"clustering",label:"Clustering Prompt",description:"Group keywords into topic clusters. Use [IGNY8_KEYWORDS] to inject keyword data.",icon:"🌐",color:"green"},{key:"ideas",label:"Ideas Generation Prompt",description:"Generate content ideas from clusters. Use [IGNY8_CLUSTERS] and [IGNY8_CLUSTER_KEYWORDS] to inject data.",icon:"💡",color:"amber"},{key:"content_generation",label:"Content Generation Prompt",description:"Generate content from ideas. Use [IGNY8_IDEA], [IGNY8_CLUSTER], and [IGNY8_KEYWORDS] to inject data.",icon:"📝",color:"blue"},{key:"image_prompt_extraction",label:"Image Prompt Extraction",description:"Extract image prompts from article content. Use {title}, {content}, {max_images} placeholders.",icon:"🔍",color:"indigo"},{key:"image_prompt_template",label:"Image Prompt Template",description:"Template for generating image prompts. Use {post_title}, {image_prompt}, {image_type} placeholders.",icon:"🖼️",color:"purple"},{key:"negative_prompt",label:"Negative Prompt",description:"Specify elements to avoid in generated images (text, watermarks, logos, etc.).",icon:"🚫",color:"red"}];function C(){const n=w(),[l,y]=f.useState({}),[u,b]=f.useState(!0),[a,d]=f.useState({});f.useEffect(()=>{c()},[]);const c=async()=>{b(!0);try{const r=h.map(async o=>{try{const m=await k(`/v1/system/prompts/by_type/${o.key}/`);return{key:o.key,data:m}}catch(m){return console.error(`Error loading prompt ${o.key}:`,m),{key:o.key,data:null}}}),t=await Promise.all(r),s={};t.forEach(({key:o,data:m})=>{var j;m?s[o]=m:s[o]={prompt_type:o,prompt_type_display:((j=h.find(_=>_.key===o))==null?void 0:j.label)||o,prompt_value:"",default_prompt:"",is_active:!0}}),y(s)}catch(r){console.error("Error loading prompts:",r),n.error("Failed to load prompts")}finally{b(!1)}},x=async r=>{const t=l[r];if(t){d({...a,[r]:!0});try{const s=await k("/v1/system/prompts/save/",{method:"POST",body:JSON.stringify({prompt_type:r,prompt_value:t.prompt_value})});if(s.success)n.success(s.message||"Prompt saved successfully"),await c();else throw new Error(s.error||"Failed to save prompt")}catch(s){console.error("Error saving prompt:",s),n.error(`Failed to save prompt: ${s.message}`)}finally{d({...a,[r]:!1})}}},i=async r=>{if(confirm("Are you sure you want to reset this prompt to default? This will overwrite any custom changes.")){d({...a,[r]:!0});try{const t=await k("/v1/system/prompts/reset/",{method:"POST",body:JSON.stringify({prompt_type:r})});if(t.success)n.success(t.message||"Prompt reset to default"),await c();else throw new Error(t.error||"Failed to reset prompt")}catch(t){console.error("Error resetting prompt:",t),n.error(`Failed to reset prompt: ${t.message}`)}finally{d({...a,[r]:!1})}}},g=(r,t)=>{y({...l,[r]:{...l[r],prompt_value:t}})};return u?e.jsxs(e.Fragment,{children:[e.jsx(N,{title:"Prompts - IGNY8",description:"AI prompts management"}),e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500 mx-auto"}),e.jsx("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:"Loading prompts..."})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{title:"Prompts - IGNY8",description:"AI prompts management"}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(P,{className:"text-primary-500 size-6"}),e.jsx("h1",{className:"text-2xl font-semibold text-gray-800 dark:text-white",children:"AI Prompts Management"})]}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for clustering, idea generation, content writing, and image generation"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Planner Prompts"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for clustering and idea generation"})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:h.filter(r=>["clustering","ideas"].includes(r.key)).map(r=>{const t=l[r.key]||{prompt_type:r.key,prompt_type_display:r.label,prompt_value:""};return e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:r.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:r.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(v,{value:t.prompt_value||"",onChange:s=>g(r.key,s),rows:12,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>x(r.key),disabled:a[r.key],className:"flex-1",variant:"solid",color:"primary",children:a[r.key]?"Saving...":"Save Prompt"}),e.jsx(p,{onClick:()=>i(r.key),disabled:a[r.key],variant:"outline",children:"Reset to Default"})]})]})]},r.key)})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Writer Prompts"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI prompt templates for content writing"})]}),e.jsx("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:h.filter(r=>r.key==="content_generation").map(r=>{const t=l[r.key]||{prompt_type:r.key,prompt_type_display:r.label,prompt_value:""};return e.jsxs("div",{children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:r.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:r.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(v,{value:t.prompt_value||"",onChange:s=>g(r.key,s),rows:15,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>x(r.key),disabled:a[r.key],className:"flex-1",variant:"solid",color:"primary",children:a[r.key]?"Saving...":"Save Prompt"}),e.jsx(p,{onClick:()=>i(r.key),disabled:a[r.key],variant:"outline",children:"Reset to Default"})]})]})]},r.key)})})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-800 dark:text-white mb-1",children:"Image Generation"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Configure AI image generation prompts"})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:h.filter(r=>["image_prompt_extraction","image_prompt_template","negative_prompt"].includes(r.key)).map(r=>{const t=l[r.key]||{prompt_type:r.key,prompt_type_display:r.label,prompt_value:""};return e.jsxs("div",{className:"rounded-2xl border border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-900",children:[e.jsx("div",{className:"p-5 border-b border-gray-200 dark:border-gray-800",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:r.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-white",children:r.label}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:r.description})]})]})})}),e.jsxs("div",{className:"p-5",children:[e.jsx(v,{value:t.prompt_value||"",onChange:s=>g(r.key,s),rows:r.key==="negative_prompt"?4:8,placeholder:"Enter prompt template...",className:"font-mono-custom text-sm"}),e.jsxs("div",{className:"flex gap-3 mt-4",children:[e.jsx(p,{onClick:()=>x(r.key),disabled:a[r.key],className:"flex-1",variant:"solid",color:"primary",children:a[r.key]?"Saving...":"Save Prompt"}),r.key==="image_prompt_template"&&e.jsx(p,{onClick:()=>i(r.key),disabled:a[r.key],variant:"outline",children:"Reset to Default"})]})]})]},r.key)})})]})]})]})}export{C as default};