Spaces:
Runtime error
Runtime error
Update application/templates/index.html
#1
by
MisterProton
- opened
application/static/js/components/chat.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
| 1 |
-
import requests from "./request.js";
|
| 2 |
-
|
| 3 |
-
class Chat{
|
| 4 |
-
constructor(uiManager){
|
| 5 |
-
this.uiManager = uiManager;
|
| 6 |
-
}
|
| 7 |
-
async chat(){
|
| 8 |
-
let payload = {
|
| 9 |
-
"model": this.uiManager.initializer.model,
|
| 10 |
-
"prompt": this.uiManager.userP.innerText.trim(),
|
| 11 |
-
"convId": this.uiManager.initializer.convId,
|
| 12 |
-
"system": this.uiManager.initializer.systemPrompt,
|
| 13 |
-
"temperature": 0.
|
| 14 |
-
"top_p": 0.9
|
| 15 |
-
};
|
| 16 |
-
try {
|
| 17 |
-
if(this.uiManager.initializer.convId==null){
|
| 18 |
-
await this.uiManager.initializer.createConv();
|
| 19 |
-
payload["convId"] = this.uiManager.initializer.convId;
|
| 20 |
-
}
|
| 21 |
-
this.uiManager.textBox.value='';
|
| 22 |
-
this.uiManager.sendBtn.disabled = true;
|
| 23 |
-
const response = await requests.request('POST','/completions',{"Content-Type": "application/json"},JSON.stringify(payload),true);
|
| 24 |
-
for await (const chunk of response){
|
| 25 |
-
this.uiManager.aiP.innerHTML+=chunk;
|
| 26 |
-
this.uiManager.renderSymbols.renderAll(this.uiManager.aiP)
|
| 27 |
-
};
|
| 28 |
-
} catch (error) {
|
| 29 |
-
this.uiManager.sendBtn.disabled = false;
|
| 30 |
-
this.uiManager.aiP.innerHTML+= `<span class="error" style="color: red;">${error}</span>`;
|
| 31 |
-
return
|
| 32 |
-
}
|
| 33 |
-
this.uiManager.renderSymbols.renderCode(this.uiManager.aiP);
|
| 34 |
-
if(this.uiManager.initializer.convTitle==null){
|
| 35 |
-
this.uiManager.initializer.convTitle = this.uiManager.userP.innerText.substring(0,23);
|
| 36 |
-
this.uiManager.addChat();
|
| 37 |
-
}
|
| 38 |
-
this.uiManager.sendBtn.disabled = false;
|
| 39 |
-
|
| 40 |
-
}
|
| 41 |
-
}
|
| 42 |
-
|
| 43 |
export default Chat
|
|
|
|
| 1 |
+
import requests from "./request.js";
|
| 2 |
+
|
| 3 |
+
class Chat{
|
| 4 |
+
constructor(uiManager){
|
| 5 |
+
this.uiManager = uiManager;
|
| 6 |
+
}
|
| 7 |
+
async chat(){
|
| 8 |
+
let payload = {
|
| 9 |
+
"model": this.uiManager.initializer.model,
|
| 10 |
+
"prompt": this.uiManager.userP.innerText.trim(),
|
| 11 |
+
"convId": this.uiManager.initializer.convId,
|
| 12 |
+
"system": this.uiManager.initializer.systemPrompt,
|
| 13 |
+
"temperature": 0.7,
|
| 14 |
+
"top_p": 0.9
|
| 15 |
+
};
|
| 16 |
+
try {
|
| 17 |
+
if(this.uiManager.initializer.convId==null){
|
| 18 |
+
await this.uiManager.initializer.createConv();
|
| 19 |
+
payload["convId"] = this.uiManager.initializer.convId;
|
| 20 |
+
}
|
| 21 |
+
this.uiManager.textBox.value='';
|
| 22 |
+
this.uiManager.sendBtn.disabled = true;
|
| 23 |
+
const response = await requests.request('POST','/completions',{"Content-Type": "application/json"},JSON.stringify(payload),true);
|
| 24 |
+
for await (const chunk of response){
|
| 25 |
+
this.uiManager.aiP.innerHTML+=chunk;
|
| 26 |
+
this.uiManager.renderSymbols.renderAll(this.uiManager.aiP)
|
| 27 |
+
};
|
| 28 |
+
} catch (error) {
|
| 29 |
+
this.uiManager.sendBtn.disabled = false;
|
| 30 |
+
this.uiManager.aiP.innerHTML+= `<span class="error" style="color: red;">${error}</span>`;
|
| 31 |
+
return
|
| 32 |
+
}
|
| 33 |
+
this.uiManager.renderSymbols.renderCode(this.uiManager.aiP);
|
| 34 |
+
if(this.uiManager.initializer.convTitle==null){
|
| 35 |
+
this.uiManager.initializer.convTitle = this.uiManager.userP.innerText.substring(0,23);
|
| 36 |
+
this.uiManager.addChat();
|
| 37 |
+
}
|
| 38 |
+
this.uiManager.sendBtn.disabled = false;
|
| 39 |
+
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
export default Chat
|
application/templates/index.html
CHANGED
|
@@ -1,55 +1,55 @@
|
|
| 1 |
-
<!DOCTYPE html>
|
| 2 |
-
<html lang="en">
|
| 3 |
-
<head>
|
| 4 |
-
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
| 5 |
-
<meta charset="UTF-8">
|
| 6 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
| 8 |
-
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap" rel="stylesheet">
|
| 9 |
-
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700&display=swap" rel="stylesheet">
|
| 10 |
-
|
| 11 |
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
|
| 12 |
-
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
| 13 |
-
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 14 |
-
<title>Chat Completion Demo</title>
|
| 15 |
-
</head>
|
| 16 |
-
<body>
|
| 17 |
-
<nav>
|
| 18 |
-
<select name="" id="models" class="models">
|
| 19 |
-
</select>
|
| 20 |
-
<div class="hamburger" id="hamburger">
|
| 21 |
-
<div class="line1"></div>
|
| 22 |
-
<div class="line2"></div>
|
| 23 |
-
</div>
|
| 24 |
-
<div class="menu" id="menu">
|
| 25 |
-
<div class="newChat" id="newChat">+ New Chat</div>
|
| 26 |
-
<p class="chatsTxt">chats</p>
|
| 27 |
-
<div class="prevChatsCont" id="prevChatsCont">
|
| 28 |
-
</div>
|
| 29 |
-
</div>
|
| 30 |
-
|
| 31 |
-
</nav>
|
| 32 |
-
<div class="container" id="container">
|
| 33 |
-
<div class="messages" id="messages">
|
| 34 |
-
</div>
|
| 35 |
-
<div class="inputs">
|
| 36 |
-
<textarea name="" id="textBox" class="textBox" placeholder="Enter your message..."></textarea>
|
| 37 |
-
<button id="sendBtn" class="sendBtn"><i class="fa-solid fa-arrow-up"></i></button>
|
| 38 |
-
</div>
|
| 39 |
-
</div>
|
| 40 |
-
<div class="alert" id="alert">
|
| 41 |
-
<div class="closeAlert" id="closeAlert">X</div>
|
| 42 |
-
<p class="note">Note</p>
|
| 43 |
-
<p>---> You can easily use your own API provider to run this application; just update the pipeline.json file</p>
|
| 44 |
-
<p>---> The file/image attachment feature for the vision model has not been implemented yet.</p>
|
| 45 |
-
<a href="https://discord.gg/tRC7hNXfPH" class="discord"
|
| 46 |
-
</div>
|
| 47 |
-
<div class="textCustomization">
|
| 48 |
-
<div class="colors"></div>
|
| 49 |
-
<div class="fontSize"></div>
|
| 50 |
-
<div class="background"></div>
|
| 51 |
-
</div>
|
| 52 |
-
<script src="{{ url_for('static', filename='js/script.js') }}" type="module"></script>
|
| 53 |
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
|
| 54 |
-
</body>
|
| 55 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
| 5 |
+
<meta charset="UTF-8">
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
|
| 8 |
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap" rel="stylesheet">
|
| 9 |
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700&display=swap" rel="stylesheet">
|
| 10 |
+
|
| 11 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
|
| 12 |
+
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
| 13 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 14 |
+
<title>Chat Completion Demo</title>
|
| 15 |
+
</head>
|
| 16 |
+
<body>
|
| 17 |
+
<nav>
|
| 18 |
+
<select name="" id="models" class="models">
|
| 19 |
+
</select>
|
| 20 |
+
<div class="hamburger" id="hamburger">
|
| 21 |
+
<div class="line1"></div>
|
| 22 |
+
<div class="line2"></div>
|
| 23 |
+
</div>
|
| 24 |
+
<div class="menu" id="menu">
|
| 25 |
+
<div class="newChat" id="newChat">+ New Chat</div>
|
| 26 |
+
<p class="chatsTxt">chats</p>
|
| 27 |
+
<div class="prevChatsCont" id="prevChatsCont">
|
| 28 |
+
</div>
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
</nav>
|
| 32 |
+
<div class="container" id="container">
|
| 33 |
+
<div class="messages" id="messages">
|
| 34 |
+
</div>
|
| 35 |
+
<div class="inputs">
|
| 36 |
+
<textarea name="" id="textBox" class="textBox" placeholder="Enter your message..."></textarea>
|
| 37 |
+
<button id="sendBtn" class="sendBtn"><i class="fa-solid fa-arrow-up"></i></button>
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
<div class="alert" id="alert">
|
| 41 |
+
<div class="closeAlert" id="closeAlert">X</div>
|
| 42 |
+
<p class="note">Note</p>
|
| 43 |
+
<p>---> You can easily use your own API provider to run this application; just update the pipeline.json file</p>
|
| 44 |
+
<p>---> The file/image attachment feature for the vision model has not been implemented yet.</p>
|
| 45 |
+
<a href="https://discord.gg/tRC7hNXfPH" class="discord" target="_blank"> Join Discord </a>
|
| 46 |
+
</div>
|
| 47 |
+
<div class="textCustomization">
|
| 48 |
+
<div class="colors"></div>
|
| 49 |
+
<div class="fontSize"></div>
|
| 50 |
+
<div class="background"></div>
|
| 51 |
+
</div>
|
| 52 |
+
<script src="{{ url_for('static', filename='js/script.js') }}" type="module"></script>
|
| 53 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
|
| 54 |
+
</body>
|
| 55 |
</html>
|