Upload folder using huggingface_hub
Browse files- static/css/ragrqs.min.css +1 -1
- static/javascript/rag_cleaner.js +87 -167
- static/javascript/rag_mgr.js +187 -171
- static/javascript/rag_prompts.js +72 -8
- static/javascript/rag_rqs.js +3 -7
- static/javascript/rag_ui.js +15 -13
- static/javascript/ualog3.js +97 -0
- static/js/ragrqs.min.js +73 -41
- static/less/ualog3.less +69 -0
- static/ragrqs_.html +3 -2
static/css/ragrqs.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;background:#1a1a1a}details,main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:ButtonText dotted 1px}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}[hidden],template{display:none}a,body,button,div,html,input,label,li,p,span,table,td,ul{padding:0;margin:0;font-family:arial,verdana,Helvetica,sans-serif}.bb0{background:#daee59!important}.bb1{background:#5487fc!important}body{background:#1a1a1a;box-sizing:border-box;min-height:100vh;height:100vh;position:relative;padding:0;margin:0;overflow:hidden;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400}.spinner{z-index:1000;position:absolute;top:70vh;left:50vw;transform:translate(-50%,-50%);cursor:pointer;display:none;align-items:center}.spinner .pulse-icon{width:20px;height:20px;background-color:#ff8c00;border-radius:50%;animation:1.5s ease-in-out infinite pulse}.spinner .stop-message{margin-left:15px;background-color:inherit;color:#8f8a8a;padding:8px 15px;border-radius:10px;font-size:22px;font-weight:700;opacity:1;transition:opacity .3s}.spinner:hover .stop-message{color:#fff;background:#595959;opacity:1}@keyframes pulse{0%{transform:scale(.6);box-shadow:0 0 0 0 rgba(255,140,0,.7)}70%{transform:scale(1.4);box-shadow:0 0 0 20px rgba(255,140,0,0)}100%{transform:scale(.6);box-shadow:0 0 0 0 rgba(255,140,0,0)}}.show-spinner{display:flex}.upload{background-color:#1e1e1e;padding:0 2em 2em;margin:0;border-radius:4px;box-shadow:0 2px 4px rgba(0,0,0,.5);text-align:center}.upload h4{color:#fff;margin-bottom:1em}.upload form{display:flex;flex-direction:column;align-items:center}.upload form .file{background-color:#121212;border:1px solid #515151;color:#fff;padding:.5em;margin-bottom:1em;border-radius:4px;width:100%;box-sizing:border-box}.upload form .file::file-selector-button{background-color:#0a5f4e;color:#fff;border:none;padding:.5em 1em;border-radius:4px;cursor:pointer}.upload form .file::file-selector-button:hover{background-color:#053128}.upload form button{background-color:#0a5f4e;color:#fff;border:none;padding:.5em 1em;border-radius:4px;cursor:pointer;width:100%;box-sizing:border-box}.upload form button:hover{background-color:#053128}.upload .result{width:100%;background:#000;color:#fff;font-size:15px;font-weight:400;text-align:left}div.container{background:#1a1a1a;box-sizing:border-box;position:relative;top:5vh;left:0;height:95vh;margin:0;padding:0;transition:margin-left .5s;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;flex-wrap:nowrap;overflow-y:auto;overflow-x:auto}div.container div.item{box-sizing:border-box;min-height:50px;margin:0;padding:0}div.container div.item1{flex:5;padding:.5vh .5vw 10vh}div.container div.item1 .output-wrapper{background-color:#1a1a1a;border-radius:20px;position:relative;bottom:0;right:0;left:0;width:100%;height:100%;display:flex;flex-direction:row;align-items:flex-start}div.container div.item1 .output-wrapper .text-out{flex:1;box-sizing:border-box;background:#000;color:#fff;border:none;padding:2px;min-width:50vw;height:100%;border-radius:10px;overflow-y:auto;outline:0;box-shadow:0 0 0 2px #4d4d4d}div.container div.item1 .output-wrapper .text-out:hover{box-shadow:0 0 0 2px #17d2ad}div.container div.item1 .output-wrapper .text-out .pre-text{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:20px;line-height:1.6;padding:2px;margin:0;height:100%;box-sizing:border-box;overflow-y:scroll;scroll-behavior:smooth}div.container div.item1 .output-wrapper .text-out .pre-text.copied{background-color:#0d0d0d;color:#61eed2}div.container div.item1 .output-wrapper .text-out .div-text{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:20px;line-height:1.6;padding:2px;margin:0;height:100%;box-sizing:border-box;overflow-y:scroll}div.container div.item1 .output-wrapper .text-out.copied{background-color:#0d0d0d;color:#61eed2}div.container div.item1 .output-actions{display:flex;flex-direction:column;align-items:flex-end;margin-left:.5vw;margin-right:.5vw}div.container div.item1 .output-actions .clear-output,div.container div.item1 .output-actions .copy-output,div.container div.item1 .output-actions .wnd-output{box-sizing:border-box;background-color:#333;color:#fff;border:none;padding:10px;cursor:pointer;border-radius:50%;width:40px;height:40px;display:flex;align-items:center;margin-bottom:5px}div.container div.item1 .output-actions .clear-output:hover,div.container div.item1 .output-actions .copy-output:hover,div.container div.item1 .output-actions .wnd-output:hover{background-color:#595959}div.container div.item1 .output-actions .copy-output{transition:background-color .3s,transform .3s}div.container div.item1 .output-actions .copy-output.copied{background:#33e9c5;transform:scale(1.2)}div.container div.item1 .output-actions .copy-output .copy-icon{fill:#ffffff;width:24px;height:24px}div.container div.item1 .output-actions .copy-output .copy-icon:hover{fill:#33e9c5}div.container div.item1 .output-actions .clear-output,div.container div.item1 .output-actions .wnd-output{transition:background-color .3s,transform .3s}div.container div.item1 .output-actions .clear-output .icon,div.container div.item1 .output-actions .wnd-output .icon{fill:#ffffff;width:24px;height:24px}div.container div.item1 .output-actions .clear-output .icon:hover,div.container div.item1 .output-actions .wnd-output .icon:hover{fill:#33e9c5}:hover{outline:0;caret-color:transparent}textarea:focus{caret-color:auto}div.item2{flex:2;padding:0 .5vw}div.item2 .input-wrapper{background-color:#1a1a1a;border-radius:20px;position:relative;bottom:2vh;right:0;left:0;width:100%;height:100%;display:flex;flex-direction:row;align-items:flex-start}div.item2 .input-wrapper:focus-within .clear-button{display:block}div.item2 .input-wrapper .text-input{flex:1;font-size:20px;font-family:arial,verdana,Helvetica,sans-serif;resize:none;box-sizing:border-box;background:#000;color:#fff;border:none;padding:2px 40px 2px 2px;height:100%;margin-left:5px;border-radius:10px;overflow-y:auto;outline:0;box-shadow:0 0 0 2px #4d4d4d}div.item2 .input-wrapper .text-input:hover{box-shadow:0 0 0 2px #17d2ad}div.item2 .input-wrapper .text-input:focus{box-shadow:0 0 0 2px #ff4500}div.item2 .input-wrapper .clear-button{position:absolute;right:60px;top:19vh;padding:5px;border-radius:50%;background:#333;border:none;font-size:20px;cursor:pointer;color:#ccc;display:none}div.item2 .input-wrapper .clear-button:hover{font-weight:700;background:#595959;color:#fff}div.item2 .input-wrapper .input-actions{display:flex;flex-direction:column;margin-left:.5vw;margin-right:.5vw}div.item2 .input-wrapper .input-actions .clear-input,div.item2 .input-wrapper .input-actions .send-input,div.item2 .input-wrapper .input-actions .send2-input{box-sizing:border-box;background-color:#333;color:#fff;border:none;padding:10px;cursor:pointer;border-radius:50%;width:40px;height:40px;margin-bottom:5px;transition:background-color .3s}div.item2 .input-wrapper .input-actions .send-input{background:#992900}div.item2 .input-wrapper .input-actions .send-input:hover{background:#ff4500}div.item2 .input-wrapper .input-actions .send2-input{background:#0d7661}div.item2 .input-wrapper .input-actions .send2-input:hover{background:#14bb9a}div.item2 .input-wrapper .input-actions .clear-input{background:#333;color:#e6e6e6}div.item2 .input-wrapper .input-actions .clear-input:hover{background:#595959;color:#33e9c5}.menu-open .container{margin-left:16vw}.menu-open .menu-box{left:0!important}div.menu-h{background-color:#1a1a1a;position:fixed;top:0;left:0;width:100vw;height:4.5vh;padding:0;margin:0;outline:0;box-shadow:0 0 0 2px #4d4d4d;z-index:100}div.menu-h .release{background:inherit;color:#ff6a33;font-weight:700;margin-left:50vw;margin-top:.5vh}div.menu-h .menu-btn{appearance:none}div.menu-h .menu-btn:checked+.menu-icon{border:1px solid #333}div.menu-h .menu-btn:checked+.menu-icon .nav-icon{transform:rotate(45deg)}div.menu-h .menu-btn:checked+.menu-icon .nav-icon::before{top:0}div.menu-h .menu-btn:checked+.menu-icon .nav-icon::after{top:0;transform:rotate(90deg)}div.menu-h .menu-icon{box-sizing:border-box;background-color:inherit;display:block;position:absolute;margin-left:2vw;top:0;left:0;width:4vw;height:4.5vh;cursor:pointer;padding:2px;z-index:1}div.menu-h .menu-icon:hover .nav-icon,div.menu-h .menu-icon:hover .nav-icon::after,div.menu-h .menu-icon:hover .nav-icon::before{background-color:#33e9c5}div.menu-h .menu-icon .nav-icon{background-color:#aea7a7;display:block;position:absolute;top:14px;left:0;width:25px;height:2px;transition-duration:.25s}div.menu-h .menu-icon .nav-icon::after,div.menu-h .menu-icon .nav-icon::before{content:"";position:absolute;left:0;background-color:inherit;width:inherit;height:inherit}div.menu-h .menu-icon .nav-icon::before{top:-8px}div.menu-h .menu-icon .nav-icon::after{top:8px}div.menu-h .head-wrapper{position:absolute;top:0;left:5vw;height:4vh;padding:0;margin:0;display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;justify-content:flex-start}div.menu-h .head-wrapper .help,div.menu-h .head-wrapper .log,div.menu-h .head-wrapper .upload,div.menu-h .head-wrapper .upload-dir{margin-top:2px;margin-left:30px;margin-right:0;padding:5px 5px 0;border:none;cursor:pointer;border-radius:20%;font-size:20px;color:#fff;background:#333;max-height:4vh}div.menu-h .head-wrapper .help:hover,div.menu-h .head-wrapper .log:hover,div.menu-h .head-wrapper .upload-dir:hover,div.menu-h .head-wrapper .upload:hover{background:#595959}div.menu-h .upload,div.menu-h .upload-dir{transition:background-color .3s,transform .3s}div.menu-h .upload .icon,div.menu-h .upload-dir .icon{fill:#ffffff;width:24px;height:24px}div.menu-h .upload .icon:hover,div.menu-h .upload-dir .icon:hover{fill:#33e9c5}div.menu-h .log{font-size:14px!important;font-weight:400!important;background:#992900!important}div.menu-h .log:hover{background:#cc3700!important}div.menu-h .log.active{background:#0d7661!important}div.menu-h .log.active:hover{background:#12a487!important}div.menu-h div.menu-box{position:fixed;top:5vh;left:-2000px;height:95vh;width:16vw;transition:left .3s ease-out;padding:1vh 0 0 .5vw;z-index:101;background:#0d0d0d;box-sizing:border-box;outline:0;box-shadow:0 0 0 2px #4d4d4d;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:flex-start;align-items:stretch;overflow-y:auto;overflow-x:auto}div.menu-h div.menu-box ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;border-top:1px solid #333}div.menu-h div.menu-box ul li{border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333}div.menu-h div.menu-box ul li a{color:#fff;font-size:14px;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400;display:block;margin:0;padding:2px 2px 2px 0;text-align:left;text-decoration:none}div.menu-h div.menu-box ul li:hover{text-decoration:underline;background-color:#333;color:#33e9c5}div.menu-h div.menu-box ul a.delete{text-align:center;font-weight:700;font-style:italic;color:#000;background:#b3a80b}div.menu-h div.menu-box ul a.help{text-align:center;font-weight:700;font-style:italic;color:#000;background:#cc3700}div.menu-h div.menu-box ul li.show{background:#000;color:#fff;width:100%;text-align:center;box-sizing:border-box}div.menu-h div.menu-box ul li.show:hover{text-decoration:none}.window-text{position:relative;top:0;left:0;background:#1a1a1a;color:#fff;border:none;padding:0 2px 2px;width:78vw;height:80vh;border-radius:10px;box-sizing:border-box;outline:0;box-shadow:0 0 0 2px #b3a80b;overflow-y:auto}.window-text pre.pre-text{color:#f8f292;white-space:pre-wrap;word-wrap:break-word;font-family:Georigia,"Ties New Roman",serif;font-size:18px;line-height:1.6;padding:2px;margin:0;text-align:left}.window-text div.text{font-size:18px;font-weight:400;padding-left:10px;padding-right:10px;margin:0}.window-text div.text pre{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:18px;line-height:1.3;padding:0 5px;margin:0;text-align:left}.window-text div.text .center{text-align:center;font-size:18px;font-weight:700;text-decoration:underline;font-style:italic;color:#e3d50e}.window-text div.text .label{margin:5px 0 5px 10px;font-size:18px;font-weight:700;font-style:italic;color:#e3d50e}.window-text div.text div{font-family:arial,verdana,Helvetica,sans-serif;font-size:18px;font-weight:700;padding-top:0;padding-bottom:0}.window-text div.text div a{background:#000;color:#fff;font-weight:400}.window-text div.text div a:hover{background:#333;color:#fff}.window-text div.text p{font-size:18px;font-weight:400;font-family:arial,verdana,Helvetica,sans-serif;text-align:justify;padding-bottom:9px;padding-right:0;padding-left:10px}.btn-wrapper{width:100%;height:2vw;position:sticky;top:0;padding:0;background:#262626}.btn-wrapper .btn-copy{position:absolute;top:1px;right:5vw;box-sizing:border-box;background:inherit;color:#fff;border:none;cursor:pointer;width:30px;margin:0;padding:0;transition:background-color .3s}.btn-wrapper .btn-copy:hover{background-color:#595959}.btn-wrapper .btn-copy .copy-icon{fill:#e6e6e6;width:20px;height:20px}.btn-wrapper .btn-copy .copy-icon:hover{fill:#33e9c5;background:#404040}.btn-wrapper .btn-close{position:absolute;top:0;right:2vw;margin:0;background-color:transparent;border:none;color:#e6e6e6;font-size:22px;font-weight:700;cursor:pointer;outline:0}.btn-wrapper .btn-close:hover{color:#33e9c5;background:#404040}.msg{box-sizing:border-box;position:fixed;width:300px;height:100px;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#222;color:#ffeb3b;border:2px solid #ffeb3b;border-radius:15px;display:flex;align-items:center;justify-content:center;font-family:Arial,sans-serif;font-size:24px;font-weight:700;text-align:center;z-index:1000;box-shadow:0 4px 8px rgba(0,0,0,.2)}.alert,.confirm{background-color:#303030!important;color:#fff;padding:20px;border-radius:4px;box-shadow:0 2px 4px #00000033!important}.alert .button,.confirm .button{background-color:#37474f!important;color:#fff;border:none;padding:10px 20px;border-radius:4px;cursor:pointer;margin-top:20px}.alert .button:hover,.confirm .button:hover{background-color:#222c31}
|
|
|
1 |
+
a,body,button,div,html,input,label,li,p,span,table,td,ul{padding:0;margin:0;font-family:arial,verdana,Helvetica,sans-serif}.bb0{background:#daee59!important}.bb1{background:#5487fc!important}html{background:#1a1a1a}body{background:#1a1a1a;box-sizing:border-box;min-height:100vh;height:100vh;position:relative;padding:0;margin:0;overflow:hidden;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400}.spinner{z-index:1000;position:absolute;top:70vh;left:50vw;transform:translate(-50%,-50%);cursor:pointer;display:none;align-items:center}.spinner .pulse-icon{width:20px;height:20px;background-color:#ff8c00;border-radius:50%;animation:1.5s ease-in-out infinite pulse}.spinner .stop-message{margin-left:15px;background-color:inherit;color:#8f8a8a;padding:8px 15px;border-radius:10px;font-size:22px;font-weight:700;opacity:1;transition:opacity .3s}.spinner:hover .stop-message{color:#fff;background:#595959;opacity:1}@keyframes pulse{0%{transform:scale(.6);box-shadow:0 0 0 0 rgba(255,140,0,.7)}70%{transform:scale(1.4);box-shadow:0 0 0 20px rgba(255,140,0,0)}100%{transform:scale(.6);box-shadow:0 0 0 0 rgba(255,140,0,0)}}.show-spinner{display:flex}.upload{background-color:#1e1e1e;padding:0 2em 2em;margin:0;border-radius:4px;box-shadow:0 2px 4px rgba(0,0,0,.5);text-align:center}.upload h4{color:#fff;margin-bottom:1em}.upload form{display:flex;flex-direction:column;align-items:center}.upload form .file{background-color:#121212;border:1px solid #515151;color:#fff;padding:.5em;margin-bottom:1em;border-radius:4px;width:100%;box-sizing:border-box}.upload form .file::file-selector-button{background-color:#0a5f4e;color:#fff;border:none;padding:.5em 1em;border-radius:4px;cursor:pointer}.upload form .file::file-selector-button:hover{background-color:#053128}.upload form button{background-color:#0a5f4e;color:#fff;border:none;padding:.5em 1em;border-radius:4px;cursor:pointer;width:100%;box-sizing:border-box}.upload form button:hover{background-color:#053128}.upload .result{width:100%;background:#000;color:#fff;font-size:15px;font-weight:400;text-align:left}div.container{background:#1a1a1a;box-sizing:border-box;position:relative;top:5vh;left:0;height:95vh;margin:0;padding:0;transition:margin-left .5s;display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;flex-wrap:nowrap;overflow-y:auto;overflow-x:auto}div.container div.item{box-sizing:border-box;min-height:50px;margin:0;padding:0}div.container div.item1{flex:5;padding:.5vh .5vw 10vh}div.container div.item1 .output-wrapper{background-color:#1a1a1a;border-radius:20px;position:relative;bottom:0;right:0;left:0;width:100%;height:100%;display:flex;flex-direction:row;align-items:flex-start}div.container div.item1 .output-wrapper .text-out{flex:1;box-sizing:border-box;background:#000;color:#fff;border:none;padding:2px;min-width:50vw;height:100%;border-radius:10px;overflow-y:auto;outline:0;box-shadow:0 0 0 2px #4d4d4d}div.container div.item1 .output-wrapper .text-out:hover{box-shadow:0 0 0 2px #17d2ad}div.container div.item1 .output-wrapper .text-out .pre-text{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:20px;line-height:1.6;padding:2px;margin:0;height:100%;box-sizing:border-box;overflow-y:scroll;scroll-behavior:smooth}div.container div.item1 .output-wrapper .text-out .pre-text.copied{background-color:#0d0d0d;color:#61eed2}div.container div.item1 .output-wrapper .text-out .div-text{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:20px;line-height:1.6;padding:2px;margin:0;height:100%;box-sizing:border-box;overflow-y:scroll}div.container div.item1 .output-wrapper .text-out.copied{background-color:#0d0d0d;color:#61eed2}div.container div.item1 .output-actions{display:flex;flex-direction:column;align-items:flex-end;margin-left:.5vw;margin-right:.5vw}div.container div.item1 .output-actions .clear-output,div.container div.item1 .output-actions .copy-output,div.container div.item1 .output-actions .wnd-output{box-sizing:border-box;background-color:#333;color:#fff;border:none;padding:10px;cursor:pointer;border-radius:50%;width:40px;height:40px;display:flex;align-items:center;margin-bottom:5px}div.container div.item1 .output-actions .clear-output:hover,div.container div.item1 .output-actions .copy-output:hover,div.container div.item1 .output-actions .wnd-output:hover{background-color:#595959}div.container div.item1 .output-actions .copy-output{transition:background-color .3s,transform .3s}div.container div.item1 .output-actions .copy-output.copied{background:#33e9c5;transform:scale(1.2)}div.container div.item1 .output-actions .copy-output .copy-icon{fill:#ffffff;width:24px;height:24px}div.container div.item1 .output-actions .copy-output .copy-icon:hover{fill:#33e9c5}div.container div.item1 .output-actions .clear-output,div.container div.item1 .output-actions .wnd-output{transition:background-color .3s,transform .3s}div.container div.item1 .output-actions .clear-output .icon,div.container div.item1 .output-actions .wnd-output .icon{fill:#ffffff;width:24px;height:24px}div.container div.item1 .output-actions .clear-output .icon:hover,div.container div.item1 .output-actions .wnd-output .icon:hover{fill:#33e9c5}:hover{outline:0;caret-color:transparent}textarea:focus{caret-color:auto}div.item2{flex:2;padding:0 .5vw}div.item2 .input-wrapper{background-color:#1a1a1a;border-radius:20px;position:relative;bottom:2vh;right:0;left:0;width:100%;height:100%;display:flex;flex-direction:row;align-items:flex-start}div.item2 .input-wrapper:focus-within .clear-button{display:block}div.item2 .input-wrapper .text-input{flex:1;font-size:20px;font-family:arial,verdana,Helvetica,sans-serif;resize:none;box-sizing:border-box;background:#000;color:#fff;border:none;padding:2px 40px 2px 2px;height:100%;margin-left:5px;border-radius:10px;overflow-y:auto;outline:0;box-shadow:0 0 0 2px #4d4d4d}div.item2 .input-wrapper .text-input:hover{box-shadow:0 0 0 2px #17d2ad}div.item2 .input-wrapper .text-input:focus{box-shadow:0 0 0 2px #ff4500}div.item2 .input-wrapper .clear-button{position:absolute;right:60px;top:19vh;padding:5px;border-radius:50%;background:#333;border:none;font-size:20px;cursor:pointer;color:#ccc;display:none}div.item2 .input-wrapper .clear-button:hover{font-weight:700;background:#595959;color:#fff}div.item2 .input-wrapper .input-actions{display:flex;flex-direction:column;margin-left:.5vw;margin-right:.5vw}div.item2 .input-wrapper .input-actions .clear-input,div.item2 .input-wrapper .input-actions .send-input,div.item2 .input-wrapper .input-actions .send2-input{box-sizing:border-box;background-color:#333;color:#fff;border:none;padding:10px;cursor:pointer;border-radius:50%;width:40px;height:40px;margin-bottom:5px;transition:background-color .3s}div.item2 .input-wrapper .input-actions .send-input{background:#992900}div.item2 .input-wrapper .input-actions .send-input:hover{background:#ff4500}div.item2 .input-wrapper .input-actions .send2-input{background:#0d7661}div.item2 .input-wrapper .input-actions .send2-input:hover{background:#14bb9a}div.item2 .input-wrapper .input-actions .clear-input{background:#333;color:#e6e6e6}div.item2 .input-wrapper .input-actions .clear-input:hover{background:#595959;color:#33e9c5}.menu-open .container{margin-left:16vw}.menu-open .menu-box{left:0!important}div.menu-h{background-color:#1a1a1a;position:fixed;top:0;left:0;width:100vw;height:4.5vh;padding:0;margin:0;outline:0;box-shadow:0 0 0 2px #4d4d4d;z-index:100}div.menu-h .release{background:inherit;color:#ff6a33;font-weight:700;margin-left:50vw;margin-top:.5vh}div.menu-h .menu-btn{appearance:none}div.menu-h .menu-btn:checked+.menu-icon{border:1px solid #333}div.menu-h .menu-btn:checked+.menu-icon .nav-icon{transform:rotate(45deg)}div.menu-h .menu-btn:checked+.menu-icon .nav-icon::before{top:0}div.menu-h .menu-btn:checked+.menu-icon .nav-icon::after{top:0;transform:rotate(90deg)}div.menu-h .menu-icon{box-sizing:border-box;background-color:inherit;display:block;position:absolute;margin-left:2vw;top:0;left:0;width:4vw;height:4.5vh;cursor:pointer;padding:2px;z-index:1}div.menu-h .menu-icon:hover .nav-icon,div.menu-h .menu-icon:hover .nav-icon::after,div.menu-h .menu-icon:hover .nav-icon::before{background-color:#33e9c5}div.menu-h .menu-icon .nav-icon{background-color:#aea7a7;display:block;position:absolute;top:14px;left:0;width:25px;height:2px;transition-duration:.25s}div.menu-h .menu-icon .nav-icon::after,div.menu-h .menu-icon .nav-icon::before{content:"";position:absolute;left:0;background-color:inherit;width:inherit;height:inherit}div.menu-h .menu-icon .nav-icon::before{top:-8px}div.menu-h .menu-icon .nav-icon::after{top:8px}div.menu-h .head-wrapper{position:absolute;top:0;left:5vw;height:4vh;padding:0;margin:0;display:inline-flex;flex-direction:row;flex-wrap:nowrap;align-items:center;justify-content:flex-start}div.menu-h .head-wrapper .help,div.menu-h .head-wrapper .log,div.menu-h .head-wrapper .upload,div.menu-h .head-wrapper .upload-dir{margin-top:2px;margin-left:30px;margin-right:0;padding:5px 5px 0;border:none;cursor:pointer;border-radius:20%;font-size:20px;color:#fff;background:#333;max-height:4vh}div.menu-h .head-wrapper .help:hover,div.menu-h .head-wrapper .log:hover,div.menu-h .head-wrapper .upload-dir:hover,div.menu-h .head-wrapper .upload:hover{background:#595959}div.menu-h .upload,div.menu-h .upload-dir{transition:background-color .3s,transform .3s}div.menu-h .upload .icon,div.menu-h .upload-dir .icon{fill:#ffffff;width:24px;height:24px}div.menu-h .upload .icon:hover,div.menu-h .upload-dir .icon:hover{fill:#33e9c5}div.menu-h .log{font-size:14px!important;font-weight:400!important;background:#992900!important}div.menu-h .log:hover{background:#cc3700!important}div.menu-h .log.active{background:#0d7661!important}div.menu-h .log.active:hover{background:#12a487!important}div.menu-h div.menu-box{position:fixed;top:5vh;left:-2000px;height:95vh;width:16vw;transition:left .3s ease-out;padding:1vh 0 0 .5vw;z-index:101;background:#0d0d0d;box-sizing:border-box;outline:0;box-shadow:0 0 0 2px #4d4d4d;display:flex;flex-direction:column;flex-wrap:nowrap;justify-content:flex-start;align-items:stretch;overflow-y:auto;overflow-x:auto}div.menu-h div.menu-box ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;border-top:1px solid #333}div.menu-h div.menu-box ul li{border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333}div.menu-h div.menu-box ul li a{color:#fff;font-size:14px;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400;display:block;margin:0;padding:2px 2px 2px 0;text-align:left;text-decoration:none}div.menu-h div.menu-box ul li:hover{text-decoration:underline;background-color:#333;color:#33e9c5}div.menu-h div.menu-box ul a.delete{text-align:center;font-weight:700;font-style:italic;color:#000;background:#b3a80b}div.menu-h div.menu-box ul a.help{text-align:center;font-weight:700;font-style:italic;color:#000;background:#cc3700}div.menu-h div.menu-box ul li.show{background:#000;color:#fff;width:100%;text-align:center;box-sizing:border-box}div.menu-h div.menu-box ul li.show:hover{text-decoration:none}.window-text{position:relative;top:0;left:0;background:#1a1a1a;color:#fff;border:none;padding:0 2px 2px;width:78vw;height:80vh;border-radius:10px;box-sizing:border-box;outline:0;box-shadow:0 0 0 2px #b3a80b;overflow-y:auto}.window-text pre.pre-text{color:#f8f292;white-space:pre-wrap;word-wrap:break-word;font-family:Georigia,"Ties New Roman",serif;font-size:18px;line-height:1.6;padding:2px;margin:0;text-align:left}.window-text div.text{font-size:18px;font-weight:400;padding-left:10px;padding-right:10px;margin:0}.window-text div.text pre{white-space:pre-wrap;word-wrap:break-word;font-family:arial,verdana,Helvetica,sans-serif;font-size:18px;line-height:1.3;padding:0 5px;margin:0;text-align:left}.window-text div.text .center{text-align:center;font-size:18px;font-weight:700;text-decoration:underline;font-style:italic;color:#e3d50e}.window-text div.text .label{margin:5px 0 5px 10px;font-size:18px;font-weight:700;font-style:italic;color:#e3d50e}.window-text div.text div{font-family:arial,verdana,Helvetica,sans-serif;font-size:18px;font-weight:700;padding-top:0;padding-bottom:0}.window-text div.text div a{background:#000;color:#fff;font-weight:400}.window-text div.text div a:hover{background:#333;color:#fff}.window-text div.text p{font-size:18px;font-weight:400;font-family:arial,verdana,Helvetica,sans-serif;text-align:justify;padding-bottom:9px;padding-right:0;padding-left:10px}.btn-wrapper{width:100%;height:2vw;position:sticky;top:0;padding:0;background:#262626}.btn-wrapper .btn-copy{position:absolute;top:1px;right:5vw;box-sizing:border-box;background:inherit;color:#fff;border:none;cursor:pointer;width:30px;margin:0;padding:0;transition:background-color .3s}.btn-wrapper .btn-copy:hover{background-color:#595959}.btn-wrapper .btn-copy .copy-icon{fill:#e6e6e6;width:20px;height:20px}.btn-wrapper .btn-copy .copy-icon:hover{fill:#33e9c5;background:#404040}.btn-wrapper .btn-close{position:absolute;top:0;right:2vw;margin:0;background-color:transparent;border:none;color:#e6e6e6;font-size:22px;font-weight:700;cursor:pointer;outline:0}.btn-wrapper .btn-close:hover{color:#33e9c5;background:#404040}.msg{box-sizing:border-box;position:fixed;width:300px;height:100px;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#222;color:#ffeb3b;border:2px solid #ffeb3b;border-radius:15px;display:flex;align-items:center;justify-content:center;font-family:Arial,sans-serif;font-size:24px;font-weight:700;text-align:center;z-index:1000;box-shadow:0 4px 8px rgba(0,0,0,.2)}.alert,.confirm{background-color:#303030!important;color:#fff;padding:20px;border-radius:4px;box-shadow:0 2px 4px #00000033!important}.alert .button,.confirm .button{background-color:#37474f!important;color:#fff;border:none;padding:10px 20px;border-radius:4px;cursor:pointer;margin-top:20px}.alert .button:hover,.confirm .button:hover{background-color:#222c31}#ualog_{box-sizing:border-box;width:auto;height:auto;text-align:center;padding:2px;margin:2px 0 0;background:#333;color:#fff;font-size:16px;font-weight:400;border-radius:9px;border:1px solid #999}#ualog_ button{padding:5px;margin:0 5px;font-size:18px;font-weight:700;border:2px solid #999;border-radius:10px}#ualog_ button:hover{cursor:pointer;color:#000}#ualog_ button.close{background:#ff600a;color:#000}#ualog_ button.close:hover{background:#ffa270;text-decoration:underline}#ualog_ button.clear{background:#aeab06;color:#000}#ualog_ button.clear:hover{background:#f7f423;text-decoration:underline}#ualog_ pre{box-sizing:border-box;width:auto;min-width:400px;max-width:400px;max-height:500px;text-align:left;font-size:16px;font-family:monospace;padding:2px;margin:2px;color:#fff;background:#111;overflow:auto;scrollbar-color:#23eb04 #454444;scrollbar-width:auto;word-wrap:break-word}
|
static/javascript/rag_cleaner.js
CHANGED
@@ -1,191 +1,111 @@
|
|
1 |
/** @format */
|
2 |
|
3 |
-
// const removeChars = (txt) => {
|
4 |
-
// const charsRm = /[\u00AD\u200B\u200C\u200D\u2060\uFEFF]/g;
|
5 |
-
// txt = txt.replace(charsRm, "");
|
6 |
-
// return txt;
|
7 |
-
// };
|
8 |
-
|
9 |
-
// const replaceChars = (txt) => {
|
10 |
-
// const charsSrp = /[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g;
|
11 |
-
// txt = txt.replace(charsSrp, " ");
|
12 |
-
// txt = txt.replace(/ +/g, " ");
|
13 |
-
// return txt.trim();
|
14 |
-
// };
|
15 |
-
|
16 |
-
// const removeTag = (txt) => {
|
17 |
-
// txt = txt.replace(/<<<|>>>|<<|>>/g, "");
|
18 |
-
// return txt;
|
19 |
-
// };
|
20 |
-
|
21 |
-
// function cleanDoc(txt) {
|
22 |
-
// try {
|
23 |
-
// txt = removeTag(txt);
|
24 |
-
// txt = removeChars(txt);
|
25 |
-
// txt = replaceChars(txt);
|
26 |
-
// txt = txt.replace(/\n/g, " ");
|
27 |
-
// txt = txt.replace(/\t/g, " ");
|
28 |
-
// txt = txt.replace(/ +/g, " ");
|
29 |
-
// txt = txt.replace(/\n\s*\n/g, "\n");
|
30 |
-
// txt = txt.replace(/[“”]/g, '"');
|
31 |
-
// txt = txt.replace(/[‘’]/g, "'");
|
32 |
-
// txt = txt.replace(/[«»„“]/g, '"');
|
33 |
-
// txt = txt.replace(/[–—]/g, "-");
|
34 |
-
// txt = txt.replace(/\\[nrt]/g, "");
|
35 |
-
// txt = txt.replace(/[^\w\sàèéìòùÀÈÉÌÒÙáéíóúÁÉÍÓÚäëïöüÄËÏÖÜâêîôûÂÊÎÔÛçÇñÑ.,;:!?'"()-]/g, "");
|
36 |
-
// return txt.trim();
|
37 |
-
// } catch (e) {
|
38 |
-
// xerror(e);
|
39 |
-
// return "Errore di codifica nel documento";
|
40 |
-
// }
|
41 |
-
// }
|
42 |
-
|
43 |
-
// function cleanResponse(txt) {
|
44 |
-
// try {
|
45 |
-
// txt = removeChars(txt);
|
46 |
-
// txt = replaceChars(txt);
|
47 |
-
// txt = txt.replace(/\t/g, " ");
|
48 |
-
// txt = txt.replace(/ +/g, " ");
|
49 |
-
// txt = txt.replace(/\n\s*\n/g, "\n");
|
50 |
-
// txt = txt.replace(/[“”]/g, '"');
|
51 |
-
// txt = txt.replace(/[‘’]/g, "'");
|
52 |
-
// txt = txt.replace(/[«»„“]/g, '"');
|
53 |
-
// txt = txt.replace(/[–—]/g, "-");
|
54 |
-
// txt = txt.replace(/\\[nrt]/g, "");
|
55 |
-
// txt = txt.replace(/[^\w\sàèéìòùÀÈÉÌÒÙáéíóúÁÉÍÓÚäëïöüÄËÏÖÜâêîôûÂÊÎÔÛçÇñÑ.,;:!?'"()-]/g, "");
|
56 |
-
// return txt.trim();
|
57 |
-
// } catch (e) {
|
58 |
-
// xerror(e);
|
59 |
-
// return "Errore di codifica nela risposta";
|
60 |
-
// }
|
61 |
-
// ////////////////////////////////
|
62 |
const removeChars = (txt) => {
|
63 |
-
const
|
64 |
-
|
65 |
-
|
66 |
-
}
|
67 |
|
68 |
const replaceChars = (txt) => {
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
}
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
return txt;
|
78 |
-
}
|
79 |
|
80 |
-
|
81 |
-
try {
|
82 |
-
txt = removeTag(txt);
|
83 |
-
txt = removeChars(txt);
|
84 |
-
txt = replaceChars(txt);
|
85 |
-
// Removes multiple empty lines
|
86 |
-
txt = txt.replace(/\n\s*\n/g, '\n');
|
87 |
-
// Removes visible escape characters like \n, \r, \t
|
88 |
-
txt = txt.replace(/\t/g, ' ');
|
89 |
-
txt = txt.replace(/\r/g, ' ');
|
90 |
-
txt = txt.replace(/\n/g, ' ');
|
91 |
-
|
92 |
-
// Uniforms quotation characters
|
93 |
-
txt = txt.replace(/“/g, '"');
|
94 |
-
txt = txt.replace(/”/g, '"');
|
95 |
-
|
96 |
-
// Replaces long dashes with normal dashes
|
97 |
-
// txt = txt.replace(/–/g, '-');
|
98 |
-
// txt = txt.replace(/—/g, '-');
|
99 |
|
100 |
-
|
101 |
-
txt = txt.replace(/[^\w\sàèéìòùÀÈÉÌÒÙáéíóúÁÉÍÓÚäëïöüÄËÏÖÜâêîôûÂÊÎÔÛçÇñÑ.,;:!?'"()-]/g, '');
|
102 |
-
// Removes spaces before punctuation
|
103 |
-
txt = txt.replace(/ +([.,;:!?])/g, '$1');
|
104 |
-
// Removes multiple spaces
|
105 |
-
txt = txt.replace(/ +/g, ' ');
|
106 |
-
return txt.trim();
|
107 |
-
} catch (e) {
|
108 |
-
xerror(e);
|
109 |
-
return "Errore di codifica nella risposta";
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
function cleanResponse(txt) {
|
114 |
try {
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
// Removes spaces before punctuation
|
133 |
-
txt = txt.replace(/ +([.,;:!?])/g, '$1');
|
134 |
-
// Removes multiple spaces
|
135 |
-
txt = txt.replace(/ +/g, ' ');
|
136 |
-
return txt.trim();
|
137 |
} catch (e) {
|
138 |
-
|
139 |
-
|
140 |
}
|
141 |
-
}
|
142 |
|
143 |
-
|
144 |
-
function cleanOutput(txt) {
|
145 |
try {
|
146 |
txt = removeChars(txt);
|
147 |
txt = replaceChars(txt);
|
148 |
-
|
149 |
txt = txt.replace(/\n\s*\n/g, "\n");
|
150 |
-
//
|
151 |
-
|
152 |
-
//
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
txt = txt.replace(/ +/g, " ");
|
158 |
return txt.trim();
|
159 |
} catch (e) {
|
160 |
-
|
161 |
-
return "Errore di codifica
|
162 |
-
}
|
163 |
-
}
|
164 |
-
|
165 |
-
function list2text(docList) {
|
166 |
-
const docDict = {};
|
167 |
-
|
168 |
-
function getLabel(txt) {
|
169 |
-
const match = txt.match(/<<<(.*?)>>>/);
|
170 |
-
return match ? match[1] : null;
|
171 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
}
|
189 |
|
190 |
// <<<doc_name>>> => Documento: doc_name
|
191 |
function subResponseDOcTag(txt) {
|
|
|
1 |
/** @format */
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
const removeChars = (txt) => {
|
4 |
+
const charsRm = /[\u00AD\u200B\u200C\u200D\u2060\uFEFF]/g;
|
5 |
+
return txt.replace(charsRm, "");
|
6 |
+
};
|
|
|
7 |
|
8 |
const replaceChars = (txt) => {
|
9 |
+
const charsSrp = /[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g;
|
10 |
+
return txt.replace(charsSrp, " ");
|
11 |
+
};
|
|
|
12 |
|
13 |
+
const removeTag = (txt) => {
|
14 |
+
return txt.replace(/<<</g, "").replace(/>>>/g, "").replace(/<<|>>/g, "");
|
15 |
+
};
|
|
|
|
|
16 |
|
17 |
+
const ALLOWED_CHARS = /\w\sàèéìòùÀÈÉÌÒÙáéíóúÁÉÍÓÚäëïöüÄËÏÖÜâêîôûÂÊÎÔÛçÇñÑ.,;:!?\'"()-/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
const cleanDoc = (txt) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
try {
|
21 |
+
txt = removeTag(txt);
|
22 |
+
txt = removeChars(txt);
|
23 |
+
txt = replaceChars(txt);
|
24 |
+
// Rimuove linee vuote multiple
|
25 |
+
txt = txt.replace(/\n\s*\n/g, "\n");
|
26 |
+
// Rimuove caratteri di escape visibili come \n, \r, \t
|
27 |
+
txt = txt.replace(/[\t\r]/g, " ");
|
28 |
+
// Uniforma i caratteri di quotazione
|
29 |
+
txt = txt.replace(/“/g, '"').replace(/”/g, '"');
|
30 |
+
// Rimuove caratteri speciali non comuni mantenendo i caratteri accentati e punteggiatura
|
31 |
+
txt = txt.replace(new RegExp(`[^${ALLOWED_CHARS.source}]`, "g"), " ");
|
32 |
+
// Rimuove spazi prima della punteggiatura
|
33 |
+
txt = txt.replace(/ +([.,;:!?])/g, "$1");
|
34 |
+
// Rimuove spazi multipli
|
35 |
+
txt = txt.replace(/ +/g, " ");
|
36 |
+
return txt.trim();
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
} catch (e) {
|
38 |
+
console.error(e);
|
39 |
+
return "Errore di codifica nella risposta";
|
40 |
}
|
41 |
+
};
|
42 |
|
43 |
+
const cleanResponse = (txt) => {
|
|
|
44 |
try {
|
45 |
txt = removeChars(txt);
|
46 |
txt = replaceChars(txt);
|
47 |
+
// Rimuove linee vuote multiple
|
48 |
txt = txt.replace(/\n\s*\n/g, "\n");
|
49 |
+
// Rimuove caratteri di escape visibili come \n, \r, \t
|
50 |
+
txt = txt.replace(/[\t\r\n]/g, " ");
|
51 |
+
// Rimuove caratteri speciali non comuni mantenendo i caratteri accentati e punteggiatura
|
52 |
+
txt = txt.replace(new RegExp(`[^${ALLOWED_CHARS.source}]`, "g"), " ");
|
53 |
+
// Rimuove spazi prima della punteggiatura
|
54 |
+
txt = txt.replace(/ +([.,;:!?])/g, "$1");
|
55 |
+
// Rimuove spazi multipli
|
56 |
txt = txt.replace(/ +/g, " ");
|
57 |
return txt.trim();
|
58 |
} catch (e) {
|
59 |
+
console.error(e);
|
60 |
+
return "Errore di codifica nella risposta";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
+
};
|
63 |
+
|
64 |
+
const cleanOutput = (text) => {
|
65 |
+
txt = removeTag(txt);
|
66 |
+
// Rimuove gli spazi bianchi iniziali e finali
|
67 |
+
text = text.trim();
|
68 |
+
// Sostituisce le sequenze di più di due newline con due newline
|
69 |
+
text = text.replace(/\n{3,}/g, "\n\n");
|
70 |
+
// Rimuove gli spazi bianchi extra all'inizio di ogni riga
|
71 |
+
text = text.replace(/^\s+/gm, "");
|
72 |
+
// Formatta gli elenchi puntati per una migliore leggibilità
|
73 |
+
text = text.replace(/^(\s*[-*•])(\s*)/gm, "\n$1 ");
|
74 |
+
// Formatta gli elenchi numerati per una migliore leggibilità
|
75 |
+
text = text.replace(/^(\s*\d+\.)(\s*)/gm, "\n$1 ");
|
76 |
+
// Aggiunge una riga vuota prima e dopo i blocchi di codice
|
77 |
+
text = text.replace(/(```[\s\S]*?```)/g, "\n\n$1\n\n");
|
78 |
+
// Aggiunge un'andata a capo dopo ogni punto, eccetto quando seguito da newline o fine stringa
|
79 |
+
text = text.replace(/\.(?!\n|$)/g, ".\n");
|
80 |
+
// Rimuove gli spazi bianchi extra alla fine di ogni riga
|
81 |
+
text = text.replace(/\s+$/gm, "");
|
82 |
+
return text;
|
83 |
+
};
|
84 |
+
|
85 |
+
// function list2text(docList) {
|
86 |
+
// const docDict = {};
|
87 |
+
|
88 |
+
// function getLabel(txt) {
|
89 |
+
// const match = txt.match(/<<<(.*?)>>>/);
|
90 |
+
// return match ? match[1] : null;
|
91 |
+
// }
|
92 |
|
93 |
+
// for (let doc of docList) {
|
94 |
+
// const docName = getLabel(doc);
|
95 |
+
// // const content = doc.replace(/<<<.*?>>>/g, ''); //TODO
|
96 |
+
// const content = doc.replace(/<<<.*?>>>/, "");
|
97 |
+
// if (docName in docDict) {
|
98 |
+
// docDict[docName] += `\n ${content}`;
|
99 |
+
// } else {
|
100 |
+
// docDict[docName] = content;
|
101 |
+
// }
|
102 |
+
// }
|
103 |
+
// const lst = [];
|
104 |
+
// for (let [docName, content] of Object.entries(docDict)) {
|
105 |
+
// lst.push(`Documento: ${docName}.\n${content}`);
|
106 |
+
// }
|
107 |
+
// return lst.join("\n\n");
|
108 |
+
// }
|
109 |
|
110 |
// <<<doc_name>>> => Documento: doc_name
|
111 |
function subResponseDOcTag(txt) {
|
static/javascript/rag_mgr.js
CHANGED
@@ -22,6 +22,52 @@ const MAX_PROMPT_LENGTH = 1024 * 80;
|
|
22 |
// decremento dopo errore per tokens eccessivi
|
23 |
const PROMPT_DECR = 1024 * 2;
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
const Rag = {
|
26 |
// costituito dalla risposte accumulate sistemate
|
27 |
ragContext: "",
|
@@ -30,6 +76,7 @@ const Rag = {
|
|
30 |
// risposta finale alla qury contetso
|
31 |
ragResponse: "",
|
32 |
responses: [],
|
|
|
33 |
prompts: [],
|
34 |
doc: "",
|
35 |
doc_part: "",
|
@@ -59,250 +106,230 @@ const Rag = {
|
|
59 |
readRespsFromDb() {
|
60 |
this.responses = UaDb.readArray(ID_RESPONSES);
|
61 |
},
|
62 |
-
addPrompt(p) {
|
63 |
-
|
64 |
-
},
|
65 |
-
|
66 |
-
const rspsl = this.responses.reduce((acc, cur) => {
|
67 |
-
return acc + cur.length;
|
68 |
-
}, 0);
|
69 |
-
return rspsl;
|
70 |
-
},
|
71 |
-
ragLog(msg, lftLen, rgtLen) {
|
72 |
-
const maxl = MAX_PROMPT_LENGTH;
|
73 |
-
const rspsl = this.responsesLength();
|
74 |
-
const d = " ";
|
75 |
-
let s = `${msg} mx:${maxl} lft:${lftLen} rgt:${rgtLen} arr:${rspsl}`;
|
76 |
-
xlog(s);
|
77 |
-
s = `${msg}${d}${lftLen}${d}${rgtLen}${d}${rspsl}`;
|
78 |
-
//nsg plft.length prgt.length responses.length
|
79 |
-
UaLog.log(s);
|
80 |
-
},
|
81 |
-
truncInput(txt, decr) {
|
82 |
-
const tl = txt.length;
|
83 |
-
const lim = tl - decr;
|
84 |
-
const s = txt.substring(0, lim);
|
85 |
-
return s;
|
86 |
-
},
|
87 |
-
getPartSize(doc, prompt, decr) {
|
88 |
-
const limitWIthPoint = (s, free_len) => {
|
89 |
-
const idx = s.indexOf(".", free_len);
|
90 |
-
let lim = (idx != -1 ? idx : free_len) + 1;
|
91 |
-
if (lim > free_len + 100) {
|
92 |
-
lim = free_len;
|
93 |
-
}
|
94 |
-
return lim;
|
95 |
-
};
|
96 |
-
|
97 |
-
const dpl = doc.length + prompt.length;
|
98 |
-
const free_len = MAX_PROMPT_LENGTH - decr;
|
99 |
-
let size = 0;
|
100 |
-
if (dpl < free_len) {
|
101 |
-
size = doc.length;
|
102 |
-
} else {
|
103 |
-
size = limitWIthPoint(doc, free_len);
|
104 |
-
}
|
105 |
-
return size;
|
106 |
-
},
|
107 |
-
getPartDoc(pRgt, partSize) {
|
108 |
-
const pLft = pRgt.substring(0, partSize);
|
109 |
-
pRgt = pRgt.substring(partSize).trim();
|
110 |
-
return [pLft, pRgt];
|
111 |
-
},
|
112 |
-
// documenti => risposte RAG => context
|
113 |
async requestDocsRAG(query) {
|
114 |
DataMgr.deleteJsonDati();
|
115 |
DataMgr.readDbDocNames();
|
116 |
DataMgr.readDbDocs();
|
117 |
this.ragQuery = query;
|
118 |
let ndoc = 0;
|
119 |
-
|
120 |
try {
|
121 |
for (let i = 0; i < DataMgr.docs.length; i++) {
|
122 |
let doc = DataMgr.docs[i];
|
123 |
if (doc.trim() == "") continue;
|
124 |
-
const
|
125 |
const doc_entire_len = doc.length;
|
126 |
-
xlog(`${
|
127 |
-
UaLog.log(`${
|
128 |
-
|
129 |
++ndoc;
|
130 |
let npart = 0;
|
131 |
let decr = 0;
|
132 |
let prompt = "";
|
133 |
let lft = "";
|
134 |
let rgt = "";
|
|
|
|
|
135 |
|
136 |
while (true) {
|
137 |
-
let partSize =
|
138 |
if (partSize < 10) {
|
139 |
break;
|
140 |
}
|
141 |
-
[lft, rgt] =
|
142 |
-
|
143 |
-
prompt = promptDoc(lft, query);
|
144 |
const payload = getPayloadDoc(prompt);
|
145 |
-
let text;
|
146 |
try {
|
147 |
-
text = await HfRequest.post(payload);
|
148 |
if (!text) return "";
|
149 |
} catch (err) {
|
150 |
-
const
|
151 |
-
if (
|
152 |
-
UaLog.log(`Error tokens
|
153 |
-
|
154 |
decr += PROMPT_DECR;
|
155 |
continue;
|
156 |
} else {
|
157 |
-
|
158 |
-
|
159 |
-
throw s;
|
160 |
}
|
161 |
}
|
162 |
-
|
163 |
npart++;
|
164 |
doc = rgt;
|
165 |
-
text = cleanResponse(text);
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
} // end while
|
170 |
-
} // end for
|
171 |
-
} catch (error) {
|
172 |
-
alert("requestDocsRAG(1)\n" + error);
|
173 |
-
xerror(error);
|
174 |
-
}
|
175 |
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
this.saveToDb();
|
179 |
|
180 |
// query finale utilizza context
|
181 |
{
|
182 |
let text = "";
|
|
|
183 |
try {
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
|
|
|
|
199 |
}
|
|
|
200 |
}
|
|
|
201 |
this.ragResponse = text;
|
202 |
this.saveRespToDb();
|
203 |
ThreadMgr.init();
|
204 |
this.saveToDb();
|
205 |
const pl = prompt.length;
|
206 |
UaLog.log(`Risposta (${pl},${text.length})`);
|
207 |
-
} catch (
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
throw error;
|
212 |
} finally {
|
213 |
-
text = cleanOutput(text);
|
214 |
return text;
|
215 |
}
|
216 |
-
}
|
217 |
},
|
218 |
-
|
219 |
// thread
|
220 |
async requestContext(query) {
|
221 |
-
|
222 |
-
|
223 |
if (!this.ragContext) {
|
224 |
const ok = await confirm("Contesto vuoto. Vuoi continuare?");
|
225 |
if (!ok) return "";
|
226 |
}
|
227 |
-
|
228 |
if (ThreadMgr.isFirst()) {
|
229 |
-
|
230 |
-
ThreadMgr.init(); //AAA
|
231 |
try {
|
232 |
let context = this.ragContext;
|
233 |
-
|
234 |
-
prompt = promptThread(context, thread, query);
|
235 |
-
const payload = getPayloadThread(prompt);
|
236 |
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
252 |
}
|
|
|
253 |
ThreadMgr.add(query, text);
|
254 |
-
|
255 |
UaLog.log(`Inizio Conversazione (${prompt.length},${text.length})`);
|
256 |
-
} catch (
|
257 |
-
|
258 |
-
|
259 |
-
throw
|
260 |
} finally {
|
261 |
-
|
262 |
-
return outText;
|
263 |
}
|
264 |
} else {
|
265 |
-
let outText = "";
|
266 |
try {
|
267 |
let context = this.ragContext;
|
268 |
let thread = ThreadMgr.getThread();
|
269 |
let prompt = "";
|
270 |
-
let text = "";
|
271 |
-
let decr = 0;
|
272 |
-
|
273 |
while (true) {
|
274 |
-
thread = this.truncInput(thread, decr);
|
275 |
prompt = promptThread(context, thread, query);
|
276 |
const payload = getPayloadThread(prompt);
|
277 |
-
|
278 |
try {
|
279 |
-
text = await HfRequest.post(payload);
|
280 |
if (!text) return "";
|
281 |
} catch (err) {
|
282 |
-
const
|
283 |
-
if (
|
284 |
-
UaLog.log(`Error tokens
|
285 |
-
|
286 |
-
|
287 |
continue;
|
288 |
} else {
|
289 |
-
|
290 |
-
throw
|
291 |
}
|
292 |
}
|
293 |
break;
|
294 |
}
|
|
|
295 |
ThreadMgr.add(query, text);
|
296 |
-
|
297 |
UaLog.log(`Conversazione (${prompt.length},${text.length})`);
|
298 |
-
} catch (
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
throw error;
|
303 |
} finally {
|
304 |
-
|
305 |
-
return outText;
|
306 |
}
|
307 |
}
|
308 |
},
|
@@ -326,25 +353,14 @@ const ThreadMgr = {
|
|
326 |
this.rows.push(row);
|
327 |
UaDb.saveArray(ID_THREAD, ThreadMgr.rows);
|
328 |
},
|
329 |
-
getOutText() {
|
330 |
-
const rows = [];
|
331 |
-
for (const ua of this.rows) {
|
332 |
-
const u = ua[0].trim();
|
333 |
-
const a = ua[1].trim();
|
334 |
-
rows.push(`\n${USER}\n${u}\n${LLM}\n${a}\n\n`);
|
335 |
-
}
|
336 |
-
let text = rows.join("").trim();
|
337 |
-
return text;
|
338 |
-
},
|
339 |
getThread() {
|
340 |
const rows = [];
|
341 |
for (const ua of this.rows) {
|
342 |
-
const u = ua[0]
|
343 |
-
const a = ua[1]
|
344 |
-
rows.push(
|
345 |
}
|
346 |
-
|
347 |
-
return text;
|
348 |
},
|
349 |
isFirst() {
|
350 |
return this.rows.length < 2;
|
|
|
22 |
// decremento dopo errore per tokens eccessivi
|
23 |
const PROMPT_DECR = 1024 * 2;
|
24 |
|
25 |
+
const TIMEOUT = 60000;
|
26 |
+
|
27 |
+
const truncInput = (txt, decr) => {
|
28 |
+
const tl = txt.length;
|
29 |
+
const lim = tl - decr;
|
30 |
+
const s = txt.substring(0, lim);
|
31 |
+
return s;
|
32 |
+
};
|
33 |
+
|
34 |
+
const getPartSize = (doc, prompt, decr) => {
|
35 |
+
const limitWIthPoint = (s, free_len) => {
|
36 |
+
const idx = s.indexOf(".", free_len);
|
37 |
+
let lim = (idx != -1 ? idx : free_len) + 1;
|
38 |
+
if (lim > free_len + 100) {
|
39 |
+
lim = free_len;
|
40 |
+
}
|
41 |
+
return lim;
|
42 |
+
};
|
43 |
+
const dpl = doc.length + prompt.length;
|
44 |
+
const free_len = MAX_PROMPT_LENGTH - decr;
|
45 |
+
let size = 0;
|
46 |
+
if (dpl < free_len) {
|
47 |
+
size = doc.length;
|
48 |
+
} else {
|
49 |
+
size = limitWIthPoint(doc, free_len);
|
50 |
+
}
|
51 |
+
return size;
|
52 |
+
};
|
53 |
+
|
54 |
+
const getPartDoc = (pRgt, partSize) => {
|
55 |
+
const pLft = pRgt.substring(0, partSize);
|
56 |
+
pRgt = pRgt.substring(partSize).trim();
|
57 |
+
return [pLft, pRgt];
|
58 |
+
};
|
59 |
+
|
60 |
+
const ragLog = (msg, lftLen, rgtLen, responses) => {
|
61 |
+
const maxl = MAX_PROMPT_LENGTH;
|
62 |
+
const rspsl = responses.reduce((acc, cur) => {
|
63 |
+
return acc + cur.length;
|
64 |
+
}, 0);
|
65 |
+
let s = `${msg} mx:${maxl} lft:${lftLen} rgt:${rgtLen} arr:${rspsl}`;
|
66 |
+
xlog(s);
|
67 |
+
s = `${msg} ${lftLen} ${rgtLen} ${rspsl}`;
|
68 |
+
UaLog.log(s);
|
69 |
+
};
|
70 |
+
|
71 |
const Rag = {
|
72 |
// costituito dalla risposte accumulate sistemate
|
73 |
ragContext: "",
|
|
|
76 |
// risposta finale alla qury contetso
|
77 |
ragResponse: "",
|
78 |
responses: [],
|
79 |
+
contextAnswers: [],
|
80 |
prompts: [],
|
81 |
doc: "",
|
82 |
doc_part: "",
|
|
|
106 |
readRespsFromDb() {
|
107 |
this.responses = UaDb.readArray(ID_RESPONSES);
|
108 |
},
|
109 |
+
// addPrompt(p) {
|
110 |
+
// this.prompts.push(p);
|
111 |
+
// },
|
112 |
+
// documenti => risposte RAG => context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
async requestDocsRAG(query) {
|
114 |
DataMgr.deleteJsonDati();
|
115 |
DataMgr.readDbDocNames();
|
116 |
DataMgr.readDbDocs();
|
117 |
this.ragQuery = query;
|
118 |
let ndoc = 0;
|
|
|
119 |
try {
|
120 |
for (let i = 0; i < DataMgr.docs.length; i++) {
|
121 |
let doc = DataMgr.docs[i];
|
122 |
if (doc.trim() == "") continue;
|
123 |
+
const docName = DataMgr.doc_names[i];
|
124 |
const doc_entire_len = doc.length;
|
125 |
+
xlog(`${docName} (${doc_entire_len}) `);
|
126 |
+
UaLog.log(`${docName} (${doc_entire_len}) `);
|
|
|
127 |
++ndoc;
|
128 |
let npart = 0;
|
129 |
let decr = 0;
|
130 |
let prompt = "";
|
131 |
let lft = "";
|
132 |
let rgt = "";
|
133 |
+
let text = "";
|
134 |
+
let docAnswers = [];
|
135 |
|
136 |
while (true) {
|
137 |
+
let partSize = getPartSize(doc, promptDoc("", query, ""), decr);
|
138 |
if (partSize < 10) {
|
139 |
break;
|
140 |
}
|
141 |
+
[lft, rgt] = getPartDoc(doc, partSize);
|
142 |
+
ragLog(`${ndoc},${npart + 1}`, lft.length, rgt.length, this.responses);
|
143 |
+
prompt = promptDoc(lft, query, docName);
|
144 |
const payload = getPayloadDoc(prompt);
|
|
|
145 |
try {
|
146 |
+
text = await HfRequest.post(payload, TIMEOUT);
|
147 |
if (!text) return "";
|
148 |
} catch (err) {
|
149 |
+
const ei = errorInfo(err);
|
150 |
+
if (ei.errorType === ERROR_TOKENS) {
|
151 |
+
UaLog.log(`Error tokens Doc ${lft.length}`);
|
152 |
+
console.error(`Error tokens. Doc ${prompt.length}`);
|
153 |
decr += PROMPT_DECR;
|
154 |
continue;
|
155 |
} else {
|
156 |
+
console.error(err);
|
157 |
+
throw err;
|
|
|
158 |
}
|
159 |
}
|
|
|
160 |
npart++;
|
161 |
doc = rgt;
|
162 |
+
text = cleanResponse(text);
|
163 |
+
docAnswers.push(text);
|
164 |
+
const s = `DOCUMENTO : ${docName}\n${text}`;
|
165 |
+
this.responses.push(s);
|
166 |
} // end while
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
+
//implemntare build context
|
169 |
+
let donAnsLen = 0;
|
170 |
+
if (docAnswers == 1) {
|
171 |
+
//il docuento non è duvuso in parti
|
172 |
+
text = docAnswers[0];
|
173 |
+
donAnsLen = text.length;
|
174 |
+
} else {
|
175 |
+
//il documento è diviso in parto
|
176 |
+
text = docAnswers.join("\n");
|
177 |
+
donAnsLen = text.length;
|
178 |
+
while (true) {
|
179 |
+
prompt = promptBuildContext(text);
|
180 |
+
const payload = getPayloadBuildContext(prompt);
|
181 |
+
try {
|
182 |
+
text = await HfRequest.post(payload, TIMEOUT);
|
183 |
+
if (!text) return "";
|
184 |
+
} catch (err) {
|
185 |
+
const ei = errorInfo(err);
|
186 |
+
if (ei.errorType === ERROR_TOKENS) {
|
187 |
+
UaLog.log(`Error tokens build Context ${lft.length}`);
|
188 |
+
console.error(`Error tokens buildContext. ${prompt.length}`);
|
189 |
+
text = truncInput(text, PROMPT_DECR);
|
190 |
+
continue;
|
191 |
+
} else {
|
192 |
+
console.error(err);
|
193 |
+
throw err;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
break;
|
197 |
+
} //end while
|
198 |
+
} //end else
|
199 |
+
UaLog.log(`context ${donAnsLen} => ${text.length}`);
|
200 |
+
text = cleanResponse(text);
|
201 |
+
text = `DOCUMENTO: ${docName}\n ${text}`;
|
202 |
+
this.contextAnswers.push(text);
|
203 |
+
} // end for document
|
204 |
+
} catch (err) {
|
205 |
+
console.error(err);
|
206 |
+
throw err;
|
207 |
+
}
|
208 |
+
// costruzione context
|
209 |
+
this.ragContext = this.contextAnswers.join("\n");
|
210 |
this.saveToDb();
|
211 |
|
212 |
// query finale utilizza context
|
213 |
{
|
214 |
let text = "";
|
215 |
+
let context = this.ragContext;
|
216 |
try {
|
217 |
+
while (true) {
|
218 |
+
let prompt = promptWithContext(context, query);
|
219 |
+
const payload = getPayloadWithContext(prompt);
|
220 |
+
try {
|
221 |
+
text = await HfRequest.post(payload, TIMEOUT);
|
222 |
+
if (!text) return "";
|
223 |
+
} catch (err) {
|
224 |
+
const ei = errorInfo(err);
|
225 |
+
if (ei.errorType === ERROR_TOKENS) {
|
226 |
+
UaLog.log(`Error tokens with COntext ${lft.length}`);
|
227 |
+
console.error(`Error tokens context. Doc ${prompt.length}`);
|
228 |
+
context = truncInput(context, PROMPT_DECR);
|
229 |
+
continue;
|
230 |
+
} else {
|
231 |
+
console.error(err);
|
232 |
+
throw err;
|
233 |
+
}
|
234 |
}
|
235 |
+
break;
|
236 |
}
|
237 |
+
text = cleanResponse(text);
|
238 |
this.ragResponse = text;
|
239 |
this.saveRespToDb();
|
240 |
ThreadMgr.init();
|
241 |
this.saveToDb();
|
242 |
const pl = prompt.length;
|
243 |
UaLog.log(`Risposta (${pl},${text.length})`);
|
244 |
+
} catch (err) {
|
245 |
+
console.error(err);
|
246 |
+
text = `${err}`;
|
247 |
+
throw err;
|
|
|
248 |
} finally {
|
|
|
249 |
return text;
|
250 |
}
|
251 |
+
} // end query
|
252 |
},
|
253 |
+
//////////////////////////
|
254 |
// thread
|
255 |
async requestContext(query) {
|
256 |
+
let text = "";
|
|
|
257 |
if (!this.ragContext) {
|
258 |
const ok = await confirm("Contesto vuoto. Vuoi continuare?");
|
259 |
if (!ok) return "";
|
260 |
}
|
|
|
261 |
if (ThreadMgr.isFirst()) {
|
262 |
+
ThreadMgr.init();
|
|
|
263 |
try {
|
264 |
let context = this.ragContext;
|
265 |
+
let thread = ThreadMgr.getThread();
|
|
|
|
|
266 |
|
267 |
+
while (true) {
|
268 |
+
prompt = promptThread(context, thread, query);
|
269 |
+
const payload = getPayloadThread(prompt);
|
270 |
+
try {
|
271 |
+
text = await HfRequest.post(payload, TIMEOUT);
|
272 |
+
if (!text) return "";
|
273 |
+
} catch (err) {
|
274 |
+
const ei = errorInfo(err);
|
275 |
+
if (ei.errorType === ERROR_TOKENS) {
|
276 |
+
UaLog.log(`Error tokens Thread Init ${prompt.length}`);
|
277 |
+
console.error(`Error tokens Thread Init. ${prompt.length}`);
|
278 |
+
thread = truncInput(thread, PROMPT_DECR);
|
279 |
+
continue;
|
280 |
+
} else {
|
281 |
+
console.error(err);
|
282 |
+
throw err;
|
283 |
+
}
|
284 |
+
} //end catch
|
285 |
+
break;
|
286 |
}
|
287 |
+
text = cleanResponse(text);
|
288 |
ThreadMgr.add(query, text);
|
289 |
+
text = ThreadMgr.getThread();
|
290 |
UaLog.log(`Inizio Conversazione (${prompt.length},${text.length})`);
|
291 |
+
} catch (err) {
|
292 |
+
console.error(err);
|
293 |
+
text = `${err}`;
|
294 |
+
throw err;
|
295 |
} finally {
|
296 |
+
return text;
|
|
|
297 |
}
|
298 |
} else {
|
|
|
299 |
try {
|
300 |
let context = this.ragContext;
|
301 |
let thread = ThreadMgr.getThread();
|
302 |
let prompt = "";
|
|
|
|
|
|
|
303 |
while (true) {
|
|
|
304 |
prompt = promptThread(context, thread, query);
|
305 |
const payload = getPayloadThread(prompt);
|
|
|
306 |
try {
|
307 |
+
text = await HfRequest.post(payload, TIMEOUT);
|
308 |
if (!text) return "";
|
309 |
} catch (err) {
|
310 |
+
const ei = errorInfo(err);
|
311 |
+
if (ei.errorType === ERROR_TOKENS) {
|
312 |
+
UaLog.log(`Error tokens Thread ${prompt.length}`);
|
313 |
+
console.error(`Error tokens Thread. ${prompt.length}`);
|
314 |
+
thread = truncInput(thread, PROMPT_DECR);
|
315 |
continue;
|
316 |
} else {
|
317 |
+
console.error(err);
|
318 |
+
throw err;
|
319 |
}
|
320 |
}
|
321 |
break;
|
322 |
}
|
323 |
+
text = cleanResponse(text);
|
324 |
ThreadMgr.add(query, text);
|
325 |
+
text = ThreadMgr.getThread();
|
326 |
UaLog.log(`Conversazione (${prompt.length},${text.length})`);
|
327 |
+
} catch (err) {
|
328 |
+
console.error(err);
|
329 |
+
text = `${err}`;
|
330 |
+
throw err;
|
|
|
331 |
} finally {
|
332 |
+
return text;
|
|
|
333 |
}
|
334 |
}
|
335 |
},
|
|
|
353 |
this.rows.push(row);
|
354 |
UaDb.saveArray(ID_THREAD, ThreadMgr.rows);
|
355 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
getThread() {
|
357 |
const rows = [];
|
358 |
for (const ua of this.rows) {
|
359 |
+
const u = ua[0];
|
360 |
+
const a = ua[1];
|
361 |
+
rows.push(`\n${USER}\n${u}\n${LLM}\n${a}\n`);
|
362 |
}
|
363 |
+
return rows.join("").trim();
|
|
|
364 |
},
|
365 |
isFirst() {
|
366 |
return this.rows.length < 2;
|
static/javascript/rag_prompts.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
function promptDoc(documento, domanda, docName) {
|
6 |
return `
|
7 |
SYSTEM:
|
8 |
-
Sei un assistente AI specializzato nell'analisi di documenti.
|
9 |
|
10 |
TASK:
|
11 |
Analizzare il documento ${docName} ed estrarre le informazioni rilevanti per rispondere alla domanda fornita.
|
@@ -13,11 +13,11 @@ Analizzare il documento ${docName} ed estrarre le informazioni rilevanti per ris
|
|
13 |
INSTRUCTIONS:
|
14 |
1. Analizza attentamente il documento fornito e identifica le informazioni pertinenti alla domanda.
|
15 |
2. Estrai i concetti chiave e fai inferenze ragionevoli.
|
16 |
-
3 Organizza le informazioni in modo logico.
|
17 |
-
4. Prepara una risposta completa.
|
18 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
19 |
6. Cita le fonti quando è utile per chiarire informazioni o inferenze.
|
20 |
-
7. Assicurati che la risposta sia interamente in italiano,
|
21 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
22 |
|
23 |
DOCUMENT:
|
@@ -29,12 +29,49 @@ QUESTION:
|
|
29 |
${domanda}
|
30 |
|
31 |
OUTPUT_FORMAT:
|
32 |
-
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto.
|
33 |
|
34 |
RESPONSE:
|
35 |
`;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
function promptWithContext(contesto, domanda) {
|
39 |
return `
|
40 |
SYSTEM:
|
@@ -50,7 +87,7 @@ INSTRUCTIONS:
|
|
50 |
4. Struttura la risposta in paragrafi logici.
|
51 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
52 |
6. Se la domanda richiede di citare le fonti, fai riferimento al documento fornito distinguendolo chiaramente da eventuali altre fonti citate all'interno del documento stesso.
|
53 |
-
7. Assicurati che la risposta sia interamente in italiano
|
54 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
55 |
|
56 |
CONTEXT:
|
@@ -87,6 +124,7 @@ INSTRUCTIONS:
|
|
87 |
8. Se l'intento non è chiaro, chiedi gentilmente chiarimenti invece di fare supposizioni.
|
88 |
9. Sii flessibile: se la richiesta implica un'azione specifica, adattati di conseguenza.
|
89 |
10. Se è necessario integrare con conoscenze generali, specifica chiaramente quando lo stai facendo.
|
|
|
90 |
|
91 |
CONTEXT:
|
92 |
<<<BEGIN_CONTEXT>>>
|
@@ -101,7 +139,7 @@ REQUEST:
|
|
101 |
${richiesta}
|
102 |
|
103 |
OUTPUT_FORMAT:
|
104 |
-
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto.
|
105 |
|
106 |
RESPONSE:
|
107 |
`;
|
@@ -168,7 +206,7 @@ function getPayloadDoc(prompt) {
|
|
168 |
task: "text2text-generation",
|
169 |
max_new_tokens: 1024,
|
170 |
num_return_sequences: 1,
|
171 |
-
temperature: 0.
|
172 |
top_k: 50,
|
173 |
top_p: 0.7,
|
174 |
do_sample: false,
|
@@ -188,6 +226,32 @@ function getPayloadDoc(prompt) {
|
|
188 |
return payload;
|
189 |
}
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
function getPayloadWithContext(prompt) {
|
193 |
const payload = {
|
|
|
5 |
function promptDoc(documento, domanda, docName) {
|
6 |
return `
|
7 |
SYSTEM:
|
8 |
+
Sei un assistente AI specializzato nell'analisi di documenti.Rispondi sempre ed esclusivamente in italiano.
|
9 |
|
10 |
TASK:
|
11 |
Analizzare il documento ${docName} ed estrarre le informazioni rilevanti per rispondere alla domanda fornita.
|
|
|
13 |
INSTRUCTIONS:
|
14 |
1. Analizza attentamente il documento fornito e identifica le informazioni pertinenti alla domanda.
|
15 |
2. Estrai i concetti chiave e fai inferenze ragionevoli.
|
16 |
+
3. Organizza le informazioni in modo logico.
|
17 |
+
4. Prepara una risposta chiara e completa.
|
18 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
19 |
6. Cita le fonti quando è utile per chiarire informazioni o inferenze.
|
20 |
+
7. Assicurati che la risposta sia interamente in italiano,se nel testo è usata un'altra lingua traduci in italiano.
|
21 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
22 |
|
23 |
DOCUMENT:
|
|
|
29 |
${domanda}
|
30 |
|
31 |
OUTPUT_FORMAT:
|
32 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, introduzioni, elenchi o marcatori speciali.
|
33 |
|
34 |
RESPONSE:
|
35 |
`;
|
36 |
}
|
37 |
|
38 |
+
function promptBuildContext(document) {
|
39 |
+
return `
|
40 |
+
SYSTEM:
|
41 |
+
Sei un assistente AI specializzato nell'analisi di documenti.Rispondi sempre ed esclusivamente in italiano.
|
42 |
+
|
43 |
+
TASK:
|
44 |
+
Analizza e riorganizza logicamente il documento fornito. Attieniti rigorosamente alle istruzioni.
|
45 |
+
|
46 |
+
INSTRUCTIONS:
|
47 |
+
1. Valuta la tipologia e lo scopo del documento (es. articolo scientifico, racconto,saggio, documento tecnico) e adatta l'analisi di conseguenza.
|
48 |
+
2. Analizza attentamente il documento e identifica i temi principali e i concetti chiave.
|
49 |
+
3. Estrai i concetti chiave e fai inferenze ragionevoli.
|
50 |
+
4. Organizza le informazioni in una struttura logica e coerente, eliminando ridondanze e ripetizioni.
|
51 |
+
5. Prepara una risposta che riorganizzi i contenuti, dando priorità alle informazioni più importanti o rilevanti.
|
52 |
+
6. Includi un'introduzione breve che presenti i temi principali.
|
53 |
+
7. Sviluppa l'analisi raggruppando le informazioni per argomenti correlati.
|
54 |
+
8. Presenta le inferenze e le connessioni tra i diversi concetti.
|
55 |
+
9. Se presenti informazioni contrastanti, evidenziale senza eliminarle.
|
56 |
+
10. Includi, se rilevanti, dettagli specifici come nomi propri, termini tecnici, date o luoghi che contribuiscono alla precisione del contesto.
|
57 |
+
11. Concludi con una sintesi che riassuma i punti chiave e la struttura logica.
|
58 |
+
12. Se il documento contiene sezioni distinte, analizzale separatamente ma evidenzia le connessioni tra di esse.
|
59 |
+
13. Effettua un controllo finale per assicurarti che tutte le informazioni chiave siano state incluse.
|
60 |
+
14. Assicurati che la risposta sia interamente in italiano.
|
61 |
+
15. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
62 |
+
|
63 |
+
DOCUMENT:
|
64 |
+
<<<BEGIN_DOCUMENT>>>
|
65 |
+
${document}
|
66 |
+
<<<END_DOCUMENT>>>
|
67 |
+
|
68 |
+
OUTPUT_FORMAT:
|
69 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, elenchi o marcatori speciali.
|
70 |
+
|
71 |
+
RESPONSE:
|
72 |
+
`;
|
73 |
+
}
|
74 |
+
|
75 |
function promptWithContext(contesto, domanda) {
|
76 |
return `
|
77 |
SYSTEM:
|
|
|
87 |
4. Struttura la risposta in paragrafi logici.
|
88 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
89 |
6. Se la domanda richiede di citare le fonti, fai riferimento al documento fornito distinguendolo chiaramente da eventuali altre fonti citate all'interno del documento stesso.
|
90 |
+
7. Assicurati che la risposta sia interamente in italiano.
|
91 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
92 |
|
93 |
CONTEXT:
|
|
|
124 |
8. Se l'intento non è chiaro, chiedi gentilmente chiarimenti invece di fare supposizioni.
|
125 |
9. Sii flessibile: se la richiesta implica un'azione specifica, adattati di conseguenza.
|
126 |
10. Se è necessario integrare con conoscenze generali, specifica chiaramente quando lo stai facendo.
|
127 |
+
11. Assicurati che la risposta sia interamente in italiano.
|
128 |
|
129 |
CONTEXT:
|
130 |
<<<BEGIN_CONTEXT>>>
|
|
|
139 |
${richiesta}
|
140 |
|
141 |
OUTPUT_FORMAT:
|
142 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, elenchi o marcatori speciali.
|
143 |
|
144 |
RESPONSE:
|
145 |
`;
|
|
|
206 |
task: "text2text-generation",
|
207 |
max_new_tokens: 1024,
|
208 |
num_return_sequences: 1,
|
209 |
+
temperature: 0.5,
|
210 |
top_k: 50,
|
211 |
top_p: 0.7,
|
212 |
do_sample: false,
|
|
|
226 |
return payload;
|
227 |
}
|
228 |
|
229 |
+
function getPayloadBuildContext(prompt) {
|
230 |
+
const payload = {
|
231 |
+
inputs: prompt,
|
232 |
+
parameters: {
|
233 |
+
task: "text2text-generation",
|
234 |
+
max_new_tokens: 4096,
|
235 |
+
num_return_sequences: 1,
|
236 |
+
temperature: 0.4,
|
237 |
+
top_k: 20,
|
238 |
+
top_p: 0.8,
|
239 |
+
do_sample: false,
|
240 |
+
no_repeat_ngram_size: 4,
|
241 |
+
num_beams: 6,
|
242 |
+
repetition_penalty: 1.4,
|
243 |
+
return_full_text: false,
|
244 |
+
details: false,
|
245 |
+
max_time: 120.0,
|
246 |
+
seed: 42
|
247 |
+
},
|
248 |
+
options: {
|
249 |
+
use_cache: false,
|
250 |
+
wait_for_model: true,
|
251 |
+
},
|
252 |
+
};
|
253 |
+
return payload;
|
254 |
+
}
|
255 |
|
256 |
function getPayloadWithContext(prompt) {
|
257 |
const payload = {
|
static/javascript/rag_rqs.js
CHANGED
@@ -19,7 +19,7 @@
|
|
19 |
*/
|
20 |
|
21 |
"use strict";
|
22 |
-
const VERS = "0.1.
|
23 |
|
24 |
var xlog = console.log;
|
25 |
var xerror = console.error;
|
@@ -72,7 +72,7 @@ function openApp() {
|
|
72 |
Menu.init();
|
73 |
TextInput.init();
|
74 |
TextOutput.init();
|
75 |
-
Rag.init();
|
76 |
document.querySelector(".menu-btn").checked = false;
|
77 |
release();
|
78 |
}
|
@@ -89,7 +89,6 @@ const op0 = async function (e) {
|
|
89 |
|
90 |
//query iniziale
|
91 |
function showQuery(e) {
|
92 |
-
// Rag.readFromDb(); XXX
|
93 |
const txt = `\n${Rag.ragQuery}`;
|
94 |
wnds.wpre.show(txt);
|
95 |
// Menu.close();
|
@@ -97,15 +96,13 @@ function showQuery(e) {
|
|
97 |
|
98 |
//Risposta Rsg
|
99 |
function showRagResponse(e) {
|
100 |
-
// Rag.readFromDb(); XXX
|
101 |
const txt = `\n${Rag.ragResponse}`;
|
102 |
wnds.wpre.show(txt);
|
103 |
}
|
104 |
|
105 |
//conversazione
|
106 |
function showThread(e) {
|
107 |
-
|
108 |
-
const txt = ThreadMgr.getOutText();
|
109 |
wnds.wpre.show(txt);
|
110 |
}
|
111 |
|
@@ -127,7 +124,6 @@ function elencoRisposte(e) {
|
|
127 |
|
128 |
//contesto
|
129 |
function showContesto(e) {
|
130 |
-
// Rag.readFromDb();XXX
|
131 |
const txt = `${Rag.ragContext}`;
|
132 |
wnds.wpre.show(txt);
|
133 |
}
|
|
|
19 |
*/
|
20 |
|
21 |
"use strict";
|
22 |
+
const VERS = "0.1.43 (12-08-2024)";
|
23 |
|
24 |
var xlog = console.log;
|
25 |
var xerror = console.error;
|
|
|
72 |
Menu.init();
|
73 |
TextInput.init();
|
74 |
TextOutput.init();
|
75 |
+
Rag.init();
|
76 |
document.querySelector(".menu-btn").checked = false;
|
77 |
release();
|
78 |
}
|
|
|
89 |
|
90 |
//query iniziale
|
91 |
function showQuery(e) {
|
|
|
92 |
const txt = `\n${Rag.ragQuery}`;
|
93 |
wnds.wpre.show(txt);
|
94 |
// Menu.close();
|
|
|
96 |
|
97 |
//Risposta Rsg
|
98 |
function showRagResponse(e) {
|
|
|
99 |
const txt = `\n${Rag.ragResponse}`;
|
100 |
wnds.wpre.show(txt);
|
101 |
}
|
102 |
|
103 |
//conversazione
|
104 |
function showThread(e) {
|
105 |
+
const txt = ThreadMgr.getThread();
|
|
|
106 |
wnds.wpre.show(txt);
|
107 |
}
|
108 |
|
|
|
124 |
|
125 |
//contesto
|
126 |
function showContesto(e) {
|
|
|
127 |
const txt = `${Rag.ragContext}`;
|
128 |
wnds.wpre.show(txt);
|
129 |
}
|
static/javascript/rag_ui.js
CHANGED
@@ -58,7 +58,7 @@ const WndPre = (id) => {
|
|
58 |
try {
|
59 |
await navigator.clipboard.writeText(t);
|
60 |
} catch (err) {
|
61 |
-
|
62 |
}
|
63 |
},
|
64 |
};
|
@@ -105,7 +105,7 @@ const WndDiv = (id) => {
|
|
105 |
try {
|
106 |
await navigator.clipboard.writeText(t);
|
107 |
} catch (err) {
|
108 |
-
|
109 |
}
|
110 |
},
|
111 |
};
|
@@ -149,7 +149,7 @@ const Menu = {
|
|
149 |
UaLog.callHide = hide;
|
150 |
UaLog.callShow = show;
|
151 |
|
152 |
-
UaLog.setXY(
|
153 |
UaLog.log_show("Buon Lavoro");
|
154 |
},
|
155 |
close() {
|
@@ -175,7 +175,6 @@ const Menu = {
|
|
175 |
},
|
176 |
};
|
177 |
|
178 |
-
|
179 |
const TextInput = {
|
180 |
wnd: null,
|
181 |
init() {
|
@@ -226,12 +225,12 @@ const TextInput = {
|
|
226 |
this.inp.value = "";
|
227 |
this.inp.focus();
|
228 |
});
|
229 |
-
this.inp.addEventListener("keydown", (e) => this.handleEnter(e));
|
230 |
document.querySelector(".send-input").addEventListener("click", () => this.send());
|
231 |
document.querySelector(".send2-input").addEventListener("click", () => this.send2());
|
232 |
document.querySelector(".clear-input").addEventListener("click", () => this.clear());
|
233 |
},
|
234 |
-
handleEnter(e) {
|
235 |
if (e.key === "Enter" && !e.shiftKey) {
|
236 |
e.preventDefault();
|
237 |
this.send2();
|
@@ -242,12 +241,11 @@ const TextInput = {
|
|
242 |
// sala le risposte RAG
|
243 |
// crea il contesto
|
244 |
async send() {
|
245 |
-
const q=this.inp.value;
|
246 |
if (!q) {
|
247 |
alert("Ricorda di scrivere la Query ");
|
248 |
return;
|
249 |
}
|
250 |
-
// Rag.readFromDb();XXX
|
251 |
if (!!Rag.ragContext) {
|
252 |
const ok = confirm("Vuoi iniziare una nuova elabrazione ?");
|
253 |
if (!ok) return "";
|
@@ -262,7 +260,7 @@ const TextInput = {
|
|
262 |
UaLog.close();
|
263 |
} catch (err) {
|
264 |
const msg = `send\n${err}`;
|
265 |
-
|
266 |
alert(msg);
|
267 |
setOutText(msg);
|
268 |
}
|
@@ -271,7 +269,7 @@ const TextInput = {
|
|
271 |
|
272 |
// utiliza il contesto esistente
|
273 |
async send2() {
|
274 |
-
const q=this.inp.value;
|
275 |
if (!q) {
|
276 |
alert("Ricorda di scrivere la Query ");
|
277 |
return;
|
@@ -289,18 +287,22 @@ const TextInput = {
|
|
289 |
this.inp.value = "";
|
290 |
} catch (err) {
|
291 |
const msg = `send2\n${err}`;
|
292 |
-
|
293 |
alert(msg);
|
294 |
setOutText(msg);
|
295 |
}
|
296 |
hideSpinner();
|
297 |
},
|
298 |
clear() {
|
|
|
|
|
|
|
|
|
299 |
const ok = confirm("Confermi cancellazione conversazione? ");
|
300 |
if (!ok) return;
|
301 |
this.inp.value = "";
|
302 |
setOutText("");
|
303 |
-
ThreadMgr.init();
|
304 |
},
|
305 |
};
|
306 |
|
@@ -337,7 +339,7 @@ TextOutput = {
|
|
337 |
try {
|
338 |
await navigator.clipboard.writeText(t);
|
339 |
} catch (err) {
|
340 |
-
|
341 |
}
|
342 |
setTimeout(() => {
|
343 |
this.copyBtn.classList.remove("copied");
|
|
|
58 |
try {
|
59 |
await navigator.clipboard.writeText(t);
|
60 |
} catch (err) {
|
61 |
+
console.error("Errore ", err);
|
62 |
}
|
63 |
},
|
64 |
};
|
|
|
105 |
try {
|
106 |
await navigator.clipboard.writeText(t);
|
107 |
} catch (err) {
|
108 |
+
console.error("Errore ", err);
|
109 |
}
|
110 |
},
|
111 |
};
|
|
|
149 |
UaLog.callHide = hide;
|
150 |
UaLog.callShow = show;
|
151 |
|
152 |
+
UaLog.setXY(54, 13).setZ(111).new();
|
153 |
UaLog.log_show("Buon Lavoro");
|
154 |
},
|
155 |
close() {
|
|
|
175 |
},
|
176 |
};
|
177 |
|
|
|
178 |
const TextInput = {
|
179 |
wnd: null,
|
180 |
init() {
|
|
|
225 |
this.inp.value = "";
|
226 |
this.inp.focus();
|
227 |
});
|
228 |
+
this.inp.addEventListener("keydown", (e) => this.handleEnter(e));
|
229 |
document.querySelector(".send-input").addEventListener("click", () => this.send());
|
230 |
document.querySelector(".send2-input").addEventListener("click", () => this.send2());
|
231 |
document.querySelector(".clear-input").addEventListener("click", () => this.clear());
|
232 |
},
|
233 |
+
handleEnter(e) {
|
234 |
if (e.key === "Enter" && !e.shiftKey) {
|
235 |
e.preventDefault();
|
236 |
this.send2();
|
|
|
241 |
// sala le risposte RAG
|
242 |
// crea il contesto
|
243 |
async send() {
|
244 |
+
const q = this.inp.value;
|
245 |
if (!q) {
|
246 |
alert("Ricorda di scrivere la Query ");
|
247 |
return;
|
248 |
}
|
|
|
249 |
if (!!Rag.ragContext) {
|
250 |
const ok = confirm("Vuoi iniziare una nuova elabrazione ?");
|
251 |
if (!ok) return "";
|
|
|
260 |
UaLog.close();
|
261 |
} catch (err) {
|
262 |
const msg = `send\n${err}`;
|
263 |
+
console.error(msg);
|
264 |
alert(msg);
|
265 |
setOutText(msg);
|
266 |
}
|
|
|
269 |
|
270 |
// utiliza il contesto esistente
|
271 |
async send2() {
|
272 |
+
const q = this.inp.value;
|
273 |
if (!q) {
|
274 |
alert("Ricorda di scrivere la Query ");
|
275 |
return;
|
|
|
287 |
this.inp.value = "";
|
288 |
} catch (err) {
|
289 |
const msg = `send2\n${err}`;
|
290 |
+
console.error(msg);
|
291 |
alert(msg);
|
292 |
setOutText(msg);
|
293 |
}
|
294 |
hideSpinner();
|
295 |
},
|
296 |
clear() {
|
297 |
+
// let s = "messaggio di prova per vedere la massima larghezza";
|
298 |
+
// for (let i = 0; i < 40; i++) {
|
299 |
+
// UaLog.log(s);
|
300 |
+
// }
|
301 |
const ok = confirm("Confermi cancellazione conversazione? ");
|
302 |
if (!ok) return;
|
303 |
this.inp.value = "";
|
304 |
setOutText("");
|
305 |
+
ThreadMgr.init();
|
306 |
},
|
307 |
};
|
308 |
|
|
|
339 |
try {
|
340 |
await navigator.clipboard.writeText(t);
|
341 |
} catch (err) {
|
342 |
+
console.error("Errore ", err);
|
343 |
}
|
344 |
setTimeout(() => {
|
345 |
this.copyBtn.classList.remove("copied");
|
static/javascript/ualog3.js
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @format */
|
2 |
+
// function show() {
|
3 |
+
// const log = document.getElementById("id_log");
|
4 |
+
// if (log.classList.contains("active")) return;
|
5 |
+
// log.classList.add("active");
|
6 |
+
// }
|
7 |
+
|
8 |
+
// function hide() {
|
9 |
+
// const log = document.getElementById("id_log");
|
10 |
+
// if (!log.classList.contains("active")) return;
|
11 |
+
// log.classList.remove("active");
|
12 |
+
// }
|
13 |
+
// jshint esversion: 8
|
14 |
+
// release 09-'6-24
|
15 |
+
// utilizzare l'ultima versione di UaWindowAdm
|
16 |
+
// setXY con vw ,vh
|
17 |
+
|
18 |
+
var UaLog = {
|
19 |
+
callHide: function () {},
|
20 |
+
callShow: function () {},
|
21 |
+
active: false,
|
22 |
+
wind: null,
|
23 |
+
x: null,
|
24 |
+
y: null,
|
25 |
+
z: null,
|
26 |
+
max_length: 2000,
|
27 |
+
msg_id: "ualogmsg_",
|
28 |
+
new: function () {
|
29 |
+
if (this.wind == null) {
|
30 |
+
this.wind = UaWindowAdm.create("ualog_");
|
31 |
+
this.wind.drag();
|
32 |
+
}
|
33 |
+
const h = `
|
34 |
+
<button type="button" class="clear" onclick="javascript:UaLog.cls();">Clear</button>
|
35 |
+
<button type="button" class="close" onclick="javascript:UaLog.close();">Close</button>
|
36 |
+
<pre id="ualogmsg_" ></pre>`;
|
37 |
+
this.wind.setHtml(h);
|
38 |
+
// this.wind.addClassStyle("ualog");
|
39 |
+
|
40 |
+
if (!!this.x) this.wind.vw_vh().setXY(this.x, this.y, -1);
|
41 |
+
else this.wind.setCenter(-1);
|
42 |
+
if (!!this.z) this.wind.setZ(this.z);
|
43 |
+
return this;
|
44 |
+
},
|
45 |
+
setXY(x, y) {
|
46 |
+
this.x = x;
|
47 |
+
this.y = y;
|
48 |
+
return this;
|
49 |
+
},
|
50 |
+
setZ(z) {
|
51 |
+
this.z = z;
|
52 |
+
return this;
|
53 |
+
},
|
54 |
+
prn_(...args) {
|
55 |
+
let s = args.join("\n");
|
56 |
+
let e = document.getElementById(this.msg_id);
|
57 |
+
let h = e.textContent + s + "\n";
|
58 |
+
e.textContent = h;
|
59 |
+
},
|
60 |
+
print(...args) {
|
61 |
+
if (this.wind == null) return;
|
62 |
+
if (!this.active) return;
|
63 |
+
this.prn_(...args);
|
64 |
+
},
|
65 |
+
log(...args) {
|
66 |
+
if (this.wind == null) return;
|
67 |
+
this.prn_(...args);
|
68 |
+
},
|
69 |
+
log_show(...args) {
|
70 |
+
if (this.wind == null) return;
|
71 |
+
if (!this.active) this.toggle();
|
72 |
+
this.prn_(...args);
|
73 |
+
},
|
74 |
+
cls() {
|
75 |
+
if (this.wind == null) return;
|
76 |
+
document.getElementById(this.msg_id).innerHTML = "";
|
77 |
+
return this;
|
78 |
+
},
|
79 |
+
close() {
|
80 |
+
if (this.wind == null) return;
|
81 |
+
this.wind.hide();
|
82 |
+
this.active = false;
|
83 |
+
this.callHide();
|
84 |
+
},
|
85 |
+
toggle() {
|
86 |
+
if (this.wind == null) return;
|
87 |
+
if (!this.active) {
|
88 |
+
this.active = true;
|
89 |
+
this.wind.show();
|
90 |
+
this.callShow();
|
91 |
+
} else {
|
92 |
+
this.active = false;
|
93 |
+
this.wind.hide();
|
94 |
+
this.callHide();
|
95 |
+
}
|
96 |
+
},
|
97 |
+
};
|
static/js/ragrqs.min.js
CHANGED
@@ -1,16 +1,13 @@
|
|
1 |
-
const removeChars=a=>a
|
2 |
-
|
3 |
-
""),a=a.replace(/ +([.,;:!?])/g,"$1"),a=a.replace(/ +/g," "),a.trim()}catch(b){return
|
4 |
-
function
|
5 |
-
"$1"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),"Errore di codifica nella risposta"}}
|
6 |
-
function cleanOutput(a){try{return a=removeChars(a),a=replaceChars(a),a=a.replace(/\t/g," "),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/\r/g," "),a=a.replace(/[^\w\s\u00e0\u00e8\u00e9\u00ec\u00f2\u00f9\u00c0\u00c8\u00c9\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00c1\u00c9\u00cd\u00d3\u00da\u00e4\u00eb\u00ef\u00f6\u00fc\u00c4\u00cb\u00cf\u00d6\u00dc\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e7\u00c7\u00f1\u00d1.,;:!?'"()-]/g,""),a=a.replace(/ +/g," "),a.trim()}catch(b){return xerror(b),
|
7 |
-
"Errore di codifica nell'output"}}function list2text(a){const b={};for(var c of a){a=(a=c.match(/<<<(.*?)>>>/))?a[1]:null;const d=c.replace(/<<<.*?>>>/,"");b[a]=a in b?b[a]+`\n ${d}`:d}c=[];for(let [d,e]of Object.entries(b))c.push(`Documento: ${d}.\n${e}`);return c.join("\n\n")}function subResponseDOcTag(a){return a.replace(/<<<(.*?)>>>/,(b,c)=>`Documento: ${c}`)};const ID_RESPONSES="id_responses",ID_DOC_NAMES="id_doc_names",ID_DOCS="id_docs;",ID_RAG="id_rag",ID_THREAD="id_thread",UaDb={create(a,b){localStorage.getItem(a)?xerror(`ID ${a} already exists.`):localStorage.setItem(a,b)},read(a){const b=localStorage.getItem(a);return null===b?(xlog(`UaDb.read ${a} not found.`),""):b},update(a,b){localStorage.getItem(a)?localStorage.setItem(a,b):xlog(`UaDb.update ${a} not found.`)},delete(a){localStorage.getItem(a)?localStorage.removeItem(a):xerror(`ID ${a} not found.`)},
|
8 |
save(a,b){localStorage.setItem(a,b)},getAllIds(){const a=[];for(let b=0;b<localStorage.length;b++)a.push(localStorage.key(b));return a},saveArray(a,b){b=JSON.stringify(b);UaDb.save(a,b)},readArray(a){a=UaDb.read(a);return 0==a.trim().length?[]:JSON.parse(a)},saveJson(a,b){b=JSON.stringify(b);UaDb.save(a,b)},readJson(a){return(a=UaDb.read(a))?JSON.parse(a):{}}},DataMgr={docs:[],doc_names:[],linkToName(a){a=a.split("/");return a[a.length-1]},async loadDoc(a){try{const b=await requestGet(a),c=cleanDoc(b),
|
9 |
d=this.linkToName(a);this.doc_names.push(d);this.docs.push(c);this.saveDbDocs();return c}catch(b){alert("loadDoc()\n"+b+"\n"+a)}},addDoc(a,b){b=cleanDoc(b);this.docs.push(b);this.doc_names.push(a);this.saveDbDocs()},saveDbDocs(){UaDb.saveArray(ID_DOC_NAMES,this.doc_names);UaDb.saveArray(ID_DOCS,this.docs)},readDbDocs(){this.docs=UaDb.readArray(ID_DOCS)},readDbDocNames(){this.doc_names=UaDb.readArray(ID_DOC_NAMES)},deleteJsonDati(){const a=UaDb.getAllIds();for(const b of a)[ID_DOCS,ID_DOC_NAMES].includes(b)||
|
10 |
UaDb.delete(b);Rag.ragQuery="";Rag.ragContext="";Rag.ragResponse="";Rag.responses=[];Rag.prompts=[];ThreadMgr.rows=[]}};const arr=["bWtkW0l+XX0=","SXx2d1FxbVc=","V1tRXlxneUY=","flV6a1NdbUg=","VllpUkc="],model_name="mistralai/Mistral-7B-Instruct-v0.3",umgm=a=>a.map(b=>atob(b).split("").map(c=>String.fromCharCode((c.charCodeAt(0)-5+256)%256)).join("")).join(""),tm=umgm(arr);
|
11 |
async function requestGet(a){try{var b=await fetch(a,{method:"GET",headers:{"Content-Type":"text/plain;charset=UTF-8"}});if(!b.ok)throw Error(`HTTP error! status: ${b.status}`);const c=await b.arrayBuffer();return(new TextDecoder("utf-8")).decode(c)}catch(c){throw console.error(c),b="AbortError"===c.name?"Request was aborted":c.message.includes("HTTP error! status")?c.message:"An error occurred",alert(`requestGet()\nurl: ${a}\n${b}`),c;}}
|
12 |
const ERROR_TOKENS="ERROR_TOKENS",TIMEOUT_ERROR="TIMEOUT_ERROR",HfRequest={controller:null,isCancelled:!1,baseUrl:"https://api-inference.huggingface.co/models",async post(a,b=5E4){this.isCancelled=!1;this.controller=new AbortController;try{const c=setTimeout(()=>{this.controller.abort()},b),d=await fetch(`${this.baseUrl}/${model_name}`,{method:"POST",headers:{Authorization:`Bearer ${tm}`,"Content-Type":"application/json"},body:JSON.stringify(a),signal:this.controller.signal});clearTimeout(c);if(this.isCancelled)return null;
|
13 |
-
const e=await d.json();if(!d.ok){const g=this.checkError(d.status,e),
|
14 |
(this.isCancelled=!0,this.controller.abort())},checkError(a,b){return 500<=a?"SERVER_ERROR":400<=a&&500>a?"object"===typeof b&&"validation"===b.error_type?b.error.includes("tokens")?ERROR_TOKENS:"ERROR_VALIDATION":"CLIENT_ERROR":"UNKNOWN_ERROR"},isInvalidResponse(a){return a&&Array.isArray(a)&&0!==a.length?a[0].generated_text?null:"MISSING_GENERATED_TEXT":"INVALID_DATA"},createErrorInfo(a,b,c,d){return JSON.stringify({status:a,statusText:b,errorType:d,message:c||"Errore sconosciuto"})}};
|
15 |
function errorInfo(a){return JSON.parse(a.message)}function errorToText(a){a=JSON.parse(a.message);return`Error:
|
16 |
Status: ${a.status}
|
@@ -34,17 +31,18 @@ function errorInfo(a){return JSON.parse(a.message)}function errorToText(a){a=JSO
|
|
34 |
You should have received a copy of the GNU General Public License
|
35 |
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
36 |
*/
|
37 |
-
const MAX_PROMPT_LENGTH=81920,PROMPT_DECR=2048,
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
b
|
44 |
-
|
45 |
-
|
|
|
46 |
SYSTEM:
|
47 |
-
Sei un assistente AI specializzato nell'analisi di documenti.
|
48 |
|
49 |
TASK:
|
50 |
Analizzare il documento ${c} ed estrarre le informazioni rilevanti per rispondere alla domanda fornita.
|
@@ -52,11 +50,11 @@ Analizzare il documento ${c} ed estrarre le informazioni rilevanti per risponder
|
|
52 |
INSTRUCTIONS:
|
53 |
1. Analizza attentamente il documento fornito e identifica le informazioni pertinenti alla domanda.
|
54 |
2. Estrai i concetti chiave e fai inferenze ragionevoli.
|
55 |
-
3 Organizza le informazioni in modo logico.
|
56 |
-
4. Prepara una risposta completa.
|
57 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
58 |
6. Cita le fonti quando \u00e8 utile per chiarire informazioni o inferenze.
|
59 |
-
7. Assicurati che la risposta sia interamente in italiano,
|
60 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
61 |
|
62 |
DOCUMENT:
|
@@ -68,10 +66,43 @@ QUESTION:
|
|
68 |
${b}
|
69 |
|
70 |
OUTPUT_FORMAT:
|
71 |
-
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto.
|
72 |
|
73 |
RESPONSE:
|
74 |
-
`}function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
SYSTEM:
|
76 |
Sei un assistente AI specializzato nell'analisi e nell'elaborazione di informazioni contestuali. Rispondi sempre in italiano.
|
77 |
|
@@ -85,7 +116,7 @@ INSTRUCTIONS:
|
|
85 |
4. Struttura la risposta in paragrafi logici.
|
86 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
87 |
6. Se la domanda richiede di citare le fonti, fai riferimento al documento fornito distinguendolo chiaramente da eventuali altre fonti citate all'interno del documento stesso.
|
88 |
-
7. Assicurati che la risposta sia interamente in italiano
|
89 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
90 |
|
91 |
CONTEXT:
|
@@ -118,6 +149,7 @@ INSTRUCTIONS:
|
|
118 |
8. Se l'intento non \u00e8 chiaro, chiedi gentilmente chiarimenti invece di fare supposizioni.
|
119 |
9. Sii flessibile: se la richiesta implica un'azione specifica, adattati di conseguenza.
|
120 |
10. Se \u00e8 necessario integrare con conoscenze generali, specifica chiaramente quando lo stai facendo.
|
|
|
121 |
|
122 |
CONTEXT:
|
123 |
<<<BEGIN_CONTEXT>>>
|
@@ -132,13 +164,14 @@ REQUEST:
|
|
132 |
${c}
|
133 |
|
134 |
OUTPUT_FORMAT:
|
135 |
-
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto.
|
136 |
|
137 |
RESPONSE:
|
138 |
-
`}function getPayloadDoc(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:1024,num_return_sequences:1,temperature:.
|
|
|
139 |
function getPayloadWithContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2048,num_return_sequences:1,temperature:.6,top_k:50,top_p:.7,do_sample:!1,no_repeat_ngram_size:4,num_beams:5,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:120,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
140 |
-
function getPayloadThread(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2048,num_return_sequences:1,temperature:.6,top_k:50,top_p:.7,do_sample:!1,no_repeat_ngram_size:4,num_beams:5,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:120,seed:42},options:{use_cache:!1,wait_for_model:!0}}};const VERS="0.1.
|
141 |
-
function openApp(){wnds.init();Menu.init();TextInput.init();TextOutput.init();Rag.init();document.querySelector(".menu-btn").checked=!1;release()}function release(){document.querySelector(".release").innerHTML=VERS}const op0=async function(a){a=await requestGet("./help1.html");wnds.wdiv.show(a)};function showQuery(a){wnds.wpre.show(`\n${Rag.ragQuery}`)}function showRagResponse(a){wnds.wpre.show(`\n${Rag.ragResponse}`)}function showThread(a){a=ThreadMgr.
|
142 |
function elencoRisposte(a){a=[...Rag.responses];0==a.length&&(a=UaDb.readArray(ID_RESPONSES));0!=a.length&&(a=a.map((b,c)=>{b=subResponseDOcTag(b);return`\n[${c+1}]\n ${b.trim()}`}).join("\n"),wnds.wpre.show(a))}function showContesto(a){wnds.wpre.show(`${Rag.ragContext}`)}function elencoDati(a){var b=UaDb.getAllIds();a=[];for(var c of b)b=UaDb.read(c).length,a.push(`${c} (${b})`);c=a.join("\n ");wnds.wpre.show(c)}
|
143 |
async function elencoDocs(a){DataMgr.readDbDocNames();a=DataMgr.doc_names.join("\n");wnds.wpre.show(a)}
|
144 |
function calcQuery(){DataMgr.readDbDocs();DataMgr.readDbDocNames();var a=[];let b=0,c=0;a.push("Documento Num.Parti");a.push("==================");for(const d of DataMgr.docs){const e=DataMgr.doc_names[c];c+=1;const f=Math.ceil(d.length/MAX_PROMPT_LENGTH);b+=f;a.push(`${e} [${f}]`)}a.push("==================");a.push(`Totale num. Parti: ${b}`);a=a.join("\n");wnds.wpre.show(a)}
|
@@ -155,7 +188,7 @@ function loadTestoEsempio(a){DataMgr.loadDoc(`data/${a}`);wnds.wdiv.close()}asyn
|
|
155 |
</div>
|
156 |
<pre class="pre-text">${b}</pre>
|
157 |
</div>
|
158 |
-
`;this.w.drag();this.w.setZ(12);this.w.vw_vh().setXY(16.5,10,-1);this.w.setHtml(b);this.w.show();this.w.getElement().querySelector(".btn-copy").addEventListener("click",()=>this.copy())},close(){this.w.close()},async copy(){const b=this.w.getElement().querySelector(".pre-text").textContent;try{await navigator.clipboard.writeText(b)}catch(c){
|
159 |
<div class="window-text">
|
160 |
<div class="btn-wrapper">
|
161 |
<button class="btn-copy" title="Copia">
|
@@ -167,14 +200,15 @@ function loadTestoEsempio(a){DataMgr.loadDoc(`data/${a}`);wnds.wdiv.close()}asyn
|
|
167 |
</div>
|
168 |
<div class="div-text">${b}</div>
|
169 |
</div>
|
170 |
-
`;this.w.drag();this.w.setZ(12);this.w.vw_vh().setXY(16.5,10,-1);this.w.setHtml(b);this.w.show();this.w.getElement().querySelector(".btn-copy").addEventListener("click",()=>this.copy())},close(){this.w.close()},async copy(){const b=this.w.getElement().querySelector(".div-text").textContent;try{await navigator.clipboard.writeText(b)}catch(c){
|
171 |
-
UaWindowAdm.close("id_w1");UaWindowAdm.close("id_out")}},Menu={init(){const a=document.querySelector("#id-menu-btn");a.addEventListener("change",()=>{document.querySelector("body").classList.toggle("menu-open",a.checked)});const b=document.getElementById("id_log");UaLog.callHide=()=>{b.classList.contains("active")&&b.classList.remove("active")};UaLog.callShow=()=>{b.classList.contains("active")||b.classList.add("active")};UaLog.setXY(
|
172 |
-
document.querySelector("#menu-toggle");document.querySelector("body").classList.remove("menu-open",a.checked);document.querySelector(".menu-btn").checked=!1},async help(){const a=await requestGet("./help0.html");wnds.wdiv.show(a)},upload(){RagUpload.open()},uploadDir(){RagUpload.openDir()},async load(){alert("load")},log(){UaLog.toggle()}},TextInput={wnd:null,init(){this.inp=document.querySelector(".text-input");document.addEventListener("keydown",a=>{document.activeElement!==this.inp&&
|
173 |
-
a.ctrlKey||a.metaKey||a.preventDefault())});document.querySelector(".clear-button").addEventListener("click",()=>{this.inp.value="";this.inp.focus()});this.inp.addEventListener("keydown",a=>this.handleEnter(a));document.querySelector(".send-input").addEventListener("click",()=>this.send());
|
174 |
-
this.send2())},async send(){if(this.inp.value){if(Rag.ragContext&&!confirm("Vuoi iniziare una nuova elabrazione ?"))return"";showSpinner();setOutText("");var a=this.inp.value.trim();try{const b=await Rag.requestDocsRAG(a);setOutText(b);this.inp.value="";UaLog.close()}catch(b){a
|
175 |
-
await Rag.requestContext(a);if(""==b){hideSpinner();return}setOutText(b);this.inp.value=""}catch(b){a=`send2\n${b}`,
|
|
|
176 |
TextOutput={init(){this.copyBtn=document.querySelector(".copy-output");this.copyBtn.addEventListener("click",()=>this.copy());document.querySelector(".clear-output").addEventListener("click",()=>this.clear());document.querySelector(".wnd-output").addEventListener("click",()=>this.openWnd())},openWnd(){const a=document.getElementById("id-text-out").textContent;wnds.wout.show(a)},async copy(){const a=document.getElementById("id-text-out").querySelector("pre");if(a){var b=a.textContent;a.classList.add("copied");
|
177 |
-
this.copyBtn.classList.add("copied");try{await navigator.clipboard.writeText(b)}catch(c){
|
178 |
a.show()},async upload(){const a=document.getElementById("id_fileupload").files[0];if(a){var b=a.name;if(DataMgr.doc_names.includes(b))alert("Il file \u00e8 gi\u00e0 in archivio");else{var c=document.getElementById("result"),d=a.name.split(".").pop().toLowerCase();showSpinner();try{let e;if("pdf"===d){const f=new PdfHandler;await f.loadPdfJs();e=await f.extractTextFromPDF(a);f.cleanup()}else if("txt"===d)e=await readTextFile(a);else{alert("Formato file non supportato.");return}DataMgr.addDoc(b,e);
|
179 |
c.innerHTML=`<br><br> ${b}<br><br>caricato e salvato nella memoria locale`}catch(e){xerror("Error:",e),alert("Errore durante l'estrazione del testo dal file.")}finally{hideSpinner()}}}else alert("Nessun file selezionato.")},openDir(){const a=UaWindowAdm.create("id_upload");a.drag();a.setZ(12);a.vw_vh().setXY(16.5,10,-1);a.setHtml('\n <div class="window-text">\n <div class="btn-wrapper">\n <button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>\n </div> \n <div class="upload"> \n <h4>Upload files Text / PDF</h4> \n <form id="uploadForm">\n <input id="id_fileupload" class="file" type="file" webkitdirectory mozdirectory msdirectory odirectory directory multiple />\n <button type="button" onclick="RagUpload.uploadDir();">Upload and Convert</button>\n </form>\n <div class="result" id="result"></div>\n </div>\n </div>\n ');
|
180 |
a.show()},async uploadDir(){var a=document.getElementById("id_fileupload").files;if(a&&0!=a.length){var b=[];showSpinner();try{for(const c of a){const d=c.name;UaLog.log_show(d);if(DataMgr.doc_names.includes(d)){UaLog.log_shw(d+" : \u00e8 gi\u00e0 in archivio");continue}const e=c.name.split(".").pop().toLowerCase();let f;if("pdf"===e){const g=new PdfHandler;await g.loadPdfJs();f=await g.extractTextFromPDF(c);g.cleanup()}else if("txt"===e)f=await readTextFile(c);else{alert("Formato file non supportato.");
|
@@ -183,11 +217,9 @@ class PdfHandler{constructor(){this.workerScriptElement=this.scriptElement=this.
|
|
183 |
document.body.appendChild(this.workerScriptElement);this.workerScriptElement.onload=a}}));this.pdfjsLib=window["pdfjs-dist/build/pdf"];this.pdfjsLib.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js"}async extractTextFromPDF(a){a=await a.arrayBuffer();a=await this.pdfjsLib.getDocument({data:a}).promise;let b="";for(let c=1;c<=a.numPages;c++){const d=(await (await a.getPage(c)).getTextContent()).items.map(e=>e.str).join(" ");b+=d+"\n"}return b}cleanup(){this.scriptElement&&
|
184 |
(document.body.removeChild(this.scriptElement),this.scriptElement=null);this.workerScriptElement&&(document.body.removeChild(this.workerScriptElement),this.workerScriptElement=null);this.pdfjsLib=null;window.gc&&window.gc()}}
|
185 |
async function readTextFile(a){if(!a||"text/plain"!==a.type)throw Error("Invalid file type. Please select a text file.");return new Promise((b,c)=>{const d=new FileReader;d.onload=e=>b(e.target.result);d.onerror=e=>c(Error("Error reading file: "+e.message));d.readAsText(a)})};const nodrag_tds=["input","select","a"],nodrag_cls="nodrag";
|
186 |
-
var UaDrag=function(a){return function(b){let c=0,d=0,e=0,f=0;const g=function(h){h=h||window.event;h.preventDefault();c=e-h.clientX;d=f-h.clientY;e=h.clientX;f=h.clientY;b.style.top=b.offsetTop-d+"px";b.style.left=b.offsetLeft-c+"px"},
|
187 |
-
|
188 |
-
|
189 |
-
b[d];const c={background:"#444444",color:"#ffffff",padding:"5px 5px 5px 5px",margin:"0 5px 0 5px",fontSize:"16px",fontWeight:"bold",border:"1px solid #ffffff",borderRadius:"10px"};a=document.querySelectorAll("#ualog_ button");for(const d of a){for(const e in c)d.style[e]=c[e];d.addEventListener("mouseover",e=>{e.target.style.cursor="pointer";e.target.style.color="#000000";e.target.style.background="#aaaaaa"});d.addEventListener("mouseout",e=>{for(const f in c)e.target.style[f]=c[f]})}this.x?this.wind.vw_vh().setXY(this.x,
|
190 |
-
this.y,-1):this.wind.setCenter(-1);this.z&&this.wind.setZ(this.z);return this},setXY(a,b){this.x=a;this.y=b;return this},setZ(a){this.z=a;return this},prn_(...a){a=a.join("<br/>");let b=document.getElementById(this.msg_id);b.innerHTML=b.innerHTML+a+"<br/>"},print(...a){null!=this.wind&&this.active&&this.prn_(...a)},log(...a){null!=this.wind&&this.prn_(...a)},log_show(...a){null!=this.wind&&(this.active||this.toggle(),this.prn_(...a))},cls(){if(null!=this.wind)return document.getElementById(this.msg_id).innerHTML=
|
191 |
"",this},close(){null!=this.wind&&(this.wind.hide(),this.active=!1,this.callHide())},toggle(){null!=this.wind&&(this.active?(this.active=!1,this.wind.hide(),this.callHide()):(this.active=!0,this.wind.show(),this.callShow()))}};var UaWindowAdm={ws:{},create(a,b=null){let c=document.getElementById(a);c||(c=document.createElement("div"),b?document.getElementById(b).appendChild(c):document.body.appendChild(c),c.id=a,c.setAttribute("data-name","ua-window"),b=this.newUaWindow(c),this.ws[a]=b);a=this.ws[a];c.style.display="none";return a},get(a){return this.ws[a]?this.ws[a]:null},show(a){this.ws[a]&&this.ws[a].show()},close(a){this.ws[a]&&this.ws[a].close()},toggle(a){this.ws[a]&&this.ws[a].toggle()},hide(a){this.ws[a]&&this.ws[a].hide()},
|
192 |
closeThis(a){a=a.closest('[data-name="ua-window"]').id;this.ws[a].close()},showAll(){for(let a in this.ws)this.ws[a].show()},hideAll(){for(let a in this.ws)this.ws[a].hide()},closeAll(){for(let a in this.ws)this.ws[a].close()},remove(a){this.ws[a]&&(document.getElementById(a).remove(),this.ws[a]=null,delete this.ws[a])},removeAll(){for(let a in this.ws)this.remove(a);this.ws={}},newUaWindow(a){let b={initialize(c){this.w=c;this.wy=this.wx="0px";this.isVisible=this.isOpen=!1;this.firstShow=!0;this.wz=
|
193 |
this.pos=0;this.vh=this.vw="px"},vw_vh(){this.vw="vw";this.vh="vh";return this},addClassStyle(c){this.w.classList.contains(c)||this.w.classList.add(c);return this},removeClassStyle(c){this.w.classList.contains(c)&&this.w.classList.remove(c);return this},getWindow(){alert("getWindow => ??");return this.w},getElement(){return this.w},getId(){return this.w.id},setStyle(c){for(const d in c)this.w.style[d]=c[d];return this},setHtml(c){this.w.innerHTML=c;return this},getHtml(){return this.w.innerHTML},
|
|
|
1 |
+
const removeChars=a=>a.replace(/[\u00AD\u200B\u200C\u200D\u2060\uFEFF]/g,""),replaceChars=a=>a.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g," "),removeTag=a=>a.replace(/<<</g,"").replace(/>>>/g,"").replace(/<<|>>/g,""),ALLOWED_CHARS=/\w\s\u00e0\u00e8\u00e9\u00ec\u00f2\u00f9\u00c0\u00c8\u00c9\u00cc\u00d2\u00d9\u00e1\u00e9\u00ed\u00f3\u00fa\u00c1\u00c9\u00cd\u00d3\u00da\u00e4\u00eb\u00ef\u00f6\u00fc\u00c4\u00cb\u00cf\u00d6\u00dc\u00e2\u00ea\u00ee\u00f4\u00fb\u00c2\u00ca\u00ce\u00d4\u00db\u00e7\u00c7\u00f1\u00d1.,;:!?'"()-/,
|
2 |
+
cleanDoc=a=>{try{return a=removeTag(a),a=removeChars(a),a=replaceChars(a),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/[\t\r]/g," "),a=a.replace(/\u201c/g,'"').replace(/\u201d/g,'"'),a=a.replace(new RegExp(`[^${ALLOWED_CHARS.source}]`,"g")," "),a=a.replace(/ +([.,;:!?])/g,"$1"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),"Errore di codifica nella risposta"}},cleanResponse=a=>{try{return a=removeChars(a),a=replaceChars(a),a=a.replace(/\n\s*\n/g,"\n"),a=a.replace(/[\t\r\n]/g," "),
|
3 |
+
a=a.replace(new RegExp(`[^${ALLOWED_CHARS.source}]`,"g")," "),a=a.replace(/ +([.,;:!?])/g,"$1"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),"Errore di codifica nella risposta"}},cleanOutput=a=>{txt=removeTag(txt);a=a.trim();a=a.replace(/\n{3,}/g,"\n\n");a=a.replace(/^\s+/gm,"");a=a.replace(/^(\s*[-*\u2022])(\s*)/gm,"\n$1 ");a=a.replace(/^(\s*\d+\.)(\s*)/gm,"\n$1 ");a=a.replace(/(```[\s\S]*?```)/g,"\n\n$1\n\n");a=a.replace(/\.(?!\n|$)/g,".\n");return a=a.replace(/\s+$/gm,"")};
|
4 |
+
function subResponseDOcTag(a){return a.replace(/<<<(.*?)>>>/,(b,c)=>`Documento: ${c}`)};const ID_RESPONSES="id_responses",ID_DOC_NAMES="id_doc_names",ID_DOCS="id_docs;",ID_RAG="id_rag",ID_THREAD="id_thread",UaDb={create(a,b){localStorage.getItem(a)?xerror(`ID ${a} already exists.`):localStorage.setItem(a,b)},read(a){const b=localStorage.getItem(a);return null===b?(xlog(`UaDb.read ${a} not found.`),""):b},update(a,b){localStorage.getItem(a)?localStorage.setItem(a,b):xlog(`UaDb.update ${a} not found.`)},delete(a){localStorage.getItem(a)?localStorage.removeItem(a):xerror(`ID ${a} not found.`)},
|
|
|
|
|
|
|
5 |
save(a,b){localStorage.setItem(a,b)},getAllIds(){const a=[];for(let b=0;b<localStorage.length;b++)a.push(localStorage.key(b));return a},saveArray(a,b){b=JSON.stringify(b);UaDb.save(a,b)},readArray(a){a=UaDb.read(a);return 0==a.trim().length?[]:JSON.parse(a)},saveJson(a,b){b=JSON.stringify(b);UaDb.save(a,b)},readJson(a){return(a=UaDb.read(a))?JSON.parse(a):{}}},DataMgr={docs:[],doc_names:[],linkToName(a){a=a.split("/");return a[a.length-1]},async loadDoc(a){try{const b=await requestGet(a),c=cleanDoc(b),
|
6 |
d=this.linkToName(a);this.doc_names.push(d);this.docs.push(c);this.saveDbDocs();return c}catch(b){alert("loadDoc()\n"+b+"\n"+a)}},addDoc(a,b){b=cleanDoc(b);this.docs.push(b);this.doc_names.push(a);this.saveDbDocs()},saveDbDocs(){UaDb.saveArray(ID_DOC_NAMES,this.doc_names);UaDb.saveArray(ID_DOCS,this.docs)},readDbDocs(){this.docs=UaDb.readArray(ID_DOCS)},readDbDocNames(){this.doc_names=UaDb.readArray(ID_DOC_NAMES)},deleteJsonDati(){const a=UaDb.getAllIds();for(const b of a)[ID_DOCS,ID_DOC_NAMES].includes(b)||
|
7 |
UaDb.delete(b);Rag.ragQuery="";Rag.ragContext="";Rag.ragResponse="";Rag.responses=[];Rag.prompts=[];ThreadMgr.rows=[]}};const arr=["bWtkW0l+XX0=","SXx2d1FxbVc=","V1tRXlxneUY=","flV6a1NdbUg=","VllpUkc="],model_name="mistralai/Mistral-7B-Instruct-v0.3",umgm=a=>a.map(b=>atob(b).split("").map(c=>String.fromCharCode((c.charCodeAt(0)-5+256)%256)).join("")).join(""),tm=umgm(arr);
|
8 |
async function requestGet(a){try{var b=await fetch(a,{method:"GET",headers:{"Content-Type":"text/plain;charset=UTF-8"}});if(!b.ok)throw Error(`HTTP error! status: ${b.status}`);const c=await b.arrayBuffer();return(new TextDecoder("utf-8")).decode(c)}catch(c){throw console.error(c),b="AbortError"===c.name?"Request was aborted":c.message.includes("HTTP error! status")?c.message:"An error occurred",alert(`requestGet()\nurl: ${a}\n${b}`),c;}}
|
9 |
const ERROR_TOKENS="ERROR_TOKENS",TIMEOUT_ERROR="TIMEOUT_ERROR",HfRequest={controller:null,isCancelled:!1,baseUrl:"https://api-inference.huggingface.co/models",async post(a,b=5E4){this.isCancelled=!1;this.controller=new AbortController;try{const c=setTimeout(()=>{this.controller.abort()},b),d=await fetch(`${this.baseUrl}/${model_name}`,{method:"POST",headers:{Authorization:`Bearer ${tm}`,"Content-Type":"application/json"},body:JSON.stringify(a),signal:this.controller.signal});clearTimeout(c);if(this.isCancelled)return null;
|
10 |
+
const e=await d.json();if(!d.ok){const g=this.checkError(d.status,e),m=this.createErrorInfo(d.status,d.statusText,e.error,g);throw Error(m);}const f=this.isInvalidResponse(e);if("string"===typeof f){const g=this.createErrorInfo(d.status,d.statusText,e.error,f);throw Error(g);}return e[0].generated_text.trim()}catch(c){if(this.isCancelled)return null;if("AbortError"===c.name)throw a=this.createErrorInfo(0,"Timeout","La richiesta \u00e8 scaduta",TIMEOUT_ERROR),Error(a);throw c;}},cancelRequest(){this.controller&&
|
11 |
(this.isCancelled=!0,this.controller.abort())},checkError(a,b){return 500<=a?"SERVER_ERROR":400<=a&&500>a?"object"===typeof b&&"validation"===b.error_type?b.error.includes("tokens")?ERROR_TOKENS:"ERROR_VALIDATION":"CLIENT_ERROR":"UNKNOWN_ERROR"},isInvalidResponse(a){return a&&Array.isArray(a)&&0!==a.length?a[0].generated_text?null:"MISSING_GENERATED_TEXT":"INVALID_DATA"},createErrorInfo(a,b,c,d){return JSON.stringify({status:a,statusText:b,errorType:d,message:c||"Errore sconosciuto"})}};
|
12 |
function errorInfo(a){return JSON.parse(a.message)}function errorToText(a){a=JSON.parse(a.message);return`Error:
|
13 |
Status: ${a.status}
|
|
|
31 |
You should have received a copy of the GNU General Public License
|
32 |
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
33 |
*/
|
34 |
+
const MAX_PROMPT_LENGTH=81920,PROMPT_DECR=2048,TIMEOUT=6E4,truncInput=(a,b)=>a.substring(0,a.length-b),getPartSize=(a,b,c)=>{c=MAX_PROMPT_LENGTH-c;a.length+b.length<c?c=a.length:(a=a.indexOf(".",c),a=(-1!=a?a:c)+1,a>c+100&&(a=c),c=a);return c},getPartDoc=(a,b)=>{const c=a.substring(0,b);a=a.substring(b).trim();return[c,a]},ragLog=(a,b,c,d)=>{const e=MAX_PROMPT_LENGTH;d=d.reduce((f,g)=>f+g.length,0);xlog(`${a} mx:${e} lft:${b} rgt:${c} arr:${d}`);UaLog.log(`${a} ${b} ${c} ${d}`)},Rag={ragContext:"",
|
35 |
+
ragQuery:"",ragResponse:"",responses:[],contextAnswers:[],prompts:[],doc:"",doc_part:"",init(){this.readRespsFromDb();this.readFromDb()},saveToDb(){UaDb.saveJson(ID_RAG,{context:this.ragContext,ragquery:this.ragQuery,ragresponse:this.ragResponse});UaDb.saveArray(ID_THREAD,ThreadMgr.rows)},readFromDb(){const a=UaDb.readJson(ID_RAG);this.ragContext=a.context||"";this.ragQuery=a.ragquery||"";this.ragResponse=a.ragresponse||"";ThreadMgr.rows=UaDb.readArray(ID_THREAD)},saveRespToDb(){UaDb.saveArray(ID_RESPONSES,
|
36 |
+
this.responses)},readRespsFromDb(){this.responses=UaDb.readArray(ID_RESPONSES)},async requestDocsRAG(a){DataMgr.deleteJsonDati();DataMgr.readDbDocNames();DataMgr.readDbDocs();this.ragQuery=a;var b=0;try{for(var c=0;c<DataMgr.docs.length;c++){let e=DataMgr.docs[c];if(""==e.trim())continue;const f=DataMgr.doc_names[c],g=e.length;xlog(`${f} (${g}) `);UaLog.log(`${f} (${g}) `);++b;var d=0;let m=0,h="",l="",r="",k="",p=[];for(;;){let q=getPartSize(e,promptDoc("",a,""),m);if(10>q)break;[l,r]=getPartDoc(e,
|
37 |
+
q);ragLog(`${b},${d+1}`,l.length,r.length,this.responses);h=promptDoc(l,a,f);const n=getPayloadDoc(h);try{if(k=await HfRequest.post(n,TIMEOUT),!k)return""}catch(t){if(errorInfo(t).errorType===ERROR_TOKENS){UaLog.log(`Error tokens Doc ${l.length}`);console.error(`Error tokens. Doc ${h.length}`);m+=PROMPT_DECR;continue}else throw console.error(t),t;}d++;e=r;k=cleanResponse(k);p.push(k);this.responses.push(`DOCUMENTO : ${f}\n${k}`)}d=0;if(1==p)k=p[0],d=k.length;else for(k=p.join("\n"),d=k.length;;){h=
|
38 |
+
promptBuildContext(k);const q=getPayloadBuildContext(h);try{if(k=await HfRequest.post(q,TIMEOUT),!k)return""}catch(n){if(errorInfo(n).errorType===ERROR_TOKENS){UaLog.log(`Error tokens build Context ${l.length}`);console.error(`Error tokens buildContext. ${h.length}`);k=truncInput(k,PROMPT_DECR);continue}else throw console.error(n),n;}break}UaLog.log(`context ${d} => ${k.length}`);k=cleanResponse(k);k=`DOCUMENTO: ${f}\n ${k}`;this.contextAnswers.push(k)}}catch(e){throw console.error(e),e;}this.ragContext=
|
39 |
+
this.contextAnswers.join("\n");this.saveToDb();b="";c=this.ragContext;try{for(;;){let e=promptWithContext(c,a);const f=getPayloadWithContext(e);try{if(b=await HfRequest.post(f,TIMEOUT),!b)return""}catch(g){if(errorInfo(g).errorType===ERROR_TOKENS){UaLog.log(`Error tokens with COntext ${lft.length}`);console.error(`Error tokens context. Doc ${e.length}`);c=truncInput(c,PROMPT_DECR);continue}else throw console.error(g),g;}break}this.ragResponse=b=cleanResponse(b);this.saveRespToDb();ThreadMgr.init();
|
40 |
+
this.saveToDb();UaLog.log(`Risposta (${prompt.length},${b.length})`)}catch(e){throw console.error(e),b=`${e}`,e;}finally{return b}},async requestContext(a){let b="";if(!this.ragContext&&!await confirm("Contesto vuoto. Vuoi continuare?"))return"";if(ThreadMgr.isFirst()){ThreadMgr.init();try{var c=this.ragContext;let d=ThreadMgr.getThread();for(;;){prompt=promptThread(c,d,a);const e=getPayloadThread(prompt);try{if(b=await HfRequest.post(e,TIMEOUT),!b)return""}catch(f){if(errorInfo(f).errorType===ERROR_TOKENS){UaLog.log(`Error tokens Thread Init ${prompt.length}`);
|
41 |
+
console.error(`Error tokens Thread Init. ${prompt.length}`);d=truncInput(d,PROMPT_DECR);continue}else throw console.error(f),f;}break}b=cleanResponse(b);ThreadMgr.add(a,b);b=ThreadMgr.getThread();UaLog.log(`Inizio Conversazione (${prompt.length},${b.length})`)}catch(d){throw console.error(d),b=`${d}`,d;}finally{return b}}else try{let d=this.ragContext,e=ThreadMgr.getThread();for(c="";;){c=promptThread(d,e,a);const f=getPayloadThread(c);try{if(b=await HfRequest.post(f,TIMEOUT),!b)return""}catch(g){if(errorInfo(g).errorType===
|
42 |
+
ERROR_TOKENS){UaLog.log(`Error tokens Thread ${c.length}`);console.error(`Error tokens Thread. ${c.length}`);e=truncInput(e,PROMPT_DECR);continue}else throw console.error(g),g;}break}b=cleanResponse(b);ThreadMgr.add(a,b);b=ThreadMgr.getThread();UaLog.log(`Conversazione (${c.length},${b.length})`)}catch(d){throw console.error(d),b=`${d}`,d;}finally{return b}}},LLM="Assistant:",USER="User:",ThreadMgr={rows:[],init(){this.rows=[];Rag.ragResponse?this.add(Rag.ragQuery,Rag.ragResponse):this.add("",
|
43 |
+
"")},add(a,b){this.rows.push([a,b]);UaDb.saveArray(ID_THREAD,ThreadMgr.rows)},getThread(){const a=[];for(const b of this.rows)a.push(`\n${USER}\n${b[0]}\n${LLM}\n${b[1]}\n`);return a.join("").trim()},isFirst(){return 2>this.rows.length}};function promptDoc(a,b,c){return`
|
44 |
SYSTEM:
|
45 |
+
Sei un assistente AI specializzato nell'analisi di documenti.Rispondi sempre ed esclusivamente in italiano.
|
46 |
|
47 |
TASK:
|
48 |
Analizzare il documento ${c} ed estrarre le informazioni rilevanti per rispondere alla domanda fornita.
|
|
|
50 |
INSTRUCTIONS:
|
51 |
1. Analizza attentamente il documento fornito e identifica le informazioni pertinenti alla domanda.
|
52 |
2. Estrai i concetti chiave e fai inferenze ragionevoli.
|
53 |
+
3. Organizza le informazioni in modo logico.
|
54 |
+
4. Prepara una risposta chiara e completa.
|
55 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
56 |
6. Cita le fonti quando \u00e8 utile per chiarire informazioni o inferenze.
|
57 |
+
7. Assicurati che la risposta sia interamente in italiano,se nel testo \u00e8 usata un'altra lingua traduci in italiano.
|
58 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
59 |
|
60 |
DOCUMENT:
|
|
|
66 |
${b}
|
67 |
|
68 |
OUTPUT_FORMAT:
|
69 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, introduzioni, elenchi o marcatori speciali.
|
70 |
|
71 |
RESPONSE:
|
72 |
+
`}function promptBuildContext(a){return`
|
73 |
+
SYSTEM:
|
74 |
+
Sei un assistente AI specializzato nell'analisi di documenti.Rispondi sempre ed esclusivamente in italiano.
|
75 |
+
|
76 |
+
TASK:
|
77 |
+
Analizza e riorganizza logicamente il documento fornito. Attieniti rigorosamente alle istruzioni.
|
78 |
+
|
79 |
+
INSTRUCTIONS:
|
80 |
+
1. Valuta la tipologia e lo scopo del documento (es. articolo scientifico, racconto,saggio, documento tecnico) e adatta l'analisi di conseguenza.
|
81 |
+
2. Analizza attentamente il documento e identifica i temi principali e i concetti chiave.
|
82 |
+
3. Estrai i concetti chiave e fai inferenze ragionevoli.
|
83 |
+
4. Organizza le informazioni in una struttura logica e coerente, eliminando ridondanze e ripetizioni.
|
84 |
+
5. Prepara una risposta che riorganizzi i contenuti, dando priorit\u00e0 alle informazioni pi\u00f9 importanti o rilevanti.
|
85 |
+
6. Includi un'introduzione breve che presenti i temi principali.
|
86 |
+
7. Sviluppa l'analisi raggruppando le informazioni per argomenti correlati.
|
87 |
+
8. Presenta le inferenze e le connessioni tra i diversi concetti.
|
88 |
+
9. Se presenti informazioni contrastanti, evidenziale senza eliminarle.
|
89 |
+
10. Includi, se rilevanti, dettagli specifici come nomi propri, termini tecnici, date o luoghi che contribuiscono alla precisione del contesto.
|
90 |
+
11. Concludi con una sintesi che riassuma i punti chiave e la struttura logica.
|
91 |
+
12. Se il documento contiene sezioni distinte, analizzale separatamente ma evidenzia le connessioni tra di esse.
|
92 |
+
13. Effettua un controllo finale per assicurarti che tutte le informazioni chiave siano state incluse.
|
93 |
+
14. Assicurati che la risposta sia interamente in italiano.
|
94 |
+
15. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
95 |
+
|
96 |
+
DOCUMENT:
|
97 |
+
<<<BEGIN_DOCUMENT>>>
|
98 |
+
${a}
|
99 |
+
<<<END_DOCUMENT>>>
|
100 |
+
|
101 |
+
OUTPUT_FORMAT:
|
102 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, elenchi o marcatori speciali.
|
103 |
+
|
104 |
+
RESPONSE:
|
105 |
+
`}function promptWithContext(a,b){return`
|
106 |
SYSTEM:
|
107 |
Sei un assistente AI specializzato nell'analisi e nell'elaborazione di informazioni contestuali. Rispondi sempre in italiano.
|
108 |
|
|
|
116 |
4. Struttura la risposta in paragrafi logici.
|
117 |
5. Includi un'introduzione breve, sviluppa l'analisi, presenta le inferenze e concludi con una sintesi.
|
118 |
6. Se la domanda richiede di citare le fonti, fai riferimento al documento fornito distinguendolo chiaramente da eventuali altre fonti citate all'interno del documento stesso.
|
119 |
+
7. Assicurati che la risposta sia interamente in italiano.
|
120 |
8. Mantieni un tono oggettivo e uno stile fluido e coerente.
|
121 |
|
122 |
CONTEXT:
|
|
|
149 |
8. Se l'intento non \u00e8 chiaro, chiedi gentilmente chiarimenti invece di fare supposizioni.
|
150 |
9. Sii flessibile: se la richiesta implica un'azione specifica, adattati di conseguenza.
|
151 |
10. Se \u00e8 necessario integrare con conoscenze generali, specifica chiaramente quando lo stai facendo.
|
152 |
+
11. Assicurati che la risposta sia interamente in italiano.
|
153 |
|
154 |
CONTEXT:
|
155 |
<<<BEGIN_CONTEXT>>>
|
|
|
164 |
${c}
|
165 |
|
166 |
OUTPUT_FORMAT:
|
167 |
+
Rispondi con un testo continuo suddiviso in paragrafi. Inizia direttamente con il contenuto. Evita di usare etichette, elenchi o marcatori speciali.
|
168 |
|
169 |
RESPONSE:
|
170 |
+
`}function getPayloadDoc(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:1024,num_return_sequences:1,temperature:.5,top_k:50,top_p:.7,do_sample:!1,no_repeat_ngram_size:4,num_beams:4,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:90,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
171 |
+
function getPayloadBuildContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:4096,num_return_sequences:1,temperature:.4,top_k:20,top_p:.8,do_sample:!1,no_repeat_ngram_size:4,num_beams:6,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:120,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
172 |
function getPayloadWithContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2048,num_return_sequences:1,temperature:.6,top_k:50,top_p:.7,do_sample:!1,no_repeat_ngram_size:4,num_beams:5,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:120,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
173 |
+
function getPayloadThread(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2048,num_return_sequences:1,temperature:.6,top_k:50,top_p:.7,do_sample:!1,no_repeat_ngram_size:4,num_beams:5,repetition_penalty:1.4,return_full_text:!1,details:!1,max_time:120,seed:42},options:{use_cache:!1,wait_for_model:!0}}};const VERS="0.1.43 (12-08-2024)";var xlog=console.log,xerror=console.error;const cancelRequest=()=>{confirm("Confermi Cancellazione Richeista ?")&&(HfRequest.cancelRequest(),hideSpinner())},showSpinner=()=>{const a=document.getElementById("spinner");a.classList.add("show-spinner");a.addEventListener("click",cancelRequest)},hideSpinner=()=>{const a=document.getElementById("spinner");a.classList.remove("show-spinner");a.removeEventListener("click",cancelRequest)};
|
174 |
+
function openApp(){wnds.init();Menu.init();TextInput.init();TextOutput.init();Rag.init();document.querySelector(".menu-btn").checked=!1;release()}function release(){document.querySelector(".release").innerHTML=VERS}const op0=async function(a){a=await requestGet("./help1.html");wnds.wdiv.show(a)};function showQuery(a){wnds.wpre.show(`\n${Rag.ragQuery}`)}function showRagResponse(a){wnds.wpre.show(`\n${Rag.ragResponse}`)}function showThread(a){a=ThreadMgr.getThread();wnds.wpre.show(a)}
|
175 |
function elencoRisposte(a){a=[...Rag.responses];0==a.length&&(a=UaDb.readArray(ID_RESPONSES));0!=a.length&&(a=a.map((b,c)=>{b=subResponseDOcTag(b);return`\n[${c+1}]\n ${b.trim()}`}).join("\n"),wnds.wpre.show(a))}function showContesto(a){wnds.wpre.show(`${Rag.ragContext}`)}function elencoDati(a){var b=UaDb.getAllIds();a=[];for(var c of b)b=UaDb.read(c).length,a.push(`${c} (${b})`);c=a.join("\n ");wnds.wpre.show(c)}
|
176 |
async function elencoDocs(a){DataMgr.readDbDocNames();a=DataMgr.doc_names.join("\n");wnds.wpre.show(a)}
|
177 |
function calcQuery(){DataMgr.readDbDocs();DataMgr.readDbDocNames();var a=[];let b=0,c=0;a.push("Documento Num.Parti");a.push("==================");for(const d of DataMgr.docs){const e=DataMgr.doc_names[c];c+=1;const f=Math.ceil(d.length/MAX_PROMPT_LENGTH);b+=f;a.push(`${e} [${f}]`)}a.push("==================");a.push(`Totale num. Parti: ${b}`);a=a.join("\n");wnds.wpre.show(a)}
|
|
|
188 |
</div>
|
189 |
<pre class="pre-text">${b}</pre>
|
190 |
</div>
|
191 |
+
`;this.w.drag();this.w.setZ(12);this.w.vw_vh().setXY(16.5,10,-1);this.w.setHtml(b);this.w.show();this.w.getElement().querySelector(".btn-copy").addEventListener("click",()=>this.copy())},close(){this.w.close()},async copy(){const b=this.w.getElement().querySelector(".pre-text").textContent;try{await navigator.clipboard.writeText(b)}catch(c){console.error("Errore ",c)}}}),WndDiv=a=>({w:UaWindowAdm.create(a),out:null,show(b){wnds.closeAll();b=`
|
192 |
<div class="window-text">
|
193 |
<div class="btn-wrapper">
|
194 |
<button class="btn-copy" title="Copia">
|
|
|
200 |
</div>
|
201 |
<div class="div-text">${b}</div>
|
202 |
</div>
|
203 |
+
`;this.w.drag();this.w.setZ(12);this.w.vw_vh().setXY(16.5,10,-1);this.w.setHtml(b);this.w.show();this.w.getElement().querySelector(".btn-copy").addEventListener("click",()=>this.copy())},close(){this.w.close()},async copy(){const b=this.w.getElement().querySelector(".div-text").textContent;try{await navigator.clipboard.writeText(b)}catch(c){console.error("Errore ",c)}}}),wnds={wdiv:null,wpre:null,wout:null,init(){this.wdiv=WndDiv("id_w0");this.wpre=WndPre("id_w1");this.wout=WndPre("id_out")},
|
204 |
+
closeAll(){UaWindowAdm.close("id_w0");UaWindowAdm.close("id_w1");UaWindowAdm.close("id_out")}},Menu={init(){const a=document.querySelector("#id-menu-btn");a.addEventListener("change",()=>{document.querySelector("body").classList.toggle("menu-open",a.checked)});const b=document.getElementById("id_log");UaLog.callHide=()=>{b.classList.contains("active")&&b.classList.remove("active")};UaLog.callShow=()=>{b.classList.contains("active")||b.classList.add("active")};UaLog.setXY(54,13).setZ(111).new();UaLog.log_show("Buon Lavoro")},
|
205 |
+
close(){const a=document.querySelector("#menu-toggle");document.querySelector("body").classList.remove("menu-open",a.checked);document.querySelector(".menu-btn").checked=!1},async help(){const a=await requestGet("./help0.html");wnds.wdiv.show(a)},upload(){RagUpload.open()},uploadDir(){RagUpload.openDir()},async load(){alert("load")},log(){UaLog.toggle()}},TextInput={wnd:null,init(){this.inp=document.querySelector(".text-input");document.addEventListener("keydown",a=>{document.activeElement!==this.inp&&
|
206 |
+
("F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Control Alt Shift Meta CapsLock Escape PrintScreen ScrollLock Pause Insert Delete Home End PageUp PageDown ArrowLeft ArrowRight ArrowUp ArrowDown".split(" ").includes(a.key)||a.ctrlKey||a.metaKey||a.preventDefault())});document.querySelector(".clear-button").addEventListener("click",()=>{this.inp.value="";this.inp.focus()});this.inp.addEventListener("keydown",a=>this.handleEnter(a));document.querySelector(".send-input").addEventListener("click",()=>this.send());
|
207 |
+
document.querySelector(".send2-input").addEventListener("click",()=>this.send2());document.querySelector(".clear-input").addEventListener("click",()=>this.clear())},handleEnter(a){"Enter"!==a.key||a.shiftKey||(a.preventDefault(),this.send2())},async send(){if(this.inp.value){if(Rag.ragContext&&!confirm("Vuoi iniziare una nuova elabrazione ?"))return"";showSpinner();setOutText("");var a=this.inp.value.trim();try{const b=await Rag.requestDocsRAG(a);setOutText(b);this.inp.value="";UaLog.close()}catch(b){a=
|
208 |
+
`send\n${b}`,console.error(a),alert(a),setOutText(a)}hideSpinner()}else alert("Ricorda di scrivere la Query ")},async send2(){if(this.inp.value){showSpinner();ThreadMgr.isFirst()&&setOutText("");var a=this.inp.value.trim();try{const b=await Rag.requestContext(a);if(""==b){hideSpinner();return}setOutText(b);this.inp.value=""}catch(b){a=`send2\n${b}`,console.error(a),alert(a),setOutText(a)}hideSpinner()}else alert("Ricorda di scrivere la Query ")},clear(){confirm("Confermi cancellazione conversazione? ")&&
|
209 |
+
(this.inp.value="",setOutText(""),ThreadMgr.init())}},setOutText=a=>{var b=document.getElementById("id-text-out");b.innerHTML='<pre class="pre-text"></pre>';b=b.querySelector(".pre-text");b.textContent=a;b.scrollTop=b.scrollHeight};
|
210 |
TextOutput={init(){this.copyBtn=document.querySelector(".copy-output");this.copyBtn.addEventListener("click",()=>this.copy());document.querySelector(".clear-output").addEventListener("click",()=>this.clear());document.querySelector(".wnd-output").addEventListener("click",()=>this.openWnd())},openWnd(){const a=document.getElementById("id-text-out").textContent;wnds.wout.show(a)},async copy(){const a=document.getElementById("id-text-out").querySelector("pre");if(a){var b=a.textContent;a.classList.add("copied");
|
211 |
+
this.copyBtn.classList.add("copied");try{await navigator.clipboard.writeText(b)}catch(c){console.error("Errore ",c)}setTimeout(()=>{this.copyBtn.classList.remove("copied");a.classList.remove("copied")},5E3)}},clear(){document.getElementById("id-text-out").textContent=""}};const RagUpload={open(){const a=UaWindowAdm.create("id_upload");a.drag();a.setZ(12);a.vw_vh().setXY(16.5,10,-1);a.setHtml('\n <div class="window-text">\n <div class="btn-wrapper">\n <button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>\n </div> \n <div class="upload"> \n <h4>Upload file Text / PDF</h4> \n <form id="uploadForm">\n <input class="file" type="file" id="id_fileupload" > \n <button type="button" onclick="RagUpload.upload();">Upload and Convert</button>\n </form>\n <div id="result" class="result"></div>\n </div>\n </div>\n ');
|
212 |
a.show()},async upload(){const a=document.getElementById("id_fileupload").files[0];if(a){var b=a.name;if(DataMgr.doc_names.includes(b))alert("Il file \u00e8 gi\u00e0 in archivio");else{var c=document.getElementById("result"),d=a.name.split(".").pop().toLowerCase();showSpinner();try{let e;if("pdf"===d){const f=new PdfHandler;await f.loadPdfJs();e=await f.extractTextFromPDF(a);f.cleanup()}else if("txt"===d)e=await readTextFile(a);else{alert("Formato file non supportato.");return}DataMgr.addDoc(b,e);
|
213 |
c.innerHTML=`<br><br> ${b}<br><br>caricato e salvato nella memoria locale`}catch(e){xerror("Error:",e),alert("Errore durante l'estrazione del testo dal file.")}finally{hideSpinner()}}}else alert("Nessun file selezionato.")},openDir(){const a=UaWindowAdm.create("id_upload");a.drag();a.setZ(12);a.vw_vh().setXY(16.5,10,-1);a.setHtml('\n <div class="window-text">\n <div class="btn-wrapper">\n <button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>\n </div> \n <div class="upload"> \n <h4>Upload files Text / PDF</h4> \n <form id="uploadForm">\n <input id="id_fileupload" class="file" type="file" webkitdirectory mozdirectory msdirectory odirectory directory multiple />\n <button type="button" onclick="RagUpload.uploadDir();">Upload and Convert</button>\n </form>\n <div class="result" id="result"></div>\n </div>\n </div>\n ');
|
214 |
a.show()},async uploadDir(){var a=document.getElementById("id_fileupload").files;if(a&&0!=a.length){var b=[];showSpinner();try{for(const c of a){const d=c.name;UaLog.log_show(d);if(DataMgr.doc_names.includes(d)){UaLog.log_shw(d+" : \u00e8 gi\u00e0 in archivio");continue}const e=c.name.split(".").pop().toLowerCase();let f;if("pdf"===e){const g=new PdfHandler;await g.loadPdfJs();f=await g.extractTextFromPDF(c);g.cleanup()}else if("txt"===e)f=await readTextFile(c);else{alert("Formato file non supportato.");
|
|
|
217 |
document.body.appendChild(this.workerScriptElement);this.workerScriptElement.onload=a}}));this.pdfjsLib=window["pdfjs-dist/build/pdf"];this.pdfjsLib.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js"}async extractTextFromPDF(a){a=await a.arrayBuffer();a=await this.pdfjsLib.getDocument({data:a}).promise;let b="";for(let c=1;c<=a.numPages;c++){const d=(await (await a.getPage(c)).getTextContent()).items.map(e=>e.str).join(" ");b+=d+"\n"}return b}cleanup(){this.scriptElement&&
|
218 |
(document.body.removeChild(this.scriptElement),this.scriptElement=null);this.workerScriptElement&&(document.body.removeChild(this.workerScriptElement),this.workerScriptElement=null);this.pdfjsLib=null;window.gc&&window.gc()}}
|
219 |
async function readTextFile(a){if(!a||"text/plain"!==a.type)throw Error("Invalid file type. Please select a text file.");return new Promise((b,c)=>{const d=new FileReader;d.onload=e=>b(e.target.result);d.onerror=e=>c(Error("Error reading file: "+e.message));d.readAsText(a)})};const nodrag_tds=["input","select","a"],nodrag_cls="nodrag";
|
220 |
+
var UaDrag=function(a){return function(b){let c=0,d=0,e=0,f=0;const g=function(h){h=h||window.event;h.preventDefault();c=e-h.clientX;d=f-h.clientY;e=h.clientX;f=h.clientY;b.style.top=b.offsetTop-d+"px";b.style.left=b.offsetLeft-c+"px"},m=function(){document.onmouseup=null;document.onmousemove=null};b.onmousedown=function(h){h=h||window.event;let l=h.target;!(l=l||null)||nodrag_tds.includes(l.tagName.toLowerCase())||l.classList.contains(nodrag_cls)||(h.preventDefault(),e=h.clientX,f=h.clientY,document.onmouseup=
|
221 |
+
m,document.onmousemove=g)}}(a)};const UaJtfh=()=>({rows:[],init(){this.rows=[];return this},insert(a){this.rows.unshift(a);return this},append(a){this.rows.push(a);return this},text(a=""){return this.rows.join(a)},html(a=""){return this.rows.join(a).replace(/\s+|\[rn\]/g," ")}});var UaLog={callHide:function(){},callShow:function(){},active:!1,wind:null,x:null,y:null,z:null,max_length:2E3,msg_id:"ualogmsg_",new:function(){null==this.wind&&(this.wind=UaWindowAdm.create("ualog_"),this.wind.drag());this.wind.setHtml('\n <button type="button" class="clear" onclick="javascript:UaLog.cls();">Clear</button>\n <button type="button" class="close" onclick="javascript:UaLog.close();">Close</button>\n <pre id="ualogmsg_" ></pre>');this.x?this.wind.vw_vh().setXY(this.x,
|
222 |
+
this.y,-1):this.wind.setCenter(-1);this.z&&this.wind.setZ(this.z);return this},setXY(a,b){this.x=a;this.y=b;return this},setZ(a){this.z=a;return this},prn_(...a){a=a.join("\n");let b=document.getElementById(this.msg_id);b.textContent=b.textContent+a+"\n"},print(...a){null!=this.wind&&this.active&&this.prn_(...a)},log(...a){null!=this.wind&&this.prn_(...a)},log_show(...a){null!=this.wind&&(this.active||this.toggle(),this.prn_(...a))},cls(){if(null!=this.wind)return document.getElementById(this.msg_id).innerHTML=
|
|
|
|
|
223 |
"",this},close(){null!=this.wind&&(this.wind.hide(),this.active=!1,this.callHide())},toggle(){null!=this.wind&&(this.active?(this.active=!1,this.wind.hide(),this.callHide()):(this.active=!0,this.wind.show(),this.callShow()))}};var UaWindowAdm={ws:{},create(a,b=null){let c=document.getElementById(a);c||(c=document.createElement("div"),b?document.getElementById(b).appendChild(c):document.body.appendChild(c),c.id=a,c.setAttribute("data-name","ua-window"),b=this.newUaWindow(c),this.ws[a]=b);a=this.ws[a];c.style.display="none";return a},get(a){return this.ws[a]?this.ws[a]:null},show(a){this.ws[a]&&this.ws[a].show()},close(a){this.ws[a]&&this.ws[a].close()},toggle(a){this.ws[a]&&this.ws[a].toggle()},hide(a){this.ws[a]&&this.ws[a].hide()},
|
224 |
closeThis(a){a=a.closest('[data-name="ua-window"]').id;this.ws[a].close()},showAll(){for(let a in this.ws)this.ws[a].show()},hideAll(){for(let a in this.ws)this.ws[a].hide()},closeAll(){for(let a in this.ws)this.ws[a].close()},remove(a){this.ws[a]&&(document.getElementById(a).remove(),this.ws[a]=null,delete this.ws[a])},removeAll(){for(let a in this.ws)this.remove(a);this.ws={}},newUaWindow(a){let b={initialize(c){this.w=c;this.wy=this.wx="0px";this.isVisible=this.isOpen=!1;this.firstShow=!0;this.wz=
|
225 |
this.pos=0;this.vh=this.vw="px"},vw_vh(){this.vw="vw";this.vh="vh";return this},addClassStyle(c){this.w.classList.contains(c)||this.w.classList.add(c);return this},removeClassStyle(c){this.w.classList.contains(c)&&this.w.classList.remove(c);return this},getWindow(){alert("getWindow => ??");return this.w},getElement(){return this.w},getId(){return this.w.id},setStyle(c){for(const d in c)this.w.style[d]=c[d];return this},setHtml(c){this.w.innerHTML=c;return this},getHtml(){return this.w.innerHTML},
|
static/less/ualog3.less
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @format */
|
2 |
+
|
3 |
+
#ualog_ {
|
4 |
+
box-sizing: border-box;
|
5 |
+
width: auto;
|
6 |
+
// min-width: 300px;
|
7 |
+
height: auto;
|
8 |
+
text-align: center;
|
9 |
+
padding: 2px;
|
10 |
+
margin: 2px 0 0 0;
|
11 |
+
background: #333333;
|
12 |
+
color: #ffffff;
|
13 |
+
font-size: 16px;
|
14 |
+
font-weight: normal;
|
15 |
+
border-radius: 9px;
|
16 |
+
border: 1px solid #999999;
|
17 |
+
|
18 |
+
button {
|
19 |
+
padding: 5px;
|
20 |
+
margin: 0 5px;
|
21 |
+
font-size: 18px;
|
22 |
+
font-weight: bold;
|
23 |
+
border: 2px solid #999999;
|
24 |
+
border-radius: 10px;
|
25 |
+
|
26 |
+
&:hover {
|
27 |
+
cursor: pointer;
|
28 |
+
color: #000000;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
@bo: #ff600a;
|
32 |
+
@br: #aeab06;
|
33 |
+
button.close {
|
34 |
+
background: @bo;
|
35 |
+
color: #000000;
|
36 |
+
&:hover {
|
37 |
+
background: lighten(@bo, 20%);
|
38 |
+
text-decoration: underline;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
button.clear {
|
42 |
+
background: @br;
|
43 |
+
color: #000000;
|
44 |
+
&:hover {
|
45 |
+
background: lighten(@br, 20%);
|
46 |
+
text-decoration: underline;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
pre {
|
51 |
+
box-sizing: border-box;
|
52 |
+
width: auto;
|
53 |
+
min-width: 400px;
|
54 |
+
max-width: 400px;
|
55 |
+
max-height: 500px;
|
56 |
+
text-align: left;
|
57 |
+
font-size: 16px;
|
58 |
+
font-family: monospace;
|
59 |
+
padding: 2px;
|
60 |
+
margin: 2px 2px 2px 2px;
|
61 |
+
color: #ffffff;
|
62 |
+
background: #111111;
|
63 |
+
overflow: auto;
|
64 |
+
scrollbar-color: #23eb04 #454444;
|
65 |
+
scrollbar-width: auto;
|
66 |
+
// white-space: pre-wrap;
|
67 |
+
word-wrap: break-word;
|
68 |
+
}
|
69 |
+
}
|
static/ragrqs_.html
CHANGED
@@ -12,13 +12,14 @@
|
|
12 |
<script src="js/ragrqs.min.js"></script>
|
13 |
-->
|
14 |
<link rel="stylesheet" href="less/normalize.css" />
|
15 |
-
<link rel="stylesheet/less"
|
|
|
16 |
<script src="less/less.js"></script>
|
17 |
|
18 |
<script src="javascript/uadrag.js"></script>
|
19 |
<script src="javascript/uawindow.js"></script>
|
20 |
<script src="javascript/uajtfh.js"></script>
|
21 |
-
<script src="javascript/
|
22 |
<script src="javascript/rag_cleaner.js"></script>
|
23 |
<script src="javascript/rag_data_mgr.js"></script>
|
24 |
<script src="javascript/rag_http.js"></script>
|
|
|
12 |
<script src="js/ragrqs.min.js"></script>
|
13 |
-->
|
14 |
<link rel="stylesheet" href="less/normalize.css" />
|
15 |
+
<link rel="stylesheet/less" href="less/ragrqs.less" />
|
16 |
+
<link rel="stylesheet/less" href="less/ualog3.less" />
|
17 |
<script src="less/less.js"></script>
|
18 |
|
19 |
<script src="javascript/uadrag.js"></script>
|
20 |
<script src="javascript/uawindow.js"></script>
|
21 |
<script src="javascript/uajtfh.js"></script>
|
22 |
+
<script src="javascript/ualog3.js"></script>
|
23 |
<script src="javascript/rag_cleaner.js"></script>
|
24 |
<script src="javascript/rag_data_mgr.js"></script>
|
25 |
<script src="javascript/rag_http.js"></script>
|