profoundjs 7.6.0 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/htdocs/profoundui/proddata/css/logic.css +5 -0
- package/htdocs/profoundui/proddata/js/designer.js +4012 -3974
- package/htdocs/profoundui/proddata/js/profoundai.js +20 -19
- package/htdocs/profoundui/proddata/js/runtime.js +1098 -1092
- package/package.json +2 -2
- package/profound.jse +1 -1
- package/setup/pjsdist.savf +0 -0
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
if(!window.profound)window.profound={};window.profound.ai||(window.profound.ai={});
|
|
2
2
|
profound.ai.Chat=function(){function g(){if(window.pui&&window.pui.ide&&window.pui.ide.designerId)return true;return false}function o(){var a=Ext.e("centerPanel").d(),f={};if(a.isAIAgent&&a.aiAgent)f.aiAgent=a.aiAgent;if(a.isAIAgent&&a.dataAccess)f.dataAccess=a.dataAccess;Object.assign(f,Object.fromEntries(Object.entries(a.pjsModule).filter(function(c){return typeof c[1]!=="function"})));return f}function l(){function a(){var c=j.lastChild.querySelectorAll(".pai-chart");if(c.length!==0)if(profound.ai.a){for(var d=
|
|
3
|
-
0;d<c.length;d++){var e=c[d],n=JSON.parse(e.getAttribute("data-config"));e.removeAttribute("data-config");e.chart=new window.Chart(e.querySelector("canvas"),n);e=e.querySelector("span");e.parentNode.removeChild(e)}j.scrollTop=j.scrollHeight}else{f++;f<20&&setTimeout(a,1E3)}}var f=0;a()}function m(a){function f(){a.
|
|
4
|
-
b.add({message:"Error: "+
|
|
5
|
-
window.define;window.define=undefined;profound.ai.b(H,function(){window.define=M;profound.ai.a=true})}e=
|
|
6
|
-
if(a.runId)C=a.runId;if(a.modelKey)F=a.modelKey;if(a.message){var c=a.message,d="agent-response";if(a.status==="error"){c="Error: "+c;d="error"}if(a.status==="failed"){c="Failed: "+c;d="error"}if(a.status==="cancelled"){c="Cancelled";d="error"}if(a.status==="expired"){c="Chat Expired";d="error"}if(a.charts){if(!profound.ai.a){var e=
|
|
7
|
-
JSON.stringify(n[
|
|
8
|
-
"string")return a;if(a.length!==7)return a;if(a.substring(0,1)!=="#")return a;var c=parseInt(a.substring(1,3),16),d=parseInt(a.substring(3,5),16),e=parseInt(a.substring(5,7),16);c=parseInt(c*(100+f)/100);d=parseInt(d*(100+f)/100);e=parseInt(e*(100+f)/100);c=c<255?c:255;d=d<255?d:255;e=e<255?e:255;return"#"+(c.toString(16).length==1?"0"+
|
|
9
|
-
|
|
10
|
-
"Send a message...");if(a.heading)b.heading=a.heading;if(a.greeting)b.greeting=a.greeting;if(a.agent)b.agent=a.agent;if(a.pollInterval)J=a.pollInterval;if(a.loaderMessage)L=a.defaultLoaderMessage;if(a.server)A=a.server;if(a.data)b.data=a.data;if(a.stream)
|
|
11
|
-
|
|
12
|
-
z.classList.add("pai-prompt-area");k=document.createElement("textarea");k.classList.add("pai-prompt-box");k.setAttribute("placeholder",a.promptPlaceHolder);k.addEventListener("keydown",function(d){if(d.key==="Enter"){d.shiftKey||d.preventDefault();d.stopPropagation();d.shiftKey||b.send()}D()});k.addEventListener("input",function(){K();D()});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
body:JSON.stringify(a)}).then(function(
|
|
21
|
-
|
|
3
|
+
0;d<c.length;d++){var e=c[d],n=JSON.parse(e.getAttribute("data-config"));e.removeAttribute("data-config");e.chart=new window.Chart(e.querySelector("canvas"),n);e=e.querySelector("span");e.parentNode.removeChild(e)}j.scrollTop=j.scrollHeight}else{f++;f<20&&setTimeout(a,1E3)}}var f=0;a()}function m(a){function f(){a.read().then(function(n){var i=n.value;if(n.done){b.hideLoader();l()}else{n=c.decode(i).split("\n");for(i=0;i<n.length-1;i++){var h=n[i];if(h){h=JSON.parse(h);if(h.threadId)t=h.threadId;
|
|
4
|
+
if(h.status==="error"){b.hideLoader();b.add({message:"Error: "+h.message,type:"error"});return}if(h.status==="calling"){var p=j.lastChild;h=p.innerHTML.replace(u,"")+'<p>Calling <span class="pai-function-name">'+h["function"]+"</span>.</p>";b.add({message:h+u,type:"agent-response",replace:true})}else if(h.status==="calls completed"){p=j.lastChild;var y="<p>";y+=h.count===1?"Call completed.":h.count+" calls completed.";y+="</p>";y=p.innerHTML.replace(u,"")+y;b.add({message:y+u,type:"agent-response",
|
|
5
|
+
replace:true})}else{if(h.status==="file")d=d.replace(h.placeholderUrl,h.fileUrl);d+=h.text;if(h.charts){if(!profound.ai.a){var M=window.define;window.define=undefined;profound.ai.b(H,function(){window.define=M;profound.ai.a=true})}e=h.charts}if(e)for(var I in e)d=d.replace(I,'<div class="pai-chart" data-config="'+JSON.stringify(e[I]).replace(/"/g,""")+'"><span>Loading chart...</span><canvas></canvas></div>');p=d&&typeof window.marked==="function"?window.marked(d+u):d+u;if(h.status==="citation")p=
|
|
6
|
+
p.replace(h.citationPlaceholder,h.citationContent);b.add({message:p,type:"agent-response",replace:true})}}}f()}})}var c=new TextDecoder("utf-8"),d="",e;f()}function x(a){var f=a.status;if(a.threadId)t=a.threadId;if(a.runId)C=a.runId;if(a.modelKey)F=a.modelKey;if(a.message){var c=a.message,d="agent-response";if(a.status==="error"){c="Error: "+c;d="error"}if(a.status==="failed"){c="Failed: "+c;d="error"}if(a.status==="cancelled"){c="Cancelled";d="error"}if(a.status==="expired"){c="Chat Expired";d="error"}if(a.charts){if(!profound.ai.a){var e=
|
|
7
|
+
window.define;window.define=undefined;profound.ai.b(H,function(){window.define=e;profound.ai.a=true})}var n=a.charts;for(var i in n)c=c.replace(i,'<div class="pai-chart" data-config="'+JSON.stringify(n[i]).replace(/"/g,""")+'"><span>Loading chart...</span><canvas></canvas></div>')}b.add({message:c,type:d});a.charts&&l()}f==="queued"||f==="in_progress"?setTimeout(function(){b.poll()},J):b.hideLoader()}function D(){k.value===""||b.isLoading()?q.classList.remove("pai-send-button-active"):q.classList.add("pai-send-button-active")}
|
|
8
|
+
function K(){k.style.height="1px";var a=k.scrollHeight;if(a>100)a=100;j.style.height="calc(100% - "+(a+54)+"px)";k.style.height=a+"px"}function N(a,f){if(typeof a!=="string")return a;if(a.length!==7)return a;if(a.substring(0,1)!=="#")return a;var c=parseInt(a.substring(1,3),16),d=parseInt(a.substring(3,5),16),e=parseInt(a.substring(5,7),16);c=parseInt(c*(100+f)/100);d=parseInt(d*(100+f)/100);e=parseInt(e*(100+f)/100);c=c<255?c:255;d=d<255?d:255;e=e<255?e:255;return"#"+(c.toString(16).length==1?"0"+
|
|
9
|
+
c.toString(16):c.toString(16))+(d.toString(16).length==1?"0"+d.toString(16):d.toString(16))+(e.toString(16).length==1?"0"+e.toString(16):e.toString(16))}var b=this,r=null,j=null,z=null,k=null,q=null,t=null,C=null,F=null,J=1E3,v=null,E=null,L="Thinking",A="",B="light",w=null,s=false,u='<span class="pai-loader-dot pai-inline-loader"></span>',H="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",G=null;this.init=function(a){a||(a={});if(!a.container)a.container=document.body;a.closeButton||
|
|
10
|
+
(a.closeButton=true);a.closeTitle||(a.closeTitle="Close this conversation");a.sendTitle||(a.sendTitle="Send this message");a.promptPlaceHolder||(a.promptPlaceHolder="Send a message...");if(a.heading)b.heading=a.heading;if(a.greeting)b.greeting=a.greeting;if(a.agent)b.agent=a.agent;if(a.pollInterval)J=a.pollInterval;if(a.loaderMessage)L=a.defaultLoaderMessage;if(a.server)A=a.server;if(a.data)b.data=a.data;if(a.stream)s=a.stream;if(a.jwt)G=a.jwt;b.dom=document.createElement("div");b.dom.classList.add("pai-chat");
|
|
11
|
+
b.dom.classList.add("pai-hidden");a.container.appendChild(b.dom);if(a.closeButton){r=document.createElement("div");r.classList.add("pai-close-button");r.title=a.closeTitle;r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>';r.addEventListener("click",function(){b.onClose&&b.onClose();
|
|
12
|
+
g()?b.clear():b.hide()});b.dom.appendChild(r)}j=document.createElement("div");j.classList.add("pai-messages");b.dom.appendChild(j);z=document.createElement("div");z.classList.add("pai-prompt-area");k=document.createElement("textarea");k.classList.add("pai-prompt-box");k.setAttribute("placeholder",a.promptPlaceHolder);k.addEventListener("keydown",function(d){if(d.key==="Enter"){d.shiftKey||d.preventDefault();d.stopPropagation();d.shiftKey||b.send()}D()});k.addEventListener("input",function(){K();D()});
|
|
13
|
+
z.appendChild(k);q=document.createElement("div");q.classList.add("pai-send-button");q.title=a.sendTitle;q.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z"/></svg>';q.addEventListener("click",function(){b.send()});z.appendChild(q);b.dom.appendChild(z);v=document.createElement("div");v.classList.add("pai-loader");E=document.createElement("span");
|
|
14
|
+
E.classList.add("pai-loader-message");v.appendChild(E);for(var f=1;f<=3;f++){var c=document.createElement("div");c.classList.add("pai-loader-dot");v.appendChild(c)}b.clear();a.theme&&b.setTheme(a.theme);a.brandColor&&b.setBrandColor(a.brandColor)};this.show=function(){b.dom.classList.remove("pai-hidden");k.focus()};this.hide=function(){b.dom.classList.add("pai-hidden")};this.add=function(a){var f=a.message,c=document.createElement("div");c.classList.add("pai-message");var d=a.type;d||(d="user-message");
|
|
15
|
+
c.classList.add("pai-"+d);if(d==="agent-response"){c.classList.add("markdown-body");if(A)f=f.replace(/<img src="\/profound-ai\/image\?file=/g,'<img src="'+A+"/profound-ai/image?file=");c.innerHTML=f;c.querySelectorAll("a").forEach(function(e){e.addEventListener("click",function(){pui.skipConfirm=true;setTimeout(function(){pui.skipConfirm=false},250)})});c.querySelectorAll("span.pai-citation").forEach(function(e){function n(){if(i&&!i.matches(":hover")){e.removeChild(i);i=null}}var i,h;e.addEventListener("mouseenter",
|
|
16
|
+
function(){if(!i)if(e.getAttribute("data-citation")){i=document.createElement("div");i.classList.add("pai-tooltip-content");i.innerHTML=e.getAttribute("data-citation");e.appendChild(i);var p=e.getBoundingClientRect();i.style.left=p.left+"px";i.style.top=p.top-i.offsetHeight-5+"px";i.addEventListener("mouseenter",function(){clearTimeout(h)});i.addEventListener("mouseleave",function(){n()})}});e.addEventListener("mouseleave",function(){h=setTimeout(n,100)})});if(a.replace)(a=j.lastChild)&&a.classList.contains("pai-agent-response")&&
|
|
17
|
+
a.parentNode.removeChild(a)}else c.innerText=f;j.appendChild(c);j.scrollTop=j.scrollHeight};this.clear=function(){j.innerHTML="";b.heading&&b.add({message:b.heading,type:"heading"});b.greeting&&b.add({message:b.greeting,type:"greeting"});b.setBrandColor(w);C=t=null};this.setTheme=function(a){B=a;B=typeof B!=="string"?"light":B.toLowerCase();B==="dark"?b.dom.classList.add("pai-dark"):b.dom.classList.remove("pai-dark")};this.setBrandColor=function(a){w=a;if(a=b.dom.querySelector(".pai-heading")){a.style.backgroundColor=
|
|
18
|
+
null;a.style.backgroundImage=null;a.classList.remove("pai-branded")}r&&r.classList.remove("pai-branded");q.style.backgroundColor=null;if(w){var f=N(w,-30);if(a){a.style.backgroundColor=w;a.style.backgroundImage="linear-gradient(to right, "+w+", "+f+")";a.classList.add("pai-branded")}r&&a&&r.classList.add("pai-branded");q.style.backgroundColor=w}};this.send=function(){if(k.value!=="")if(!b.isLoading()){b.onSend&&b.onSend(k.value);b.add({message:k.value});var a={};a.message=k.value;if(t)a.threadId=
|
|
19
|
+
t;var f="/profound-ai/chat";if(g()){a.agentData=o();a.agentFile=Ext.e("centerPanel").d().title.replace(/\*/g,"").trim();s=pui.streamingModelList.includes(a.agentData.aiAgent.model);f="/ide/profound-ai/chat"}else a.agent=b.agent;var c=b.data;if(typeof c==="function")c=c();if(b.data)a.data=c;k.value="";K();k.focus();b.showLoader();c={"Content-Type":"application/json"};if(s){c.Connection="keep-alive";c["Response-Type"]="stream"}if(G){var d=G;if(typeof d==="function")d=d();c.Authorization="Bearer "+d}fetch(A+
|
|
20
|
+
f,{method:"POST",headers:c,body:JSON.stringify(a)}).then(function(e){return s?e.body.getReader():e.json()}).then(function(e){s?m(e):x(e)})["catch"](function(e){b.hideLoader();b.add({message:"Error: "+e.message,type:"error"})})}};this.poll=function(){if(!(!t||!C||!F)){var a={};a.threadId=t;a.runId=C;a.modelKey=F;var f="/profound-ai/poll";if(g())f="/ide/profound-ai/poll";fetch(A+f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(function(c){return c.json()}).then(function(c){x(c)})["catch"](function(c){b.hideLoader();
|
|
21
|
+
b.add({message:"Error: "+c.message,type:"error"})})}};this.showLoader=function(a){a||(a=L);E.innerText=a;if(!b.isLoading()){s?b.add({message:u,type:"agent-response"}):j.appendChild(v);D()}j.scrollTop=j.scrollHeight};this.hideLoader=function(){if(b.isLoading()){if(s)for(var a=j.querySelectorAll(".pai-inline-loader"),f=a.length-1;f>=0;f--)a[f].parentNode.removeChild(a[f]);else j.removeChild(v);D()}};this.isLoading=function(){if(s)return j.querySelectorAll(".pai-inline-loader").length>0;return v.parentNode===
|
|
22
|
+
j};this.destroy=function(){if(b.dom){b.dom.parentNode.removeChild(b.dom);b.dom=null}};this.removeEmbedIcon=function(){profound.ai.removeEmbedIcon()}};profound.ai.c=function(g){if(!document.querySelector('link[href="'+g+'"]')){var o=document.createElement("link");o.rel="stylesheet";o.href=g;document.head.appendChild(o)}};
|
|
22
23
|
profound.ai.b=function(g,o){if(document.querySelector('script[src="'+g+'"]'))typeof o==="function"&&o();else{var l=document.createElement("script");l.type="text/javascript";l.src=g;l.onload=function(){typeof o==="function"&&o()};document.head.appendChild(l)}};
|
|
23
24
|
profound.ai.startAgent=function(g,o){g||(g={});var l="";if(g.server)l=g.server;if(!o&&g.agent)fetch(l+"/profound-ai/attributes",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:g.agent})}).then(function(m){return m.json()}).then(function(m){if(m.status==="error")throw Error(m.message);m=m.attributes;for(var x in m)if(g[x]===undefined)g[x]=m[x];profound.ai.startAgent(g,true)})["catch"](function(m){throw Error("Unable to start AI Agent: "+m.message);});else{if(!g.container)g.container=
|
|
24
25
|
document.body;g.stream&&profound.ai.b(l+"/marked/marked.min.js");profound.ai.c(l+"/profoundui/proddata/css/markdown.css");profound.ai.c(l+"/profoundui/proddata/css/profoundai.css");profound.ai.agent&&profound.ai.agent.destroy();if(g.embed){if(!profound.ai.embedIcon){profound.ai.embedIcon=document.createElement("div");profound.ai.embedIcon.classList.add("pai-embed-icon");profound.ai.embedIcon.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M21 6h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1zm-4 6V3c0-.55-.45-1-1-1H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1z"/></svg>';
|