Upload folder using huggingface_hub
Browse files- static/css/ragrqs.min.css +1 -1
- static/help0.html +2 -2
- static/javascript/app.js +306 -0
- static/javascript/rag_mgr.js +6 -6
- static/javascript/rag_upload.js +61 -8
- static/js/ragrqs.min.js +34 -32
- static/less/ragrqs.less +55 -24
- static/ragrqs.html +41 -10
- static/ragrqs_.html +30 -13
static/css/ragrqs.min.css
CHANGED
@@ -1 +1 @@
|
|
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.5;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.5;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;overflow-x: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.div-text{color:#f8f292;word-wrap:break-word;font-family:Georigia,"Ties New Roman",serif;font-size:18px;padding:0 2px;margin:0}.window-text div.div-text ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;border-top:1px solid #333}.window-text div.div-text ul li{border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333}.window-text div.div-text ul li a{color:#fff;font-size:14px;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400;display:block;margin:0;padding:5px 2px 2px 0;text-align:left;text-decoration:none}.window-text div.div-text ul li:hover{text-decoration:underline;background-color:#333;color:#33e9c5}.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 #888;border-radius:10px;color:#000}#ualog_ button:hover{cursor:pointer;text-decoration:underline}#ualog_ button.close{background:#cc3700}#ualog_ button.close:hover{background:#ff8f66;border-color:#992900}#ualog_ button.clear{background:#b3a80b}#ualog_ button.clear:hover{background:#f5ec62;border-color:#837b08}#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}
|
|
|
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}.theme-dark .btn-light,.theme-light .btn-dark{display:inline-block!important}.invert,.invert iframe,.invert img,.invert video{filter:invert(100%)}.btn-theme{position:fixed;top:0;right:4vw;height:4vh;background:inherit;font-weight:700;margin-left:5vw;margin-top:.5vh;z-index:2000}.btn-theme button{color:#fff;border:none;background:0 0;cursor:pointer;padding:5px;display:none}.btn-theme button svg{width:24px;height:24px;stroke:currentColor}.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.5;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.5;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:40vw;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:25px;height:100%;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;overflow-x: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.div-text{color:#f8f292;word-wrap:break-word;font-family:Georigia,"Ties New Roman",serif;font-size:18px;padding:0 2px;margin:0}.window-text div.div-text ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;border-top:1px solid #333}.window-text div.div-text ul li{border-left:1px solid #333;border-right:1px solid #333;border-bottom:1px solid #333}.window-text div.div-text ul li a{color:#fff;font-size:14px;font-family:arial,verdana,Helvetica,sans-serif;font-weight:400;display:block;margin:0;padding:5px 2px 2px 0;text-align:left;text-decoration:none}.window-text div.div-text ul li:hover{text-decoration:underline;background-color:#333;color:#33e9c5}.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 #888;border-radius:10px;color:#000}#ualog_ button:hover{cursor:pointer;text-decoration:underline}#ualog_ button.close{background:#cc3700}#ualog_ button.close:hover{background:#ff8f66;border-color:#992900}#ualog_ button.clear{background:#b3a80b}#ualog_ button.clear:hover{background:#f5ec62;border-color:#837b08}#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/help0.html
CHANGED
@@ -7,14 +7,14 @@
|
|
7 |
<div>
|
8 |
Uploa dFiles
|
9 |
<p>
|
10 |
-
Fa l'upload di un file locale. Sono accettati i file pdf e txt.
|
11 |
Controlla se il file è in archivio, per non sovrascriverlo.
|
12 |
</p>
|
13 |
</div>
|
14 |
<div>
|
15 |
Upload Dir:
|
16 |
<p>
|
17 |
-
Per fare l'upload dei files di una dri. Sono accettati i files pdf e txt.
|
18 |
I file in archivio con lo stesso nome non vengono sovrascritti.
|
19 |
</p>
|
20 |
</div>
|
|
|
7 |
<div>
|
8 |
Uploa dFiles
|
9 |
<p>
|
10 |
+
Fa l'upload di un file locale. Sono accettati i file pdf, docx e txt.
|
11 |
Controlla se il file è in archivio, per non sovrascriverlo.
|
12 |
</p>
|
13 |
</div>
|
14 |
<div>
|
15 |
Upload Dir:
|
16 |
<p>
|
17 |
+
Per fare l'upload dei files di una dri. Sono accettati i files pdf, dpcx e txt.
|
18 |
I file in archivio con lo stesso nome non vengono sovrascritti.
|
19 |
</p>
|
20 |
</div>
|
static/javascript/app.js
ADDED
@@ -0,0 +1,306 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @format */
|
2 |
+
/**
|
3 |
+
* @license
|
4 |
+
* rag_rqs
|
5 |
+
* Copyright (C) 2024 [Il tuo nome]
|
6 |
+
*
|
7 |
+
* This program is free software: you can redistribute it and/or modify
|
8 |
+
* it under the terms of the GNU General Public License as published by
|
9 |
+
* the Free Software Foundation, either version 3 of the License, or
|
10 |
+
* (at your option) any later version.
|
11 |
+
*
|
12 |
+
* This program is distributed in the hope that it will be useful,
|
13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
+
* GNU General Public License for more details.
|
16 |
+
*
|
17 |
+
* You should have received a copy of the GNU General Public License
|
18 |
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
+
*/
|
20 |
+
|
21 |
+
"use strict";
|
22 |
+
const VERS = "0.1.60 (62-12-2024)";
|
23 |
+
|
24 |
+
var xlog = console.log;
|
25 |
+
var xerror = console.error;
|
26 |
+
// let T0 = {};
|
27 |
+
|
28 |
+
// var start_performance = function (k) {
|
29 |
+
// T0.k = performance.now();
|
30 |
+
// };
|
31 |
+
|
32 |
+
// var log_performance = function (k, msg = "") {
|
33 |
+
// const t1 = performance.now();
|
34 |
+
// const d = t1 - T0.k;
|
35 |
+
// console.log(msg, d);
|
36 |
+
// T0.k = t1;
|
37 |
+
// return d;
|
38 |
+
// };
|
39 |
+
|
40 |
+
// function showMessage(message, duraction = 5000) {
|
41 |
+
// const popup = document.createElement("div");
|
42 |
+
// popup.className = "msg";
|
43 |
+
// popup.innerText = message;
|
44 |
+
// document.body.appendChild(popup);
|
45 |
+
// setTimeout(function () {
|
46 |
+
// document.body.removeChild(popup);
|
47 |
+
// }, duraction);
|
48 |
+
// }
|
49 |
+
|
50 |
+
const cancelRequest = () => {
|
51 |
+
const ok = confirm("Confermi Cancellazione Richeista ?");
|
52 |
+
if (!ok) return;
|
53 |
+
HfRequest.cancelRequest();
|
54 |
+
hideSpinner();
|
55 |
+
};
|
56 |
+
|
57 |
+
const showSpinner = () => {
|
58 |
+
const spinner = document.getElementById("spinner");
|
59 |
+
spinner.classList.add("show-spinner");
|
60 |
+
spinner.addEventListener("click", cancelRequest);
|
61 |
+
};
|
62 |
+
|
63 |
+
const hideSpinner = () => {
|
64 |
+
const spinner = document.getElementById("spinner");
|
65 |
+
spinner.classList.remove("show-spinner");
|
66 |
+
spinner.removeEventListener("click", cancelRequest);
|
67 |
+
};
|
68 |
+
|
69 |
+
var tm;
|
70 |
+
|
71 |
+
function openApp() {
|
72 |
+
setTimeout(() => {
|
73 |
+
tm = umgm();
|
74 |
+
wnds.init();
|
75 |
+
Menu.init();
|
76 |
+
TextInput.init();
|
77 |
+
TextOutput.init();
|
78 |
+
Rag.init();
|
79 |
+
document.querySelector(".menu-btn").checked = false;
|
80 |
+
release();
|
81 |
+
showHistory();
|
82 |
+
getTheme();
|
83 |
+
}, 10);
|
84 |
+
}
|
85 |
+
|
86 |
+
// function openApp() {
|
87 |
+
// tm = umgm();
|
88 |
+
// wnds.init();
|
89 |
+
// Menu.init();
|
90 |
+
// TextInput.init();
|
91 |
+
// TextOutput.init();
|
92 |
+
// Rag.init();
|
93 |
+
// document.querySelector(".menu-btn").checked = false;
|
94 |
+
// release();
|
95 |
+
// showHistory();
|
96 |
+
// }
|
97 |
+
|
98 |
+
// Visualizza la storia della conversazione
|
99 |
+
function showHistory() {
|
100 |
+
const txt = ThreadMgr.getThread();
|
101 |
+
setOutText(txt);
|
102 |
+
// const p = document.querySelector("#id-text-out .pre-text");
|
103 |
+
// p.textContent = txt;
|
104 |
+
// setTimeout(() => {
|
105 |
+
// p.scrollTop = p.scrollHeight;
|
106 |
+
// }, 0);
|
107 |
+
}
|
108 |
+
|
109 |
+
function release() {
|
110 |
+
document.querySelector(".release").innerHTML = VERS;
|
111 |
+
}
|
112 |
+
|
113 |
+
// README
|
114 |
+
const op0 = async function (e) {
|
115 |
+
const text = await requestGet("./help1.html");
|
116 |
+
wnds.wdiv.show(text);
|
117 |
+
};
|
118 |
+
|
119 |
+
//query iniziale
|
120 |
+
function showQuery(e) {
|
121 |
+
const txt = `\n${Rag.ragQuery}`;
|
122 |
+
wnds.wpre.show(txt);
|
123 |
+
// Menu.close();
|
124 |
+
}
|
125 |
+
|
126 |
+
//Risposta Rsg
|
127 |
+
function showRagResponse(e) {
|
128 |
+
const txt = `\n${Rag.ragAnswer}`;
|
129 |
+
wnds.wpre.show(txt);
|
130 |
+
}
|
131 |
+
|
132 |
+
//conversazione
|
133 |
+
function showThread(e) {
|
134 |
+
const txt = ThreadMgr.getThread();
|
135 |
+
wnds.wpre.show(txt);
|
136 |
+
}
|
137 |
+
|
138 |
+
//elenco risposte
|
139 |
+
function elencoRisposte(e) {
|
140 |
+
let rs = [...Rag.answers];
|
141 |
+
if (rs.length == 0) {
|
142 |
+
rs = UaDb.readArray(ID_RESPONSES);
|
143 |
+
}
|
144 |
+
if (rs.length == 0) return;
|
145 |
+
const text = rs
|
146 |
+
.map((x, i) => {
|
147 |
+
// x = subResponseDOcTag(x);
|
148 |
+
return `\n[${i + 1}]\n ${x.trim()}`;
|
149 |
+
})
|
150 |
+
.join("\n");
|
151 |
+
wnds.wpre.show(text);
|
152 |
+
}
|
153 |
+
|
154 |
+
//contesto
|
155 |
+
function showContesto(e) {
|
156 |
+
const txt = `${Rag.ragContext}`;
|
157 |
+
wnds.wpre.show(txt);
|
158 |
+
}
|
159 |
+
|
160 |
+
//elemco dati
|
161 |
+
function elencoDati(e) {
|
162 |
+
const ids = UaDb.getAllIds();
|
163 |
+
const arr = [];
|
164 |
+
for (const id of ids) {
|
165 |
+
const s = UaDb.read(id);
|
166 |
+
const l = s.length;
|
167 |
+
arr.push(`${id} (${l})`);
|
168 |
+
}
|
169 |
+
let msg = arr.join("\n ");
|
170 |
+
wnds.wpre.show(msg);
|
171 |
+
}
|
172 |
+
|
173 |
+
//visualizza docuemnto
|
174 |
+
const showT = (n) => {
|
175 |
+
const arr = DataMgr.docs;
|
176 |
+
const s = arr[n];
|
177 |
+
wnds.wpre.show(s);
|
178 |
+
};
|
179 |
+
|
180 |
+
// elenco e visualizzazione documenti
|
181 |
+
function elencoDocs() {
|
182 |
+
DataMgr.readDbDocs();
|
183 |
+
DataMgr.readDbDocNames();
|
184 |
+
const arr = DataMgr.doc_names;
|
185 |
+
const fh = (x, i) => `
|
186 |
+
<li><a href="#" onCLick="showT(${i});">${i + 1}.${x}</a></li>
|
187 |
+
`;
|
188 |
+
const jfh = UaJtfh();
|
189 |
+
let i = 0;
|
190 |
+
jfh.append("<ul>");
|
191 |
+
for (const x of arr) jfh.append(fh(x, i++));
|
192 |
+
jfh.append("</ul>");
|
193 |
+
const t = jfh.html();
|
194 |
+
wnds.wdiv.show(`<br><br>${t}`);
|
195 |
+
}
|
196 |
+
|
197 |
+
//calcolo query
|
198 |
+
function calcQuery() {
|
199 |
+
const calc = () => {
|
200 |
+
const arr = [];
|
201 |
+
let nptot = 0;
|
202 |
+
let i = 0;
|
203 |
+
arr.push(`Documento Num.Parti`);
|
204 |
+
arr.push("==================");
|
205 |
+
for (const doc of DataMgr.docs) {
|
206 |
+
const name = DataMgr.doc_names[i];
|
207 |
+
i += 1;
|
208 |
+
const dl = doc.length;
|
209 |
+
const np = Math.ceil(dl / MAX_PROMPT_LENGTH);
|
210 |
+
nptot += np;
|
211 |
+
arr.push(`${name} [${np}]`);
|
212 |
+
}
|
213 |
+
arr.push("==================");
|
214 |
+
arr.push(`Totale num. Parti: ${nptot}`);
|
215 |
+
const s = arr.join("\n");
|
216 |
+
return s;
|
217 |
+
};
|
218 |
+
DataMgr.readDbDocs();
|
219 |
+
DataMgr.readDbDocNames();
|
220 |
+
const s = calc();
|
221 |
+
wnds.wpre.show(s);
|
222 |
+
}
|
223 |
+
|
224 |
+
//cancella dati
|
225 |
+
function deleteDati(e) {
|
226 |
+
const ok = confirm("Confermi cancellazione dati?");
|
227 |
+
if (ok) {
|
228 |
+
DataMgr.deleteJsonDati();
|
229 |
+
wnds.wdiv.close();
|
230 |
+
wnds.wpre.close();
|
231 |
+
TextOutput.clear();
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
//cancella localstrage
|
236 |
+
function deleteSttorage(e) {
|
237 |
+
const ok = confirm("Confermi cancellazione documenti & dati?");
|
238 |
+
if (ok) {
|
239 |
+
DataMgr.deleteJsonDati();
|
240 |
+
localStorage.clear();
|
241 |
+
wnds.wdiv.close();
|
242 |
+
wnds.wpre.close();
|
243 |
+
TextOutput.clear();
|
244 |
+
DataMgr.docs = [];
|
245 |
+
DataMgr.doc_names = [];
|
246 |
+
}
|
247 |
+
}
|
248 |
+
|
249 |
+
//documenti di esempio nella dir ./data
|
250 |
+
async function help1(e) {
|
251 |
+
const text = await requestGet("./data/help_test.html");
|
252 |
+
wnds.wdiv.show(text);
|
253 |
+
}
|
254 |
+
|
255 |
+
//lettura files di esempio invocata dalla pagina ./data/help_test.html
|
256 |
+
function loadTestoEsempio(name) {
|
257 |
+
const link = `data/${name}`;
|
258 |
+
DataMgr.loadDoc(link);
|
259 |
+
wnds.wdiv.close();
|
260 |
+
}
|
261 |
+
|
262 |
+
//domande di esempio
|
263 |
+
async function help2(e) {
|
264 |
+
const text = await requestGet("./help2.html");
|
265 |
+
wnds.wdiv.show(text);
|
266 |
+
}
|
267 |
+
|
268 |
+
const themeKey = "theme";
|
269 |
+
|
270 |
+
function getTheme() {
|
271 |
+
const t = localStorage.getItem(themeKey);
|
272 |
+
if (!!t && t == "light") {
|
273 |
+
document.body.classList.add("theme-light");
|
274 |
+
document.documentElement.classList.toggle("invert");
|
275 |
+
} else {
|
276 |
+
document.body.classList.add("theme-dark");
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
+
function setLight() {
|
281 |
+
document.documentElement.classList.toggle("invert");
|
282 |
+
document.body.classList.remove("theme-dark");
|
283 |
+
document.body.classList.add("theme-light");
|
284 |
+
localStorage.setItem(themeKey, "light");
|
285 |
+
}
|
286 |
+
|
287 |
+
function setDark() {
|
288 |
+
document.documentElement.classList.toggle("invert");
|
289 |
+
document.body.classList.remove("theme-light");
|
290 |
+
document.body.classList.add("theme-dark");
|
291 |
+
localStorage.setItem(themeKey, "dark");
|
292 |
+
}
|
293 |
+
|
294 |
+
////////////////////////////////
|
295 |
+
// Solo Sviluppo
|
296 |
+
|
297 |
+
//prompts
|
298 |
+
function showPrompts(e) {
|
299 |
+
if (Rag.prompts.length == 0) return;
|
300 |
+
const text = Rag.prompts
|
301 |
+
.map((x, i) => {
|
302 |
+
return `[${i + 1}]${x}\n`;
|
303 |
+
})
|
304 |
+
.join("\n");
|
305 |
+
wnds.wpre.show(text);
|
306 |
+
}
|
static/javascript/rag_mgr.js
CHANGED
@@ -28,13 +28,13 @@ function wait(seconds) {
|
|
28 |
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
29 |
}
|
30 |
|
31 |
-
async function example() {
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
}
|
36 |
|
37 |
-
example();
|
38 |
|
39 |
const truncInput = (txt, decr) => {
|
40 |
const tl = txt.length;
|
|
|
28 |
return new Promise((resolve) => setTimeout(resolve, seconds * 1000));
|
29 |
}
|
30 |
|
31 |
+
// async function example() {
|
32 |
+
// console.log("Inizio attesa...");
|
33 |
+
// await wait(5); // Attende 5 secondi
|
34 |
+
// console.log("Fine attesa!");
|
35 |
+
// }
|
36 |
|
37 |
+
// example();
|
38 |
|
39 |
const truncInput = (txt, decr) => {
|
40 |
const tl = txt.length;
|
static/javascript/rag_upload.js
CHANGED
@@ -8,11 +8,11 @@ const RagUpload = {
|
|
8 |
<div class="window-text">
|
9 |
<div class="btn-wrapper">
|
10 |
<button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>
|
11 |
-
</div>
|
12 |
-
<div class="upload">
|
13 |
-
<h4>Upload file Text / PDF</h4>
|
14 |
<form id="uploadForm">
|
15 |
-
<input class="file" type="file" id="id_fileupload" >
|
16 |
<button type="button" onclick="RagUpload.upload();">Upload and Convert</button>
|
17 |
</form>
|
18 |
<div id="result" class="result"></div>
|
@@ -52,6 +52,11 @@ const RagUpload = {
|
|
52 |
pdfHandler.cleanup();
|
53 |
} else if (fileExtension === "txt") {
|
54 |
text = await readTextFile(file);
|
|
|
|
|
|
|
|
|
|
|
55 |
} else {
|
56 |
alert("Formato file non supportato.");
|
57 |
return;
|
@@ -71,9 +76,9 @@ const RagUpload = {
|
|
71 |
<div class="window-text">
|
72 |
<div class="btn-wrapper">
|
73 |
<button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>
|
74 |
-
</div>
|
75 |
-
<div class="upload">
|
76 |
-
<h4>Upload files Text / PDF</h4>
|
77 |
<form id="uploadForm">
|
78 |
<input id="id_fileupload" class="file" type="file" webkitdirectory mozdirectory msdirectory odirectory directory multiple />
|
79 |
<button type="button" onclick="RagUpload.uploadDir();">Upload and Convert</button>
|
@@ -108,7 +113,7 @@ const RagUpload = {
|
|
108 |
UaLog.log_show(fileName);
|
109 |
const exist = DataMgr.doc_names.includes(fileName);
|
110 |
if (exist) {
|
111 |
-
UaLog.
|
112 |
continue;
|
113 |
}
|
114 |
const fileExtension = file.name.split(".").pop().toLowerCase();
|
@@ -120,6 +125,11 @@ const RagUpload = {
|
|
120 |
pdfHandler.cleanup();
|
121 |
} else if (fileExtension === "txt") {
|
122 |
text = await readTextFile(file);
|
|
|
|
|
|
|
|
|
|
|
123 |
} else {
|
124 |
alert("Formato file non supportato.");
|
125 |
return;
|
@@ -202,6 +212,49 @@ class PdfHandler {
|
|
202 |
}
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
async function readTextFile(file) {
|
206 |
if (!file || file.type !== "text/plain") {
|
207 |
throw new Error("Invalid file type. Please select a text file.");
|
|
|
8 |
<div class="window-text">
|
9 |
<div class="btn-wrapper">
|
10 |
<button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>
|
11 |
+
</div>
|
12 |
+
<div class="upload">
|
13 |
+
<h4>Upload file Text / PDF / DOCX</h4>
|
14 |
<form id="uploadForm">
|
15 |
+
<input class="file" type="file" id="id_fileupload" >
|
16 |
<button type="button" onclick="RagUpload.upload();">Upload and Convert</button>
|
17 |
</form>
|
18 |
<div id="result" class="result"></div>
|
|
|
52 |
pdfHandler.cleanup();
|
53 |
} else if (fileExtension === "txt") {
|
54 |
text = await readTextFile(file);
|
55 |
+
} else if (fileExtension === "docx") {
|
56 |
+
const docxHandler = new DocxHandler();
|
57 |
+
await docxHandler.loadMammoth();
|
58 |
+
text = await docxHandler.extractTextFromDocx(file);
|
59 |
+
docxHandler.cleanup();
|
60 |
} else {
|
61 |
alert("Formato file non supportato.");
|
62 |
return;
|
|
|
76 |
<div class="window-text">
|
77 |
<div class="btn-wrapper">
|
78 |
<button class="btn-close" title="chiudi" onclick="UaWindowAdm.closeThis(this)">X</button>
|
79 |
+
</div>
|
80 |
+
<div class="upload">
|
81 |
+
<h4>Upload files Text / PDF / DOCX</h4>
|
82 |
<form id="uploadForm">
|
83 |
<input id="id_fileupload" class="file" type="file" webkitdirectory mozdirectory msdirectory odirectory directory multiple />
|
84 |
<button type="button" onclick="RagUpload.uploadDir();">Upload and Convert</button>
|
|
|
113 |
UaLog.log_show(fileName);
|
114 |
const exist = DataMgr.doc_names.includes(fileName);
|
115 |
if (exist) {
|
116 |
+
UaLog.log_show(fileName + " : è già in archivio");
|
117 |
continue;
|
118 |
}
|
119 |
const fileExtension = file.name.split(".").pop().toLowerCase();
|
|
|
125 |
pdfHandler.cleanup();
|
126 |
} else if (fileExtension === "txt") {
|
127 |
text = await readTextFile(file);
|
128 |
+
} else if (fileExtension === "docx") {
|
129 |
+
const docxHandler = new DocxHandler();
|
130 |
+
await docxHandler.loadMammoth();
|
131 |
+
text = await docxHandler.extractTextFromDocx(file);
|
132 |
+
docxHandler.cleanup();
|
133 |
} else {
|
134 |
alert("Formato file non supportato.");
|
135 |
return;
|
|
|
212 |
}
|
213 |
}
|
214 |
|
215 |
+
class DocxHandler {
|
216 |
+
constructor() {
|
217 |
+
this.mammoth = null;
|
218 |
+
this.scriptElement = null;
|
219 |
+
}
|
220 |
+
|
221 |
+
async loadMammoth() {
|
222 |
+
if (window["mammoth"]) {
|
223 |
+
this.mammoth = window["mammoth"];
|
224 |
+
return;
|
225 |
+
}
|
226 |
+
// Carica mammoth dinamicamente
|
227 |
+
this.scriptElement = document.createElement("script");
|
228 |
+
this.scriptElement.src = "https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.11/mammoth.browser.min.js";
|
229 |
+
document.body.appendChild(this.scriptElement);
|
230 |
+
|
231 |
+
// Aspetta che mammoth sia caricato
|
232 |
+
await new Promise((resolve) => {
|
233 |
+
this.scriptElement.onload = () => {
|
234 |
+
this.mammoth = window["mammoth"];
|
235 |
+
resolve();
|
236 |
+
};
|
237 |
+
});
|
238 |
+
}
|
239 |
+
|
240 |
+
async extractTextFromDocx(file) {
|
241 |
+
const arrayBuffer = await file.arrayBuffer();
|
242 |
+
const result = await this.mammoth.extractRawText({ arrayBuffer });
|
243 |
+
return result.value;
|
244 |
+
}
|
245 |
+
|
246 |
+
cleanup() {
|
247 |
+
if (this.scriptElement) {
|
248 |
+
document.body.removeChild(this.scriptElement);
|
249 |
+
this.scriptElement = null;
|
250 |
+
}
|
251 |
+
this.mammoth = null;
|
252 |
+
if (window.gc) {
|
253 |
+
window.gc();
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
async function readTextFile(file) {
|
259 |
if (!file || file.type !== "text/plain") {
|
260 |
throw new Error("Invalid file type. Please select a text file.");
|
static/js/ragrqs.min.js
CHANGED
@@ -1,19 +1,4 @@
|
|
1 |
-
|
2 |
-
function cleanDoc(a){try{return a=removeTag(a),a=a.replace(/(\w+)-\s*\n(\w+)/g,"$1$2"),a=a.replace(/[\u00AD\u200B\u200C\u200D\u2060\uFEFF\u0008]/g,""),a=a.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g," "),a=a.replace(/\\([nrtfb])/g,"$1"),a=a.replace(/\\(u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2})/g,"$1"),a=a.replace(/\\([a-zA-Z]:\\|\\\\[a-zA-Z0-9_]+\\)/g,"\\$1"),a=a.replace(/\\/g,""),a=a.replace("\u201c",'"').replace("\u201d",'"'),a=a.replace(/\n/g," "),a=a.replace(/ +([.,;:!?])/g,"$1"),a=a.split(/(?<=[.?!])\s+/).filter(b=>
|
3 |
-
5<=b.trim().length).map(b=>b.trim()).join("\n"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),"Errore di codifica del documento"}}
|
4 |
-
function cleanResponse(a){try{return a=removeTag(a),a=a.replace(/[\u00AD\u200B\u200C\u200D\u2060\uFEFF]/g,""),a=a.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g," "),a=a.replace(/\\([nrtfb])/g,"$1"),a=a.replace(/\\(u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2})/g,"$1"),a=a.replace(/\\([a-zA-Z]:\\|\\\\[a-zA-Z0-9_]+\\)/g,"\\\\$1"),a=a.replace(/\\/g,""),a=a.replace(/\n{3,}/g,"\n\n"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),`Errore di codifica nella risposta\n${b}`}}
|
5 |
-
function cleanOut(a){return a=a.replace(/\n{3,}/g,"\n\n")};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.`)},
|
6 |
-
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){this.readDbDocNames();try{const b=await requestGet(a),
|
7 |
-
c=cleanDoc(b),d=this.linkToName(a);if(this.doc_names.includes(d))alert(`Il docuento ${d} \u00e8 gi\u00e0 caricato`);else return this.doc_names.push(d),this.docs.push(c),this.saveDbDocs(),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)},
|
8 |
-
deleteJsonDati(){const a=UaDb.getAllIds();for(const b of a)[ID_DOCS,ID_DOC_NAMES].includes(b)||UaDb.delete(b);Rag.ragQuery="";Rag.ragContext="";Rag.ragAnswer="";Rag.answers=[];Rag.prompts=[];ThreadMgr.rows=[]}};function umgm(){return["bWtkSGxRfVA=","aFN1b2dycm0=","WXBfclhfUGk=","TVhWTV1aW04=","fVJPa00="].map(a=>atob(a).split("").map(b=>String.fromCharCode((b.charCodeAt(0)-5+256)%256)).join("")).join("")};const model_name="mistralai/Mistral-7B-Instruct-v0.3";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",getErrorType=(a,b)=>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",checkResponse=a=>a&&Array.isArray(a)&&0!==a.length?a[0].generated_text?"ok":"MISSING_GENERATED_TEXT":"INVALID_DATA",createErrorInfo=(a,b,c,d)=>JSON.stringify({status:a,statusText:b,errorType:d,message:c||"Errore sconosciuto"}),HfRequest={controller:null,
|
10 |
-
isCancelled:!1,baseUrl:"https://api-inference.huggingface.co/models",async post(a,b=5E4){this.isCancelled=!1;this.controller=new AbortController;let c;try{const d=setTimeout(()=>{this.controller.abort()},b);c=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(d);if(this.isCancelled)return null;const e=await c.json();if(!c.ok){const g=getErrorType(c.status,
|
11 |
-
e),k=createErrorInfo(c.status,c.statusText,e.error,g);throw Error(k);}const f=checkResponse(e);if("ok"!==f){const g=createErrorInfo(c.status,c.statusText,e.error,f);throw Error(g);}return e[0].generated_text.trim()}catch(d){if(this.isCancelled)return null;if("AbortError"===d.name)throw a=createErrorInfo(0,"Timeout","La richiesta \u00e8 scaduta",TIMEOUT_ERROR),Error(a);throw d;}},cancelRequest(){this.controller&&(this.isCancelled=!0,this.controller.abort())}};
|
12 |
-
function getErrorInfo(a){let b={};try{b=JSON.parse(a.message)}catch(c){a=`getErrorInfo\n${a}`,console.error(a),b={status:"0",statusText:"status_errorInof",errorType:"UNKNOWN_ERROR_errorInfo",message:a}}finally{return b}}function errorToText(a){let b;try{const c=JSON.parse(a.message);b=`Error:
|
13 |
-
Status: ${c.status}
|
14 |
-
Status Text: ${c.statusText}
|
15 |
-
Error Type: ${c.errorType}
|
16 |
-
Message: ${c.message}`}catch(c){console.error(`errorToText\n${c}`),b=`${c}`}finally{return b}};/*
|
17 |
|
18 |
rag_rqs
|
19 |
Copyright (C) 2024 [Il tuo nome]
|
@@ -31,7 +16,31 @@ function getErrorInfo(a){let b={};try{b=JSON.parse(a.message)}catch(c){a=`getErr
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
const truncInput=(a,b)=>a.substring(0,a.length-b),setMaxLen=a=>a.substring(0,MAX_PROMPT_LENGTH-1E3),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}`);a=formatRow([a,b,c,d],[8,-7,-7,-7]);UaLog.log(a)},Rag=
|
36 |
{ragContext:"",ragQuery:"",ragAnswer:"",answers:[],docContextLst:[],prompts:[],doc:"",doc_part:"",init(){this.readRespsFromDb();this.readFromDb()},returnOk(){return 10<this.ragContext.length},saveToDb(){UaDb.saveJson(ID_RAG,{context:this.ragContext,ragquery:this.ragQuery,raganswer:this.ragAnswer});UaDb.saveArray(ID_THREAD,ThreadMgr.rows)},readFromDb(){const a=UaDb.readJson(ID_RAG);this.ragContext=a.context||"";this.ragQuery=a.ragquery||"";this.ragAnswer=a.raganswer||"";ThreadMgr.rows=UaDb.readArray(ID_THREAD)},
|
37 |
saveRespToDb(){UaDb.saveArray(ID_RESPONSES,this.answers)},readRespsFromDb(){this.answers=UaDb.readArray(ID_RESPONSES)},async requestDocsRAG(a){DataMgr.deleteJsonDati();DataMgr.readDbDocNames();DataMgr.readDbDocs();this.ragQuery=a;this.saveToDb();var b=0;try{var c=1;for(let e=0;e<DataMgr.docs.length;e++){let f=DataMgr.docs[e];if(""==f.trim())continue;const g=DataMgr.doc_names[e],k=f.length;xlog(`${g} (${k}) `);UaLog.log(`${g} (${k}) `);++b;var d=1;let h=0,l="",t="",u="",m="",v=[];for(;;){let r=getPartSize(f,
|
@@ -147,15 +156,7 @@ RESPONSE:
|
|
147 |
`}function getPayloadDoc(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2E3,num_return_sequences:1,temperature:.4,top_p:.85,top_k:30,do_sample:!1,no_repeat_ngram_size:3,num_beams:4,repetition_penalty:1.2,return_full_text:!1,details:!1,max_time:90,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
148 |
function getPayloadBuildContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:6E3,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,do_sample:!1,no_repeat_ngram_size:4,num_beams:6,repetition_penalty:1.2,return_full_text:!1,details:!1,max_time:180,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
149 |
function getPayloadWithContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:4E3,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,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}}}
|
150 |
-
function getPayloadThread(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:6048,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,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
|
151 |
-
function openApp(){setTimeout(()=>{tm=umgm();wnds.init();Menu.init();TextInput.init();TextOutput.init();Rag.init();document.querySelector(".menu-btn").checked=!1;release();showHistory()},10)}function showHistory(){const a=ThreadMgr.getThread();setOutText(a)}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}`)}
|
152 |
-
function showRagResponse(a){wnds.wpre.show(`\n${Rag.ragAnswer}`)}function showThread(a){a=ThreadMgr.getThread();wnds.wpre.show(a)}function elencoRisposte(a){a=[...Rag.answers];0==a.length&&(a=UaDb.readArray(ID_RESPONSES));0!=a.length&&(a=a.map((b,c)=>`\n[${c+1}]\n ${b.trim()}`).join("\n"),wnds.wpre.show(a))}function showContesto(a){wnds.wpre.show(`${Rag.ragContext}`)}
|
153 |
-
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)}const showT=a=>{wnds.wpre.show(DataMgr.docs[a])};function elencoDocs(){DataMgr.readDbDocs();DataMgr.readDbDocNames();var a=DataMgr.doc_names,b=UaJtfh();let c=0;b.append("<ul>");for(const g of a){a=b;var d=a.append,e=g,f=c++;d.call(a,`
|
154 |
-
<li><a href="#" onCLick="showT(${f});">${f+1}.${e}</a></li>
|
155 |
-
`)}b.append("</ul>");b=b.html();wnds.wdiv.show(`<br><br>${b}`)}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)}
|
156 |
-
function deleteDati(a){confirm("Confermi cancellazione dati?")&&(DataMgr.deleteJsonDati(),wnds.wdiv.close(),wnds.wpre.close(),TextOutput.clear())}function deleteSttorage(a){confirm("Confermi cancellazione documenti & dati?")&&(DataMgr.deleteJsonDati(),localStorage.clear(),wnds.wdiv.close(),wnds.wpre.close(),TextOutput.clear(),DataMgr.docs=[],DataMgr.doc_names=[])}async function help1(a){a=await requestGet("./data/help_test.html");wnds.wdiv.show(a)}
|
157 |
-
function loadTestoEsempio(a){DataMgr.loadDoc(`data/${a}`);wnds.wdiv.close()}async function help2(a){a=await requestGet("./help2.html");wnds.wdiv.show(a)}function getTheme(){const a=localStorage.getItem("theme");a&&"dark"==a&&setDark()}function setLight(){document.documentElement.classList.toggle("invert");document.body.classList.remove("theme-dark");document.body.classList.add("theme-light");localStorage.setItem("theme","ligth")}
|
158 |
-
function setDark(){document.documentElement.classList.toggle("invert");document.body.classList.remove("theme-light");document.body.classList.add("theme-dark");localStorage.setItem("theme","dark")}function showPrompts(a){0!=Rag.prompts.length&&(a=Rag.prompts.map((b,c)=>`[${c+1}]${b}\n`).join("\n"),wnds.wpre.show(a))};const WndPre=a=>({w:UaWindowAdm.create(a),out:null,show(b){wnds.closeAll();b=`
|
159 |
<div class="window-text">
|
160 |
<div class="btn-wrapper">
|
161 |
<button class="btn-copy" title="Copia">
|
@@ -187,15 +188,16 @@ a=>this.handleEnter(a));document.querySelector(".send-input").addEventListener("
|
|
187 |
try{let b=await Rag.requestDocsRAG(a);b=cleanOut(b);setOutText(b);this.inp.value="";UaLog.close()}catch(b){a=`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{let b=await Rag.requestContext(a);if(""==b){hideSpinner();return}b=cleanOut(b);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 ")},
|
188 |
clear(){confirm("Confermi cancellazione conversazione? ")&&(this.inp.value="",setOutText(""),ThreadMgr.init())}};
|
189 |
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.querySelector("#id-text-out .pre-text").textContent;wnds.wout.show(a)},async copy(){const a=document.querySelector("#id-text-out .pre-text"),b=a.textContent;if(!(2>b.trim().length)){a.classList.add("copied");
|
190 |
-
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.querySelector("#id-text-out .pre-text").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
|
191 |
-
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
|
192 |
-
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
|
193 |
-
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.
|
194 |
-
return}DataMgr.addDoc(d,f);b.push(`${d}`)}}catch(c){xerror("Error:",c),alert("Errore durante l'estrazione del testo dal file.")}finally{hideSpinner()}a=document.getElementById("result");b=b.join("<br>");a.innerHTML=b}else alert("Nessun file selezionato.")}};
|
195 |
class PdfHandler{constructor(){this.workerScriptElement=this.scriptElement=this.pdfjsLib=null}async loadPdfJs(){window.pdfjsLib||(this.scriptElement=document.createElement("script"),this.scriptElement.src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js",document.body.appendChild(this.scriptElement),await new Promise(a=>{this.scriptElement.onload=()=>{this.workerScriptElement=document.createElement("script");this.workerScriptElement.src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js";
|
196 |
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&&
|
197 |
(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()}}
|
198 |
-
async
|
|
|
199 |
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"},k=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=
|
200 |
k,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," ")}});function formatRow(a,b){return a.map((c,d)=>{d=b[d];return 0>d?c.toString().padStart(Math.abs(d)," "):c.toString().padEnd(d," ")}).join(" ")}
|
201 |
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,
|
|
|
1 |
+
/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
rag_rqs
|
4 |
Copyright (C) 2024 [Il tuo nome]
|
|
|
16 |
You should have received a copy of the GNU General Public License
|
17 |
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
+
const VERS="0.1.60 (62-12-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)};var tm;
|
20 |
+
function openApp(){setTimeout(()=>{tm=umgm();wnds.init();Menu.init();TextInput.init();TextOutput.init();Rag.init();document.querySelector(".menu-btn").checked=!1;release();showHistory();getTheme()},10)}function showHistory(){const a=ThreadMgr.getThread();setOutText(a)}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}`)}
|
21 |
+
function showRagResponse(a){wnds.wpre.show(`\n${Rag.ragAnswer}`)}function showThread(a){a=ThreadMgr.getThread();wnds.wpre.show(a)}function elencoRisposte(a){a=[...Rag.answers];0==a.length&&(a=UaDb.readArray(ID_RESPONSES));0!=a.length&&(a=a.map((b,c)=>`\n[${c+1}]\n ${b.trim()}`).join("\n"),wnds.wpre.show(a))}function showContesto(a){wnds.wpre.show(`${Rag.ragContext}`)}
|
22 |
+
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)}const showT=a=>{wnds.wpre.show(DataMgr.docs[a])};function elencoDocs(){DataMgr.readDbDocs();DataMgr.readDbDocNames();var a=DataMgr.doc_names,b=UaJtfh();let c=0;b.append("<ul>");for(const g of a){a=b;var d=a.append,e=g,f=c++;d.call(a,`
|
23 |
+
<li><a href="#" onCLick="showT(${f});">${f+1}.${e}</a></li>
|
24 |
+
`)}b.append("</ul>");b=b.html();wnds.wdiv.show(`<br><br>${b}`)}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)}
|
25 |
+
function deleteDati(a){confirm("Confermi cancellazione dati?")&&(DataMgr.deleteJsonDati(),wnds.wdiv.close(),wnds.wpre.close(),TextOutput.clear())}function deleteSttorage(a){confirm("Confermi cancellazione documenti & dati?")&&(DataMgr.deleteJsonDati(),localStorage.clear(),wnds.wdiv.close(),wnds.wpre.close(),TextOutput.clear(),DataMgr.docs=[],DataMgr.doc_names=[])}async function help1(a){a=await requestGet("./data/help_test.html");wnds.wdiv.show(a)}
|
26 |
+
function loadTestoEsempio(a){DataMgr.loadDoc(`data/${a}`);wnds.wdiv.close()}async function help2(a){a=await requestGet("./help2.html");wnds.wdiv.show(a)}const themeKey="theme";function getTheme(){const a=localStorage.getItem(themeKey);a&&"light"==a?(document.body.classList.add("theme-light"),document.documentElement.classList.toggle("invert")):document.body.classList.add("theme-dark")}
|
27 |
+
function setLight(){document.documentElement.classList.toggle("invert");document.body.classList.remove("theme-dark");document.body.classList.add("theme-light");localStorage.setItem(themeKey,"light")}function setDark(){document.documentElement.classList.toggle("invert");document.body.classList.remove("theme-light");document.body.classList.add("theme-dark");localStorage.setItem(themeKey,"dark")}
|
28 |
+
function showPrompts(a){0!=Rag.prompts.length&&(a=Rag.prompts.map((b,c)=>`[${c+1}]${b}\n`).join("\n"),wnds.wpre.show(a))};function removeTag(a){a=a.replace(/<<</g," ").replace(/>>>/g," ");return a=a.replace(/<</g,"").replace(/>>/g,"")}
|
29 |
+
function cleanDoc(a){try{return a=removeTag(a),a=a.replace(/(\w+)-\s*\n(\w+)/g,"$1$2"),a=a.replace(/[\u00AD\u200B\u200C\u200D\u2060\uFEFF\u0008]/g,""),a=a.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g," "),a=a.replace(/\\([nrtfb])/g,"$1"),a=a.replace(/\\(u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2})/g,"$1"),a=a.replace(/\\([a-zA-Z]:\\|\\\\[a-zA-Z0-9_]+\\)/g,"\\$1"),a=a.replace(/\\/g,""),a=a.replace("\u201c",'"').replace("\u201d",'"'),a=a.replace(/\n/g," "),a=a.replace(/ +([.,;:!?])/g,"$1"),a=a.split(/(?<=[.?!])\s+/).filter(b=>
|
30 |
+
5<=b.trim().length).map(b=>b.trim()).join("\n"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),"Errore di codifica del documento"}}
|
31 |
+
function cleanResponse(a){try{return a=removeTag(a),a=a.replace(/[\u00AD\u200B\u200C\u200D\u2060\uFEFF]/g,""),a=a.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000\t\r\f\v]/g," "),a=a.replace(/\\([nrtfb])/g,"$1"),a=a.replace(/\\(u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2})/g,"$1"),a=a.replace(/\\([a-zA-Z]:\\|\\\\[a-zA-Z0-9_]+\\)/g,"\\\\$1"),a=a.replace(/\\/g,""),a=a.replace(/\n{3,}/g,"\n\n"),a=a.replace(/ +/g," "),a.trim()}catch(b){return console.error(b),`Errore di codifica nella risposta\n${b}`}}
|
32 |
+
function cleanOut(a){return a=a.replace(/\n{3,}/g,"\n\n")};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.`)},
|
33 |
+
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){this.readDbDocNames();try{const b=await requestGet(a),
|
34 |
+
c=cleanDoc(b),d=this.linkToName(a);if(this.doc_names.includes(d))alert(`Il docuento ${d} \u00e8 gi\u00e0 caricato`);else return this.doc_names.push(d),this.docs.push(c),this.saveDbDocs(),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)},
|
35 |
+
deleteJsonDati(){const a=UaDb.getAllIds();for(const b of a)[ID_DOCS,ID_DOC_NAMES].includes(b)||UaDb.delete(b);Rag.ragQuery="";Rag.ragContext="";Rag.ragAnswer="";Rag.answers=[];Rag.prompts=[];ThreadMgr.rows=[]}};function umgm(){return["bWtkSGxRfVA=","aFN1b2dycm0=","WXBfclhfUGk=","TVhWTV1aW04=","fVJPa00="].map(a=>atob(a).split("").map(b=>String.fromCharCode((b.charCodeAt(0)-5+256)%256)).join("")).join("")};const model_name="mistralai/Mistral-7B-Instruct-v0.3";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;}}
|
36 |
+
const ERROR_TOKENS="ERROR_TOKENS",TIMEOUT_ERROR="TIMEOUT_ERROR",getErrorType=(a,b)=>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",checkResponse=a=>a&&Array.isArray(a)&&0!==a.length?a[0].generated_text?"ok":"MISSING_GENERATED_TEXT":"INVALID_DATA",createErrorInfo=(a,b,c,d)=>JSON.stringify({status:a,statusText:b,errorType:d,message:c||"Errore sconosciuto"}),HfRequest={controller:null,
|
37 |
+
isCancelled:!1,baseUrl:"https://api-inference.huggingface.co/models",async post(a,b=5E4){this.isCancelled=!1;this.controller=new AbortController;let c;try{const d=setTimeout(()=>{this.controller.abort()},b);c=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(d);if(this.isCancelled)return null;const e=await c.json();if(!c.ok){const g=getErrorType(c.status,
|
38 |
+
e),k=createErrorInfo(c.status,c.statusText,e.error,g);throw Error(k);}const f=checkResponse(e);if("ok"!==f){const g=createErrorInfo(c.status,c.statusText,e.error,f);throw Error(g);}return e[0].generated_text.trim()}catch(d){if(this.isCancelled)return null;if("AbortError"===d.name)throw a=createErrorInfo(0,"Timeout","La richiesta \u00e8 scaduta",TIMEOUT_ERROR),Error(a);throw d;}},cancelRequest(){this.controller&&(this.isCancelled=!0,this.controller.abort())}};
|
39 |
+
function getErrorInfo(a){let b={};try{b=JSON.parse(a.message)}catch(c){a=`getErrorInfo\n${a}`,console.error(a),b={status:"0",statusText:"status_errorInof",errorType:"UNKNOWN_ERROR_errorInfo",message:a}}finally{return b}}function errorToText(a){let b;try{const c=JSON.parse(a.message);b=`Error:
|
40 |
+
Status: ${c.status}
|
41 |
+
Status Text: ${c.statusText}
|
42 |
+
Error Type: ${c.errorType}
|
43 |
+
Message: ${c.message}`}catch(c){console.error(`errorToText\n${c}`),b=`${c}`}finally{return b}};const MAX_PROMPT_LENGTH=76800,PROMPT_DECR=2048,TIMEOUT=6E4;function wait(a){return new Promise(b=>setTimeout(b,1E3*a))}
|
44 |
const truncInput=(a,b)=>a.substring(0,a.length-b),setMaxLen=a=>a.substring(0,MAX_PROMPT_LENGTH-1E3),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}`);a=formatRow([a,b,c,d],[8,-7,-7,-7]);UaLog.log(a)},Rag=
|
45 |
{ragContext:"",ragQuery:"",ragAnswer:"",answers:[],docContextLst:[],prompts:[],doc:"",doc_part:"",init(){this.readRespsFromDb();this.readFromDb()},returnOk(){return 10<this.ragContext.length},saveToDb(){UaDb.saveJson(ID_RAG,{context:this.ragContext,ragquery:this.ragQuery,raganswer:this.ragAnswer});UaDb.saveArray(ID_THREAD,ThreadMgr.rows)},readFromDb(){const a=UaDb.readJson(ID_RAG);this.ragContext=a.context||"";this.ragQuery=a.ragquery||"";this.ragAnswer=a.raganswer||"";ThreadMgr.rows=UaDb.readArray(ID_THREAD)},
|
46 |
saveRespToDb(){UaDb.saveArray(ID_RESPONSES,this.answers)},readRespsFromDb(){this.answers=UaDb.readArray(ID_RESPONSES)},async requestDocsRAG(a){DataMgr.deleteJsonDati();DataMgr.readDbDocNames();DataMgr.readDbDocs();this.ragQuery=a;this.saveToDb();var b=0;try{var c=1;for(let e=0;e<DataMgr.docs.length;e++){let f=DataMgr.docs[e];if(""==f.trim())continue;const g=DataMgr.doc_names[e],k=f.length;xlog(`${g} (${k}) `);UaLog.log(`${g} (${k}) `);++b;var d=1;let h=0,l="",t="",u="",m="",v=[];for(;;){let r=getPartSize(f,
|
|
|
156 |
`}function getPayloadDoc(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:2E3,num_return_sequences:1,temperature:.4,top_p:.85,top_k:30,do_sample:!1,no_repeat_ngram_size:3,num_beams:4,repetition_penalty:1.2,return_full_text:!1,details:!1,max_time:90,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
157 |
function getPayloadBuildContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:6E3,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,do_sample:!1,no_repeat_ngram_size:4,num_beams:6,repetition_penalty:1.2,return_full_text:!1,details:!1,max_time:180,seed:42},options:{use_cache:!1,wait_for_model:!0}}}
|
158 |
function getPayloadWithContext(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:4E3,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,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}}}
|
159 |
+
function getPayloadThread(a){return{inputs:a,parameters:{task:"text2text-generation",max_new_tokens:6048,num_return_sequences:1,temperature:.7,top_p:.85,top_k:30,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 WndPre=a=>({w:UaWindowAdm.create(a),out:null,show(b){wnds.closeAll();b=`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
<div class="window-text">
|
161 |
<div class="btn-wrapper">
|
162 |
<button class="btn-copy" title="Copia">
|
|
|
188 |
try{let b=await Rag.requestDocsRAG(a);b=cleanOut(b);setOutText(b);this.inp.value="";UaLog.close()}catch(b){a=`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{let b=await Rag.requestContext(a);if(""==b){hideSpinner();return}b=cleanOut(b);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 ")},
|
189 |
clear(){confirm("Confermi cancellazione conversazione? ")&&(this.inp.value="",setOutText(""),ThreadMgr.init())}};
|
190 |
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.querySelector("#id-text-out .pre-text").textContent;wnds.wout.show(a)},async copy(){const a=document.querySelector("#id-text-out .pre-text"),b=a.textContent;if(!(2>b.trim().length)){a.classList.add("copied");
|
191 |
+
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.querySelector("#id-text-out .pre-text").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 / DOCX</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 ');
|
192 |
+
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 if("docx"===d){const f=new DocxHandler;await f.loadMammoth();e=await f.extractTextFromDocx(a);
|
193 |
+
f.cleanup()}else{alert("Formato file non supportato.");return}DataMgr.addDoc(b,e);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 / DOCX</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 ');
|
194 |
+
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_show(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 if("docx"===e){const g=new DocxHandler;
|
195 |
+
await g.loadMammoth();f=await g.extractTextFromDocx(c);g.cleanup()}else{alert("Formato file non supportato.");return}DataMgr.addDoc(d,f);b.push(`${d}`)}}catch(c){xerror("Error:",c),alert("Errore durante l'estrazione del testo dal file.")}finally{hideSpinner()}a=document.getElementById("result");b=b.join("<br>");a.innerHTML=b}else alert("Nessun file selezionato.")}};
|
196 |
class PdfHandler{constructor(){this.workerScriptElement=this.scriptElement=this.pdfjsLib=null}async loadPdfJs(){window.pdfjsLib||(this.scriptElement=document.createElement("script"),this.scriptElement.src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.min.js",document.body.appendChild(this.scriptElement),await new Promise(a=>{this.scriptElement.onload=()=>{this.workerScriptElement=document.createElement("script");this.workerScriptElement.src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.6.347/pdf.worker.min.js";
|
197 |
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&&
|
198 |
(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()}}
|
199 |
+
class DocxHandler{constructor(){this.scriptElement=this.mammoth=null}async loadMammoth(){window.mammoth?this.mammoth=window.mammoth:(this.scriptElement=document.createElement("script"),this.scriptElement.src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.11/mammoth.browser.min.js",document.body.appendChild(this.scriptElement),await new Promise(a=>{this.scriptElement.onload=()=>{this.mammoth=window.mammoth;a()}}))}async extractTextFromDocx(a){a=await a.arrayBuffer();return(await this.mammoth.extractRawText({arrayBuffer:a})).value}cleanup(){this.scriptElement&&
|
200 |
+
(document.body.removeChild(this.scriptElement),this.scriptElement=null);this.mammoth=null;window.gc&&window.gc()}}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";
|
201 |
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"},k=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=
|
202 |
k,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," ")}});function formatRow(a,b){return a.map((c,d)=>{d=b[d];return 0>d?c.toString().padStart(Math.abs(d)," "):c.toString().padEnd(d," ")}).join(" ")}
|
203 |
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,
|
static/less/ragrqs.less
CHANGED
@@ -101,31 +101,61 @@ body {
|
|
101 |
}
|
102 |
///////////////
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
// .theme-light {
|
110 |
-
// .btn-dark {
|
111 |
-
// display: inline-block !important;
|
112 |
-
// }
|
113 |
-
// }
|
114 |
-
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
120 |
|
121 |
-
|
122 |
-
|
123 |
-
//
|
124 |
-
//
|
125 |
-
|
126 |
|
|
|
|
|
|
|
|
|
|
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
|
130 |
/////////////////
|
131 |
.upload {
|
@@ -566,6 +596,7 @@ div.item2 {
|
|
566 |
}
|
567 |
}
|
568 |
|
|
|
569 |
div.menu-h {
|
570 |
background-color: lighten(@menu-bg, 10%);
|
571 |
position: fixed;
|
@@ -578,15 +609,15 @@ div.menu-h {
|
|
578 |
outline: none;
|
579 |
box-shadow: 0 0 0 2px @border-shadow;
|
580 |
z-index: 100;
|
581 |
-
// caret-color: transparent;
|
582 |
|
583 |
.release {
|
584 |
background: inherit;
|
585 |
color: lighten(@color1, 10%);
|
586 |
font-weight: bold;
|
587 |
-
margin-left:
|
588 |
margin-top: 0.5vh;
|
589 |
}
|
|
|
590 |
.menu-btn {
|
591 |
appearance: none;
|
592 |
}
|
@@ -618,8 +649,8 @@ div.menu-h {
|
|
618 |
margin-left: 2vw;
|
619 |
top: 0;
|
620 |
left: 0;
|
621 |
-
width:
|
622 |
-
height:
|
623 |
cursor: pointer;
|
624 |
padding: 2px 2px;
|
625 |
z-index: 1;
|
|
|
101 |
}
|
102 |
///////////////
|
103 |
|
104 |
+
.theme-dark {
|
105 |
+
.btn-light {
|
106 |
+
display: inline-block !important;
|
107 |
+
}
|
108 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
.theme-light {
|
111 |
+
.btn-dark {
|
112 |
+
display: inline-block !important;
|
113 |
+
}
|
114 |
+
}
|
115 |
|
116 |
+
.invert {
|
117 |
+
filter: invert(100%);
|
118 |
+
// background-color: white;
|
119 |
+
// background-color: black;
|
120 |
+
}
|
121 |
|
122 |
+
.invert img,
|
123 |
+
.invert video,
|
124 |
+
.invert iframe {
|
125 |
+
filter: invert(100%);
|
126 |
+
}
|
127 |
|
128 |
+
//UA Bottoni tema
|
129 |
+
// .display-theme {
|
130 |
+
// button {
|
131 |
+
// display: inline-block !important;
|
132 |
+
// }
|
133 |
+
// }
|
134 |
|
135 |
+
.btn-theme {
|
136 |
+
position: fixed;
|
137 |
+
top: 0;
|
138 |
+
right: 4vw;
|
139 |
+
height: 4vh;
|
140 |
+
background: inherit;
|
141 |
+
font-weight: bold;
|
142 |
+
margin-left: 5vw;
|
143 |
+
margin-top: 0.5vh;
|
144 |
+
z-index: 2000;
|
145 |
+
button {
|
146 |
+
color: #ffffff;
|
147 |
+
border: none;
|
148 |
+
background: none;
|
149 |
+
cursor: pointer;
|
150 |
+
padding: 5px;
|
151 |
+
display: none;
|
152 |
+
svg {
|
153 |
+
width: 24px;
|
154 |
+
height: 24px;
|
155 |
+
stroke: currentColor;
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
|
160 |
/////////////////
|
161 |
.upload {
|
|
|
596 |
}
|
597 |
}
|
598 |
|
599 |
+
// UA meu-h
|
600 |
div.menu-h {
|
601 |
background-color: lighten(@menu-bg, 10%);
|
602 |
position: fixed;
|
|
|
609 |
outline: none;
|
610 |
box-shadow: 0 0 0 2px @border-shadow;
|
611 |
z-index: 100;
|
|
|
612 |
|
613 |
.release {
|
614 |
background: inherit;
|
615 |
color: lighten(@color1, 10%);
|
616 |
font-weight: bold;
|
617 |
+
margin-left: 40vw;
|
618 |
margin-top: 0.5vh;
|
619 |
}
|
620 |
+
|
621 |
.menu-btn {
|
622 |
appearance: none;
|
623 |
}
|
|
|
649 |
margin-left: 2vw;
|
650 |
top: 0;
|
651 |
left: 0;
|
652 |
+
width: 25px;
|
653 |
+
height: 100%;
|
654 |
cursor: pointer;
|
655 |
padding: 2px 2px;
|
656 |
z-index: 1;
|
static/ragrqs.html
CHANGED
@@ -4,13 +4,30 @@
|
|
4 |
<head>
|
5 |
<meta charset="utf-8" />
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
-
<meta name="description" content="Author:
|
8 |
<title>RagRqs</title>
|
9 |
|
10 |
<link rel="stylesheet" href="css/ragrqs.min.css" />
|
11 |
<script src="js/ragrqs.min.js"></script>
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
<body>
|
15 |
<div id="spinner" class="spinner">
|
16 |
<div class="pulse-icon"></div>
|
@@ -25,24 +42,37 @@
|
|
25 |
</label>
|
26 |
|
27 |
<div class="head-wrapper">
|
28 |
-
|
29 |
<button class="help" onclick="Menu.help();" title="Istruzioni">?</button>
|
30 |
-
|
31 |
<button class="upload" onclick="Menu.upload();" ; title="Upload files">
|
32 |
<svg class="icon" viewBox="0 0 24 24">
|
33 |
<path d="M20 15v2H4v-2H2v5h20v-5zM13 5V1h-2v4H7l5 5 5-5z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
34 |
</svg>
|
35 |
</button>
|
36 |
-
|
37 |
<button class="upload" onclick="Menu.uploadDir();" ; title="Upload dir">
|
38 |
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
39 |
<path d="M20 6h-8l-2-2H4C2.9 4 2 4.9 2 6v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-8 7H8v2h4v-2zm6 0h-4v2h4v-2zm0-4H8v2h10V9z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
40 |
</svg>
|
41 |
</button>
|
42 |
-
|
43 |
<button class="log active" id="id_log" onclick="Menu.log();" title="Log">Log</button>
|
44 |
<label class="release"></label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
</div>
|
|
|
|
|
46 |
<div class="menu-box">
|
47 |
<ul>
|
48 |
<li><a href="#" onCLick="op0(this);">README</a></li>
|
@@ -61,12 +91,12 @@
|
|
61 |
<li>-</li>
|
62 |
<li><a href="#" onCLick="help1(this);">Esempi di documenti</a></li>
|
63 |
<li><a href="#" onCLick="help2(this);">Esempi di domande</a></li>
|
64 |
-
|
65 |
-
|
66 |
-
<li><a href="#" onCLick="showTesti(this);">Testo Documenti</a></li> -->
|
67 |
|
68 |
</ul>
|
69 |
</div>
|
|
|
70 |
</div>
|
71 |
|
72 |
<div class="container">
|
@@ -131,9 +161,10 @@
|
|
131 |
|
132 |
</html>
|
133 |
<script>
|
|
|
134 |
window.addEventListener('load', () => {
|
135 |
console.log("Tutti i file esterni (CSS, JavaScript, immagini) sono stati caricati");
|
136 |
openApp();
|
137 |
});
|
138 |
-
|
139 |
</script>
|
|
|
4 |
<head>
|
5 |
<meta charset="utf-8" />
|
6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
7 |
+
<meta name="description" content="Author:Giuseppe Materni" />
|
8 |
<title>RagRqs</title>
|
9 |
|
10 |
<link rel="stylesheet" href="css/ragrqs.min.css" />
|
11 |
<script src="js/ragrqs.min.js"></script>
|
12 |
|
13 |
+
<!-- <link rel="stylesheet" href="less/normalize.css" />
|
14 |
+
<link rel="stylesheet/less" href="less/ragrqs.less" />
|
15 |
+
<link rel="stylesheet/less" href="less/ualog3.less" />
|
16 |
+
<script src="less/less.js"></script>
|
17 |
+
<script src="javascript/uadrag.js"></script>
|
18 |
+
<script src="javascript/uawindow.js"></script>
|
19 |
+
<script src="javascript/uajtfh.js"></script>
|
20 |
+
<script src="javascript/ualog3.js"></script>
|
21 |
+
<script src="javascript/rag_cleaner.js"></script>
|
22 |
+
<script src="javascript/rag_data_mgr.js"></script>
|
23 |
+
<script src="javascript/rag_http.js"></script>
|
24 |
+
<script src="javascript/rag_mgr.js"></script>
|
25 |
+
<script src="javascript/rag_prompts.js"></script>
|
26 |
+
<script src="javascript/rag_upload.js"></script>
|
27 |
+
<script src="javascript/rag_ui.js"></script>
|
28 |
+
<script src="javascript/rag_env.js"></script>
|
29 |
+
<script src="javascript/app.js"></script> --> -->
|
30 |
+
|
31 |
<body>
|
32 |
<div id="spinner" class="spinner">
|
33 |
<div class="pulse-icon"></div>
|
|
|
42 |
</label>
|
43 |
|
44 |
<div class="head-wrapper">
|
|
|
45 |
<button class="help" onclick="Menu.help();" title="Istruzioni">?</button>
|
|
|
46 |
<button class="upload" onclick="Menu.upload();" ; title="Upload files">
|
47 |
<svg class="icon" viewBox="0 0 24 24">
|
48 |
<path d="M20 15v2H4v-2H2v5h20v-5zM13 5V1h-2v4H7l5 5 5-5z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
49 |
</svg>
|
50 |
</button>
|
|
|
51 |
<button class="upload" onclick="Menu.uploadDir();" ; title="Upload dir">
|
52 |
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
53 |
<path d="M20 6h-8l-2-2H4C2.9 4 2 4.9 2 6v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-8 7H8v2h4v-2zm6 0h-4v2h4v-2zm0-4H8v2h10V9z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
54 |
</svg>
|
55 |
</button>
|
|
|
56 |
<button class="log active" id="id_log" onclick="Menu.log();" title="Log">Log</button>
|
57 |
<label class="release"></label>
|
58 |
+
|
59 |
+
<div class="btn-theme">
|
60 |
+
<button class="btn-dark" title="Tema scuro" onclick="setDark()">
|
61 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
62 |
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
63 |
+
</svg>
|
64 |
+
</button>
|
65 |
+
<button class="btn-light" title="Tma charo" onclick="setLight()">
|
66 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
67 |
+
<circle cx="12" cy="12" r="5" />
|
68 |
+
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" />
|
69 |
+
</svg>
|
70 |
+
</button>
|
71 |
+
</div>
|
72 |
+
|
73 |
</div>
|
74 |
+
|
75 |
+
|
76 |
<div class="menu-box">
|
77 |
<ul>
|
78 |
<li><a href="#" onCLick="op0(this);">README</a></li>
|
|
|
91 |
<li>-</li>
|
92 |
<li><a href="#" onCLick="help1(this);">Esempi di documenti</a></li>
|
93 |
<li><a href="#" onCLick="help2(this);">Esempi di domande</a></li>
|
94 |
+
<!-- -->
|
95 |
+
<li><a href="#" onCLick="showPrompts(this);">prompts</a></li>
|
|
|
96 |
|
97 |
</ul>
|
98 |
</div>
|
99 |
+
|
100 |
</div>
|
101 |
|
102 |
<div class="container">
|
|
|
161 |
|
162 |
</html>
|
163 |
<script>
|
164 |
+
|
165 |
window.addEventListener('load', () => {
|
166 |
console.log("Tutti i file esterni (CSS, JavaScript, immagini) sono stati caricati");
|
167 |
openApp();
|
168 |
});
|
169 |
+
|
170 |
</script>
|
static/ragrqs_.html
CHANGED
@@ -7,54 +7,76 @@
|
|
7 |
<meta name="description" content="Author:Giuseppe Materni" />
|
8 |
<title>RagRqs</title>
|
9 |
|
|
|
|
|
|
|
|
|
10 |
<link rel="stylesheet" href="less/normalize.css" />
|
11 |
<link rel="stylesheet/less" href="less/ragrqs.less" />
|
12 |
<link rel="stylesheet/less" href="less/ualog3.less" />
|
13 |
<script src="less/less.js"></script>
|
14 |
-
|
15 |
<script src="javascript/uadrag.js"></script>
|
16 |
<script src="javascript/uawindow.js"></script>
|
17 |
<script src="javascript/uajtfh.js"></script>
|
18 |
<script src="javascript/ualog3.js"></script>
|
|
|
19 |
<script src="javascript/rag_cleaner.js"></script>
|
20 |
<script src="javascript/rag_data_mgr.js"></script>
|
21 |
<script src="javascript/rag_http.js"></script>
|
22 |
<script src="javascript/rag_mgr.js"></script>
|
23 |
<script src="javascript/rag_prompts.js"></script>
|
24 |
-
<script src="javascript/rag_rqs.js"></script>
|
25 |
<script src="javascript/rag_upload.js"></script>
|
26 |
<script src="javascript/rag_ui.js"></script>
|
27 |
<script src="javascript/rag_env.js"></script>
|
|
|
|
|
28 |
|
29 |
<body>
|
30 |
<div id="spinner" class="spinner">
|
31 |
<div class="pulse-icon"></div>
|
32 |
<div class="stop-message">Stop</div>
|
33 |
</div>
|
|
|
34 |
<div class="menu-h">
|
|
|
35 |
<input id="id-menu-btn" name="id-menu-btn" class="menu-btn" type="checkbox" />
|
36 |
<label for="id-menu-btn" class="menu-icon">
|
37 |
<span class="nav-icon"></span>
|
38 |
</label>
|
39 |
-
<div class="head-wrapper">
|
40 |
|
|
|
41 |
<button class="help" onclick="Menu.help();" title="Istruzioni">?</button>
|
42 |
-
|
43 |
<button class="upload" onclick="Menu.upload();" ; title="Upload files">
|
44 |
<svg class="icon" viewBox="0 0 24 24">
|
45 |
<path d="M20 15v2H4v-2H2v5h20v-5zM13 5V1h-2v4H7l5 5 5-5z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
46 |
</svg>
|
47 |
</button>
|
48 |
-
|
49 |
<button class="upload" onclick="Menu.uploadDir();" ; title="Upload dir">
|
50 |
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
51 |
<path d="M20 6h-8l-2-2H4C2.9 4 2 4.9 2 6v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-8 7H8v2h4v-2zm6 0h-4v2h4v-2zm0-4H8v2h10V9z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
52 |
</svg>
|
53 |
</button>
|
54 |
-
|
55 |
<button class="log active" id="id_log" onclick="Menu.log();" title="Log">Log</button>
|
56 |
<label class="release"></label>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</div>
|
|
|
|
|
58 |
<div class="menu-box">
|
59 |
<ul>
|
60 |
<li><a href="#" onCLick="op0(this);">README</a></li>
|
@@ -78,6 +100,7 @@
|
|
78 |
|
79 |
</ul>
|
80 |
</div>
|
|
|
81 |
</div>
|
82 |
|
83 |
<div class="container">
|
@@ -142,17 +165,11 @@
|
|
142 |
|
143 |
</html>
|
144 |
<script>
|
145 |
-
// document.addEventListener("DOMContentLoaded", function () {
|
146 |
-
// console.log("DOM completamente caricato e analizzato");
|
147 |
-
// window.addEventListener("load", function () {
|
148 |
-
// console.log("Tutti i file esterni (CSS, JavaScript, immagini) sono stati caricati");
|
149 |
-
// openApp();
|
150 |
-
// });
|
151 |
-
// });
|
152 |
|
153 |
window.addEventListener('load', () => {
|
154 |
console.log("Tutti i file esterni (CSS, JavaScript, immagini) sono stati caricati");
|
155 |
openApp();
|
156 |
});
|
|
|
157 |
|
158 |
</script>
|
|
|
7 |
<meta name="description" content="Author:Giuseppe Materni" />
|
8 |
<title>RagRqs</title>
|
9 |
|
10 |
+
<!-- <link rel="stylesheet" href="css/ragrqs.min.css" />
|
11 |
+
<script src="js/ragrqs.min.js"></script> -->
|
12 |
+
|
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 |
+
<!-- -->
|
24 |
<script src="javascript/rag_cleaner.js"></script>
|
25 |
<script src="javascript/rag_data_mgr.js"></script>
|
26 |
<script src="javascript/rag_http.js"></script>
|
27 |
<script src="javascript/rag_mgr.js"></script>
|
28 |
<script src="javascript/rag_prompts.js"></script>
|
|
|
29 |
<script src="javascript/rag_upload.js"></script>
|
30 |
<script src="javascript/rag_ui.js"></script>
|
31 |
<script src="javascript/rag_env.js"></script>
|
32 |
+
<!-- -->
|
33 |
+
<script src="javascript/app.js"></script>
|
34 |
|
35 |
<body>
|
36 |
<div id="spinner" class="spinner">
|
37 |
<div class="pulse-icon"></div>
|
38 |
<div class="stop-message">Stop</div>
|
39 |
</div>
|
40 |
+
|
41 |
<div class="menu-h">
|
42 |
+
|
43 |
<input id="id-menu-btn" name="id-menu-btn" class="menu-btn" type="checkbox" />
|
44 |
<label for="id-menu-btn" class="menu-icon">
|
45 |
<span class="nav-icon"></span>
|
46 |
</label>
|
|
|
47 |
|
48 |
+
<div class="head-wrapper">
|
49 |
<button class="help" onclick="Menu.help();" title="Istruzioni">?</button>
|
|
|
50 |
<button class="upload" onclick="Menu.upload();" ; title="Upload files">
|
51 |
<svg class="icon" viewBox="0 0 24 24">
|
52 |
<path d="M20 15v2H4v-2H2v5h20v-5zM13 5V1h-2v4H7l5 5 5-5z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
53 |
</svg>
|
54 |
</button>
|
|
|
55 |
<button class="upload" onclick="Menu.uploadDir();" ; title="Upload dir">
|
56 |
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
57 |
<path d="M20 6h-8l-2-2H4C2.9 4 2 4.9 2 6v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm-8 7H8v2h4v-2zm6 0h-4v2h4v-2zm0-4H8v2h10V9z" fill="none" stroke="#FFFFFF" stroke-width="2" />
|
58 |
</svg>
|
59 |
</button>
|
|
|
60 |
<button class="log active" id="id_log" onclick="Menu.log();" title="Log">Log</button>
|
61 |
<label class="release"></label>
|
62 |
+
|
63 |
+
<div class="btn-theme">
|
64 |
+
<button class="btn-dark" title="Tema scuro" onclick="setDark()">
|
65 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
66 |
+
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" />
|
67 |
+
</svg>
|
68 |
+
</button>
|
69 |
+
<button class="btn-light" title="Tma charo" onclick="setLight()">
|
70 |
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
71 |
+
<circle cx="12" cy="12" r="5" />
|
72 |
+
<path d="M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42" />
|
73 |
+
</svg>
|
74 |
+
</button>
|
75 |
+
</div>
|
76 |
+
|
77 |
</div>
|
78 |
+
|
79 |
+
|
80 |
<div class="menu-box">
|
81 |
<ul>
|
82 |
<li><a href="#" onCLick="op0(this);">README</a></li>
|
|
|
100 |
|
101 |
</ul>
|
102 |
</div>
|
103 |
+
|
104 |
</div>
|
105 |
|
106 |
<div class="container">
|
|
|
165 |
|
166 |
</html>
|
167 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
|
169 |
window.addEventListener('load', () => {
|
170 |
console.log("Tutti i file esterni (CSS, JavaScript, immagini) sono stati caricati");
|
171 |
openApp();
|
172 |
});
|
173 |
+
// openApp();
|
174 |
|
175 |
</script>
|