All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev-ui.qwc-embedding-store.js Maven / Gradle / Ivy

The newest version!
import { LitElement, html, css} from 'lit';
import { JsonRpc } from 'jsonrpc';
import '@vaadin/button';
import '@vaadin/text-field';
import '@vaadin/text-area';
import '@vaadin/grid';
import '@vaadin/progress-bar';
import 'qui-alert';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import '@vaadin/grid/vaadin-grid-sort-column.js';


export class QwcEmbeddingStore extends LitElement {

    jsonRpc = new JsonRpc(this);

    static styles = css`
        :host {
            height: 100%;
            display: flex;
	    flex-direction: column;
        }
    `;

    static properties = {
        "_addEmbeddingConfirmation": {state: true},
        "_relevantEmbeddingsOutput": {state: true}
    }

    render() {
            return html`
                

Add a new embedding




this._addEmbedding( this.shadowRoot.getElementById('embedding-id').value, this.shadowRoot.getElementById('embedding-text').value, this.shadowRoot.getElementById('metadata').value )}>Create and store ${this._addEmbeddingConfirmation}

Search for relevant embeddings



this._findRelevant( this.shadowRoot.getElementById('search-text').value, this.shadowRoot.getElementById('search-limit').value )}>Search
${this._relevantEmbeddingsOutput} `; } _addEmbedding(id, text, metadata) { this._addEmbeddingConfirmation = html` `; this.jsonRpc.add({id: id, text: text, metadata: metadata}).then(jsonRpcResponse => { this._addEmbeddingConfirmation = html` The embedding was added with ID ${jsonRpcResponse.result}. `; }).catch((error) => { this._addEmbeddingConfirmation = html` ${JSON.stringify(error.error)} `; }); } _findRelevant(text, limit){ this._relevantEmbeddingsOutput = html``; this.jsonRpc.findRelevant({text: text, limit: limit}).then(jsonRpcResponse => { this._relevantEmbeddingsOutput = html` `; }).catch((error) => { this._relevantEmbeddingsOutput = html` ${JSON.stringify(error.error)} ` }); } _embeddingMatchMetadataRenderer(match) { if (match.metadata && match.metadata.length > 0) { return html` ${match.metadata.map((entry) => html`
${entry.key}:${entry.value}
` )}
`; } } } customElements.define('qwc-embedding-store', QwcEmbeddingStore);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy