1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {html} from '//resources/lit/v3_0/lit.rollup.js';
import type {ToolsElement} from './tools.js';
export function getHtml(this: ToolsElement) {
// clang-format off
return html`<!--_html_template_start_-->
<div class="performance-class">
Device performance class: <strong>${this.performanceClassText_}</strong>
</div>
<cr-input id="modelInput" label="Model directory" placeholder="/tmp/model"
?disabled="${this.isLoading_()}"
error-message="${this.error_}" ?invalid="${this.error_.length}" autofocus>
<cr-button slot="suffix" ?disabled="${this.isLoading_()}"
@click="${this.onLoadClick_}">
Load
</cr-button>
</cr-input>
<div class="model-options">
<select id="performanceHintSelect" class="md-select"
value="${this.performanceHint_}" @change="${this.onPerformanceHintChange_}">
<option value="kHighestQuality">Highest Quality</option>
<option value="kFastestInference">Fastest Inference</option>
</select>
</div>
<div class="model-text">
${this.getModelText_()}
<div class="throbber" ?hidden="${!this.isLoading_()}"></div>
</div>
<cr-expand-button class="cr-row first" ?expanded="${this.contextExpanded_}"
@expanded-changed="${this.onContextExpandedChanged_}"
?disabled="${!this.model_}">
Context options (current size: ${this.contextLength_} words)
</cr-expand-button>
<cr-collapse id="expandedContent" ?opened="${this.contextExpanded_}">
<cr-textarea type="text" label="Context" .value="${this.contextText_}"
@value-changed="${this.onContextTextChanged_}">
</cr-textarea>
<cr-button @click="${this.onAddContextClick_}">Add</cr-button>
<cr-button class="cr-button-gap" @click="${this.startNewSession_}">
New session
</cr-button>
</cr-collapse>
<div class="output-options">
<cr-input id="topKInput" type="number" min="1" max="128" label="Top K"
error-message="Top K must be between 1 and 128" auto-validate
.value="${this.topK_}" @value-changed="${this.onTopKChanged_}">
</cr-input>
<cr-input id="temperatureInput" type="number" min="0" max="2"
label="Temperature" auto-validate
error-message="Temperature must be between 0 and 2"
.value="${this.temperature_}"
@value-changed="${this.onTemperatureChanged_}">
</cr-input>
</div>
<cr-textarea type="text" id="textInput" label="Input"
placeholder="Place control tokens {$SYSTEM, $MODEL, $USER, $END} on their own lines, in between lines of text."
.value="${this.text_}" @value-changed="${this.onTextChanged_}">
</cr-textarea>
<div class="multimodal-buttons" >
<div class="image-buttons" ?hidden="${!this.imagesEnabled_()}">
<div class="image-error">${this.imageError_}</div>
<div ?hidden="${this.imageFile_}">
<cr-button class="floating-button"
?disabled="${!this.canUploadFile_()}"
@click="${this.onAddImageClick_}">
<cr-icon icon="cr:add" slot="prefix-icon"></cr-icon>
Add image
</cr-button>
<input id="imageInput" type="file">
</div>
${this.imageFile_ ? html`
<cr-button class="floating-button" @click="${this.onRemoteImageClick_}">
<cr-icon icon="cr:delete" slot="prefix-icon"></cr-icon>
${this.imageFile_.name}
</cr-button>
` : ''}
</div>
<div class="audio-buttons" ?hidden="${!this.audioEnabled_()}">
<div class="audio-error">${this.audioError_}</div>
<div ?hidden="${this.audioFile_}">
<cr-button class="floating-button"
?disabled="${!this.canUploadFile_()}"
@click="${this.onAddAudioClick_}">
<cr-icon icon="cr:add" slot="prefix-icon"></cr-icon>
Add audio
</cr-button>
<input id="audioInput" type="file" accept="audio/*">
</div>
${this.audioFile_ ? html`
<cr-button class="floating-button" @click="${this.onRemoteAudioClick_}">
<cr-icon icon="cr:delete" slot="prefix-icon"></cr-icon>
${this.audioFile_.name}
</cr-button>
` : ''}
</div>
</div>
<div>
<cr-button class="action-button" ?disabled="${!this.canExecute_()}"
@click="${this.onExecuteClick_}">
Execute
</cr-button>
<cr-button ?disabled="${!this.currentResponse_}"
@click="${this.onCancelClick_}">
Cancel
</cr-button>
</div>
${this.currentResponse_ ? html`
<div class="session">
<div class="text">${this.currentResponse_.text}</div>
<div ?hidden="${!this.currentResponse_.response.length}"
class="${this.currentResponse_.responseClass}"><!--
-->${this.currentResponse_.response}</div>
<div class="throbber"
?hidden="${this.currentResponse_.response.length}"></div>
</div>
` : ''}
${this.responses_.map(item => html`
<div class="session">
<div class="text">${item.text}</div>
<div class="${item.responseClass}">${item.response}</div>
</div>
`)}
<!--_html_template_end_-->`;
// clang-format on
}
|