parent
63601fabd1
commit
0b330d90ad
@ -1,120 +0,0 @@ |
|||||||
<!DOCTYPE html> |
|
||||||
<html> |
|
||||||
<head> |
|
||||||
<title>llama-cli</title> |
|
||||||
<meta charset="UTF-8"> |
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" /> |
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> |
|
||||||
</head> |
|
||||||
<style> |
|
||||||
@keyframes rotating { |
|
||||||
from { |
|
||||||
transform: rotate(0deg); |
|
||||||
} |
|
||||||
to { |
|
||||||
transform: rotate(360deg); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
.waiting { |
|
||||||
animation: rotating 1s linear infinite; |
|
||||||
} |
|
||||||
|
|
||||||
</style> |
|
||||||
<body> |
|
||||||
|
|
||||||
<div class="container mt-5" x-data="{ templates:[ |
|
||||||
{ |
|
||||||
name: 'Alpaca: Instruction without input', |
|
||||||
text: `Below is an instruction that describes a task. Write a response that appropriately completes the request. |
|
||||||
|
|
||||||
### Instruction: |
|
||||||
{{.Instruction}} |
|
||||||
|
|
||||||
### Response:`, |
|
||||||
}, |
|
||||||
{ |
|
||||||
name: 'Alpaca: Instruction with input', |
|
||||||
text: `Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request. |
|
||||||
|
|
||||||
### Instruction: |
|
||||||
{{.Instruction}} |
|
||||||
|
|
||||||
### Input: |
|
||||||
{{.Input}} |
|
||||||
|
|
||||||
### Response:`, |
|
||||||
} |
|
||||||
], selectedTemplate: '', selectedTemplateText: '' }"> |
|
||||||
<h1>llama-cli API</h1> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="inputText">Input Text:</label> |
|
||||||
<textarea class="form-control" id="inputText" rows="6" placeholder="Your text input here..." x-text="selectedTemplateText"></textarea> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="templateSelect">Select Template:</label> |
|
||||||
<select class="form-control" id="templateSelect" x-model="selectedTemplateText"> |
|
||||||
<option value="">None</option> |
|
||||||
<template x-for="(template, index) in templates" :key="index"> |
|
||||||
<option :value="template.text" x-text="template.name"></option> |
|
||||||
</template> |
|
||||||
</select> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="topP">Top P:</label> |
|
||||||
<input type="range" step="0.01" min="0" max="1" class="form-control" id="topP" value="0.20" name="topP" onchange="this.nextElementSibling.value = this.value" required> |
|
||||||
<output>0.20</output> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="topK">Top K:</label> |
|
||||||
<input type="number" class="form-control" id="topK" value="10000" name="topK" required> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="temperature">Temperature:</label> |
|
||||||
<input type="range" step="0.01" min="0" max="1" value="0.9" class="form-control" id="temperature" name="temperature" onchange="this.nextElementSibling.value = this.value" required> |
|
||||||
<output>0.9</output> |
|
||||||
</div> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="tokens">Tokens:</label> |
|
||||||
<input type="number" class="form-control" id="tokens" name="tokens" value="128" required> |
|
||||||
</div> |
|
||||||
<button class="btn btn-primary" x-on:click="submitRequest()">Submit <i class="fas fa-paper-plane"></i></button> |
|
||||||
<hr> |
|
||||||
<div class="form-group"> |
|
||||||
<label for="outputText">Output Text:</label> |
|
||||||
<textarea class="form-control" id="outputText" rows="5" readonly></textarea> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> |
|
||||||
<script> |
|
||||||
function submitRequest() { |
|
||||||
var button = document.querySelector("i.fa-paper-plane"); |
|
||||||
button.classList.add("waiting"); |
|
||||||
var text = document.getElementById("inputText").value; |
|
||||||
var url = "/predict"; |
|
||||||
var data = { |
|
||||||
"text": text, |
|
||||||
"topP": document.getElementById("topP").value, |
|
||||||
"topK": document.getElementById("topK").value, |
|
||||||
"temperature": document.getElementById("temperature").value, |
|
||||||
"tokens": document.getElementById("tokens").value |
|
||||||
}; |
|
||||||
fetch(url, { |
|
||||||
method: "POST", |
|
||||||
headers: { |
|
||||||
"Content-Type": "application/json" |
|
||||||
}, |
|
||||||
body: JSON.stringify(data) |
|
||||||
}) |
|
||||||
.then(response => response.json()) |
|
||||||
.then(data => { |
|
||||||
document.getElementById("outputText").value = data.prediction; |
|
||||||
button.classList.remove("waiting"); |
|
||||||
}) |
|
||||||
.catch(error => { console.error(error); button.classList.remove("waiting"); }); |
|
||||||
} |
|
||||||
</script> |
|
||||||
</body> |
|
||||||
</html> |
|
Loading…
Reference in new issue