Skip to content

Commit

Permalink
Version 3.2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Davidasx committed Nov 7, 2024
1 parent 2bb5039 commit 690e7b9
Show file tree
Hide file tree
Showing 17 changed files with 603 additions and 488 deletions.
14 changes: 12 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
## Current Version:

[![](https://img.shields.io/badge/Dev-3.2.4.1-blue)](https://github.com/Davidasx/flask-gpt/tree/dev)
[![](https://img.shields.io/badge/Dev-3.2.4.3-blue)](https://github.com/Davidasx/flask-gpt/tree/dev)
[![](https://img.shields.io/badge/Main-3.2.3-red)](https://github.com/Davidasx/flask-gpt/tree/main)

## Update Log (only after 3.1.0):

### 3.2.4.3

#### [![](https://img.shields.io/badge/Dev-20241107-blue)](https://github.com/Davidasx/flask-gpt)

Minor fixes.

Improvements to the filesystem structure.

Updated sender button.

### 3.2.4.2

#### [![](https://img.shields.io/badge/Dev-20241107-blue)](https://github.com/Davidasx/flask-gpt/)
#### [![](https://img.shields.io/badge/Dev-20241107-blue)](https://github.com/Davidasx/flask-gpt/tree/2bb503973ea2eb8afe60c711d8dec9e1654588dd)

New feature: add custom models to the settings.

Expand Down
29 changes: 18 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
href="https://www.freelogovectors.net/wp-content/uploads/2023/01/chatgpt-logo-freelogovectors.net_.png"
type="image/svg+xml">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link rel="stylesheet" href="static/styles.css">
<link rel="stylesheet" href="static/styles/layout.css">
<link rel="stylesheet" href="static/styles/settings.css">
<link rel="stylesheet" href="static/styles/components.css">
<link rel="stylesheet" href="static/styles/mobile.css">
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
Expand All @@ -23,22 +26,26 @@
<div class="chat-input">
<input type="text" id="message" placeholder="Enter your message" onkeydown="checkEnter(event)"
oninput="checkMessage()">
<button id="send-button" onclick="sendMessage()" data-i18n="send" disabled>Send</button>
<button id="send-button" onclick="sendMessage()" class="send-button" data-i18n-title="send" disabled>
<i class="fas fa-paper-plane"></i>
</button>
</div>
</div>

<!-- Modal for settings -->
<div id="settings-modal" class="modal">
<div class="modal-content">
<span class="close" onclick="closeSettings()">&times;</span>
<h3 data-i18n="settings">Settings</h3>
<div class="modal-header">
<h3 data-i18n="settings">Settings</h3>
<span class="close" onclick="closeSettings()">&times;</span>
</div>
<h4 data-i18n="api-settings">API Settings</h4>
<div class="input-group">
<label for="base-url" data-i18n="base-url">Base URL:</label>
<label for="base-url">Base URL:</label>
<input type="text" id="base-url" placeholder="Base URL">
</div>
<div class="input-group">
<label for="api-key" data-i18n="api-key">API Key:</label>
<label for="api-key">API Key:</label>
<input type="text" id="api-key" placeholder="API Key">
</div>
<div class="button-container-end">
Expand Down Expand Up @@ -82,11 +89,11 @@ <h4 data-i18n="history">Chat History</h4>
</div>
</div>

<script src="static/formatter.js"></script>
<script src="static/message.js"></script>
<script src="static/scripts.js"></script>
<script src="static/i18n.js"></script>
<script src="static/model.js"></script>
<script src="static/scripts/formatter.js"></script>
<script src="static/scripts/message.js"></script>
<script src="static/scripts/main.js"></script>
<script src="static/scripts/i18n.js"></script>
<script src="static/scripts/model.js"></script>
</body>

</html>
48 changes: 0 additions & 48 deletions static/i18n.js

This file was deleted.

57 changes: 57 additions & 0 deletions static/locales.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"version": "3.2.4.3",
"translations":{
"en": {
"input": "Enter your message",
"send": "Send",
"settings": "Settings",
"api-settings": "API Settings",
"history": "Chat History",
"sync": "Sync",
"clear": "Clear Memory",
"save": "Save",
"language": "Language",
"invalid-uuid": "Please enter a valid UUID",
"unknown-error": "Unknown Error",
"uuid-not-found": "UUID does not exist",
"memory-clear": "Are you sure you want to clear the memory?",
"model": "Model",
"custom": "Custom"
},
"zh-cn": {
"input": "输入你的消息",
"send": "发送",
"settings": "设置",
"api-settings": "API 设置",
"history": "聊天记录",
"sync": "同步",
"clear": "清空记忆",
"save": "保存",
"language": "语言",
"invalid-uuid": "请输入有效的UUID",
"unknown-error": "未知错误",
"uuid-not-found": "UUID不存在",
"memory-clear": "确定要清除记忆吗?",
"model": "模型",
"custom": "自定义"
},
"zh-hk": {
"version": "3.2.4.2",
"input": "輸入你的消息",
"send": "發送",
"settings": "設置",
"api-settings": "API 設置",
"history": "聊天記錄",
"sync": "同步",
"clear": "清空記憶",
"save": "保存",
"language": "語言",
"invalid-uuid": "請輸入有效的UUID",
"unknown-error": "未知錯誤",
"uuid-not-found": "UUID不存在",
"memory-clear": "確定要清除記憶嗎?",
"model": "模型",
"custom": "自定義"
}
}
}
18 changes: 0 additions & 18 deletions static/locales/en.json

This file was deleted.

18 changes: 0 additions & 18 deletions static/locales/zh-cn.json

This file was deleted.

18 changes: 0 additions & 18 deletions static/locales/zh-hk.json

This file was deleted.

2 changes: 0 additions & 2 deletions static/formatter.js → static/scripts/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ function formatMessage(message) {
// Remove the same number of leading spaces from each line
p2 = lines.map(line => line.substring(minLeadingSpaces)).join('\n');
indentLevel = minLeadingSpaces;
console.log('Indent=' + indentLevel);

for (let i = 0; i < p2.length; i++) {
const char = p2[i];
Expand Down Expand Up @@ -162,7 +161,6 @@ function formatMessage(message) {

// Remove blank lines at the end of code blocks
message = message.replace(/<\/pre>\n+/gim, '</pre>');
console.log(message);
answer = message.trim();
message = original;
return answer;
Expand Down
64 changes: 64 additions & 0 deletions static/scripts/i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
async function loadTranslations() {
const response = await fetch('/static/locales.json');
const data = await response.json();
return data;
}

function translatePage(translations, lang) {
document.querySelectorAll('[data-i18n]').forEach(element => {
const key = element.getAttribute('data-i18n');
if (translations[lang] && translations[lang][key]) {
element.textContent = translations[lang][key];
} else {
element.textContent = key;
}
});

document.querySelectorAll('[data-i18n-title]').forEach(element => {
const key = element.getAttribute('data-i18n-title');
if (translations[lang] && translations[lang][key]) {
element.setAttribute('title', translations[lang][key]);
} else {
element.setAttribute('title', key);
}
});

const messageElement = document.getElementById('message');
if (messageElement) {
if (translations[lang] && translations[lang]['input']) {
messageElement.placeholder = translations[lang]['input'];
} else {
messageElement.placeholder = 'Enter your message';
}
}
}

function translate(key) {
const lang = localStorage.getItem('language') || 'en';
const allTranslations = JSON.parse(localStorage.getItem('allTranslations')) || {};
return allTranslations[lang][key] || key;
}

async function setLanguage(lang) {
const allTranslations = JSON.parse(localStorage.getItem('allTranslations')) || {};
translatePage(allTranslations, lang);
localStorage.setItem('language', lang);
}

document.addEventListener('DOMContentLoaded', async () => {
const savedLanguage = localStorage.getItem('language') || 'en';
const storedVersion = localStorage.getItem('translations_version');
const data = await loadTranslations();
const currentVersion = data.version;
const allTranslations = data.translations;

if (storedVersion !== currentVersion) {
localStorage.setItem('allTranslations', JSON.stringify(allTranslations));
localStorage.setItem('translations_version', currentVersion);
}

translatePage(allTranslations, savedLanguage);
const translations = JSON.parse(localStorage.getItem('allTranslations')) || allTranslations;
document.getElementById('language-select').value = savedLanguage;
await setLanguage(savedLanguage, translations);
});
13 changes: 8 additions & 5 deletions static/scripts.js → static/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ function checkMessage() {
}

function openSettings() {
document.getElementById('settings-modal').style.display = "block";
const modal = document.getElementById('settings-modal');
modal.classList.add('show');
modal.style.removeProperty('display');
// Get current configuration and fill in the text boxes
const baseURL = getCookie('base_url');
const apiKey = getCookie('api_key');
Expand All @@ -132,7 +134,8 @@ function openSettings() {
}

function closeSettings() {
document.getElementById('settings-modal').style.display = "none";
const modal = document.getElementById('settings-modal');
modal.classList.remove('show');
}

function generateUUID() {
Expand Down Expand Up @@ -203,7 +206,7 @@ document.addEventListener('DOMContentLoaded', () => {
window.onclick = function (event) {
const modal = document.getElementById('settings-modal');
if (event.target == modal) {
modal.style.display = "none";
closeSettings();
}
}

Expand Down Expand Up @@ -293,13 +296,13 @@ document.getElementById('sync-button').addEventListener('click', () => {
});

document.addEventListener('DOMContentLoaded', () => {
// 禁用发送和设置按钮
// Disable send and settings buttons initially
const sendButton = document.getElementById('send-button');
const settingsButton = document.getElementById('settings-button');
sendButton.disabled = true;
settingsButton.disabled = true;

// 2秒后启用按钮
// Enable buttons after 2 seconds
setTimeout(() => {
settingsButton.disabled = false;
}, 2000);
Expand Down
1 change: 1 addition & 0 deletions static/message.js → static/scripts/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ function sendMessage(message = null, showUserBubble = true, hidden = false) {
if (userMessage) {
document.getElementById('chat-messages').removeChild(userMessage);
document.getElementById('message').value = message;
document.getElementById('send-button').disabled = false;

fetch(`/delete_message?user_id=${uuid}`, {
method: 'POST',
Expand Down
File renamed without changes.
Loading

0 comments on commit 690e7b9

Please sign in to comment.