fix dependency n viz.js added

This commit is contained in:
Tobias Weise 2024-05-26 19:53:36 +02:00
parent e65253055c
commit 357054b5af
4 changed files with 293 additions and 0 deletions

View File

@ -11,6 +11,28 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.js" integrity="sha512-q/dWJ3kcmjBLU4Qc47E4A9kTB4m3wuTY7vkFJDTZKjTs8jhyGQnaUrxa0Ytd0ssMZhbNua9hE+E7Qv1j+DyZwA==" crossorigin="anonymous"></script>
</head> </head>
<body> <body>
<!--
<dot-graph layout="fdp" style="width:800px; height:600px; box-shadow: 10px 5px 5px black;">
digraph G {
graph [
splines=spline
];
node [shape=rect];
A->B
A->C
A->D
C->D
}
</dot-graph>
-->
<div class="w3-container"> <div class="w3-container">

View File

@ -2,6 +2,7 @@
elasticsearch elasticsearch
elasticsearch-dsl elasticsearch-dsl
langchain langchain
langchain-community
tiktoken tiktoken
pydantic pydantic

214
backend/viz.js Executable file

File diff suppressed because one or more lines are too long

56
backend/viz_widget.js Executable file
View File

@ -0,0 +1,56 @@
class DotGraphElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
this.content_div = document.createElement('div');
this.shadowRoot.appendChild(this.content_div);
this.slot_ele = document.createElement('slot');
this.shadowRoot.appendChild(this.slot_ele);
this.dot_text = "";
}
connectedCallback(){
let layout = this.hasAttribute('layout') ? this.getAttribute('layout') : "fdp";
let style = this.hasAttribute('style') ? this.getAttribute('style') : "";
this.content_div.style = style;
let that = this;
this.slot_ele.addEventListener('slotchange', e => {
let graphviz_text = that.textContent;
this.dot_text = graphviz_text;
this.content_div.innerHTML = Viz(this.dot_text, {engine:layout});
this.slot_ele.style.display = "none";
this.content_div.children[0].setAttribute("width", this.content_div.style.width);
this.content_div.children[0].setAttribute("height", this.content_div.style.height);
});
}
disconnectedCallback() {
}
attributeChangedCallback(name, oldValue, newValue) {
//this.displayVal.innerText = this.value;
}
get layout(){
}
set layout(x){
}
get value(){
//dot code
}
set value(x){
}
}
customElements.define('dot-graph', DotGraphElement);