Skip to content

Commit 7a8c9aa

Browse files
committed
v1.5.0
1 parent 2a8100d commit 7a8c9aa

26 files changed

+250
-26
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,18 @@ settings/*
166166
!settings/settings.json
167167
!settings/settings_gemini.json
168168
!settings/settings_claude.json
169+
chat_icons/*
170+
!chat_icons/user_black.png
171+
!chat_icons/user_blue.png
172+
!chat_icons/user_green.png
173+
!chat_icons/user_purple.png
174+
!chat_icons/user_red.png
175+
!chat_icons/user_yellow.png
176+
!chat_icons/zunda_grape.png
177+
!chat_icons/zunda_light.png
178+
!chat_icons/zunda_lime.png
179+
!chat_icons/zunda_mono.png
180+
!chat_icons/zunda_orange.png
181+
!chat_icons/zunda_peach.png
182+
!chat_icons/zunda_sky.png
169183
起動.bat

Readme.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ ZundaGPT2(https://github.com/led-mirage/ZundaGPT2) のライト版なのだ。Zu
1717

1818
## 最新情報
1919

20-
### バージョン 1.4.2 - 1.4.3
20+
### バージョン 1.5.0
2121

22-
バグフィックス、機能改善
22+
チャット用のアイコンが表示できるようになったのだ✨
2323

2424
### バージョン 1.4.0
2525

@@ -29,7 +29,7 @@ Anthropic社のClaudeシリーズに対応したのだ✨
2929

3030
<img src="assets/ZundaGPT2_splash.png" width="200">
3131

32-
<img src="doc/screenshot_1.3.0.png" width="600">
32+
<img src="doc/screenshot_1.5.0.png" width="600">
3333

3434
## 動作確認環境
3535

@@ -186,10 +186,10 @@ OpenAIやGoogle Gemini、AnthropicのAPIキーはあなただけのものなの
186186

187187
これが嫌な人は(ボクも嫌だけど)、Python本体をインストールしてPythonから普通に実行して欲しいのだ。実行ファイルのほうが手軽だし、そのほうがPythonに詳しくない人にとっては簡単なんだけど、誤認問題がついて回ることは覚えておいて欲しいのだ。
188188

189-
VirusTotalでの[チェック結果](https://www.virustotal.com/gui/file/d5d9ff6593878f0b65fdd30708547a50fd272b01053b53fb2271663ff5175fbc)は以下の通りなのだ。
190-
(72個中3個のアンチウィルスエンジンで検出 :2025/01/02 v1.4.3)。
189+
VirusTotalでの[チェック結果](https://www.virustotal.com/gui/file/49c81f7d0475d9c0caec0d3fdfa4ecedc674d160764e0ad4a489440f37ff401d)は以下の通りなのだ。
190+
(72個中3個のアンチウィルスエンジンで検出 :2025/01/04 v1.5.0)。
191191

192-
<img src="doc/virustotal_1.4.2.png" width="600">
192+
<img src="doc/virustotal_1.5.0.png" width="600">
193193

194194
### ⚡ 免責事項
195195

@@ -244,7 +244,7 @@ VirusTotalでの[チェック結果](https://www.virustotal.com/gui/file/d5d9ff6
244244

245245
## ライセンス
246246

247-
© 2024 led-mirage
247+
© 2024-2025 led-mirage
248248

249249
本アプリケーションは [MITライセンス](https://opensource.org/licenses/MIT) の下で公開されているのだ。詳細については、プロジェクトに含まれる LICENSE ファイルを参照して欲しいのだ。
250250

@@ -347,3 +347,7 @@ VirusTotalでの[チェック結果](https://www.virustotal.com/gui/file/d5d9ff6
347347
### 1.4.3 (2025/01/02)
348348

349349
- Anthropic APIでエラーが発生したときのメッセージを分かりやすくした
350+
351+
### 1.5.0 (2025/01/04)
352+
353+
- チャットアイコンを表示する機能を追加

Readme_detail.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ZundaGPT2 Lite 追加資料
22

3-
Copyright (c) 2024 led-mirage
3+
Copyright (c) 2024-2025 led-mirage
44

55
## はじめに
66

@@ -87,6 +87,14 @@ settings.jsonはsettingsフォルダの中に格納されているのだ。声
8787

8888
あなたの名前の色の設定なのだ。
8989

90+
#### ✨ user/icon(既定値 空文字)
91+
92+
発言者名の横に表示するアイコンの設定なのだ。PNG形式の画像ファイルを指定できるのだ。空文字にするとアイコンは表示されないのだ。
93+
94+
例:chat_icons/user_black.png
95+
96+
chat_iconsフォルダの中にいくつかアイコン用の画像を用意してあるのだ。
97+
9098
#### ✨ assistant/name(既定値 ずんだ)
9199

92100
チャットアシスタントの名前の設定なのだ。
@@ -95,6 +103,14 @@ settings.jsonはsettingsフォルダの中に格納されているのだ。声
95103

96104
チャットアシスタントの名前の色の設定なのだ。
97105

106+
#### ✨ assistant/icon(既定値 空文字)
107+
108+
発言者名の横に表示するアイコンの設定なのだ。PNG形式の画像ファイルを指定できるのだ。空文字にするとアイコンは表示されないのだ。
109+
110+
例:chat_icons/zunda_lime.png
111+
112+
chat_iconsフォルダの中にいくつかアイコン用の画像を用意してあるのだ。
113+
98114
#### ✨ chat/api(既定値 OpenAI)
99115

100116
使用するAPIの設定なのだ。設定できる値は`OpenAI``AzureOpenAI``Gemini``Claude`の4つなのだ。

app/app_settings.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# メイン
44
#
5-
# Copyright (c) 2024 led-mirage
5+
# Copyright (c) 2024-2025 led-mirage
66
# このソースコードは MITライセンス の下でライセンスされています。
77
# ライセンスの詳細については、このプロジェクトのLICENSEファイルを参照してください。
88

@@ -15,7 +15,7 @@
1515
from app_config import AppConfig
1616

1717
class Settings:
18-
FILE_VER = 4
18+
FILE_VER = 5
1919
FOLDER_NAME = "settings"
2020

2121
def __init__(self, settings_filename=None):
@@ -40,10 +40,12 @@ def _init_member(self):
4040
self.user = {
4141
"name": "あなた",
4242
"name_color": "#007bff",
43+
"icon": "",
4344
}
4445
self.assistant = {
4546
"name": "ずんだ",
4647
"name_color": "#006400",
48+
"icon": "",
4749
}
4850
self.chat = {
4951
"api": "OpenAI",

app/chat_log.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# メイン
44
#
5-
# Copyright (c) 2024 led-mirage
5+
# Copyright (c) 2024-2025 led-mirage
66
# このソースコードは MITライセンス の下でライセンスされています。
77
# ライセンスの詳細については、このプロジェクトのLICENSEファイルを参照してください。
88

@@ -17,7 +17,7 @@
1717

1818
# チャットログクラス
1919
class ChatLog:
20-
FILE_VER = 3
20+
FILE_VER = 4
2121
LOG_FOLDER = "log"
2222

2323
# ログをファイルに保存する
@@ -64,11 +64,15 @@ def load(logfile: str):
6464
if data["file_ver"] == 1:
6565
return (None, None)
6666

67-
if data["file_ver"] == 2:
67+
if data["file_ver"] <= 2:
6868
data["settings"] = {
6969
"display_name": "ZundaGPT",
7070
"description": ""
7171
}
72+
73+
if data["file_ver"] <= 3:
74+
data["user"]["icon"] = ""
75+
data["assistant"]["icon"] = ""
7276

7377
app_config = AppConfig()
7478
app_config.load()

app/html/css/style.css

+9
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ mark {
217217
opacity: 1; /* ホバー時に不透明にする */
218218
transition-delay: 2.0s;
219219
}
220+
.welcome-chat-icon {
221+
width: 5.0rem;
222+
height: 5.0rem;
223+
}
224+
.chat-icon {
225+
margin-right: 0.5rem;
226+
width: 2.5rem;
227+
height: 2.5rem;
228+
}
220229
@media print {
221230
@page {
222231
margin-top: 1.5cm;

app/html/index.html

+32-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@
6161
<script>
6262
let g_userName = "あなた";
6363
let g_userColor = "#007bff";
64+
let g_userIcon = "";
6465
let g_assistantName = "ずんだ";
6566
let g_assistantColor = "#006400";
67+
let g_assistantIcon = "";
6668
let g_nextMessageIndex = 0;
6769
let g_searchTextIndex = 0;
6870
let g_searchTextTotal = 0;
@@ -275,6 +277,14 @@
275277
welcomeConainer.classList.add("welcome");
276278
chatMessagesContainer.appendChild(welcomeConainer);
277279

280+
// アシスタントアイコンを作成
281+
if (g_assistantIcon != "") {
282+
const imgElement = document.createElement("img");
283+
imgElement.classList.add("welcome-chat-icon");
284+
imgElement.src = `data:image/png;base64,${g_assistantIcon}`;
285+
welcomeConainer.appendChild(imgElement);
286+
}
287+
278288
// Welcomeタイトルを作成
279289
const welcomeTitle = document.createElement("div");
280290
welcomeTitle.id = "welcome-title";
@@ -309,6 +319,25 @@
309319
speakerElement.style.color = color;
310320
speakerElement.textContent = speakerName;
311321

322+
if (role === "user") {
323+
if (g_userIcon != "") {
324+
// ユーザーアイコンをつける
325+
const imgElement = document.createElement("img");
326+
imgElement.classList.add("chat-icon");
327+
imgElement.src = `data:image/png;base64,${g_userIcon}`;
328+
speakerElement.prepend(imgElement);
329+
}
330+
}
331+
else if (role === "assistant") {
332+
if (g_assistantIcon != "") {
333+
// アシスタントアイコンをつける
334+
const imgElement = document.createElement("img");
335+
imgElement.classList.add("chat-icon");
336+
imgElement.src = `data:image/png;base64,${g_assistantIcon}`;
337+
speakerElement.prepend(imgElement);
338+
}
339+
}
340+
312341
if (role === "user") {
313342
// 削除ボタンをつける
314343
const deleteElement = document.createElement("button");
@@ -550,11 +579,13 @@
550579

551580
// Pythonから呼び出される関数
552581
// 情報をセットする
553-
function setChatInfo(displayName, userName, userColor, assistantName, assistantColor, welcomeTitle, welcomeMessage) {
582+
function setChatInfo(displayName, userName, userColor, userIcon, assistantName, assistantColor, assistantIcon, welcomeTitle, welcomeMessage) {
554583
g_userName = userName;
555584
g_userColor = userColor;
585+
g_userIcon = userIcon;
556586
g_assistantName = assistantName;
557587
g_assistantColor = assistantColor;
588+
g_assistantIcon = assistantIcon;
558589
g_nextMessageIndex = 0;
559590
g_welcomeTitle = welcomeTitle;
560591
g_welcomeMessage = welcomeMessage;

app/main.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import sys
1010
import webview
11+
import base64
1112

1213
from app_config import AppConfig
1314
from app_settings import Settings
@@ -19,7 +20,7 @@
1920
import pyi_splash # type: ignore
2021

2122
APP_NAME = "ZundaGPT2 Lite"
22-
APP_VERSION = "1.4.3"
23+
APP_VERSION = "1.5.0"
2324
COPYRIGHT = "Copyright 2024-2025 led-mirage"
2425

2526
# アプリケーションクラス
@@ -80,17 +81,30 @@ def set_window_title(self):
8081
window_title = f"{APP_NAME} ver {APP_VERSION} - {logfile}"
8182
self._window.set_title(window_title)
8283

84+
# 画像をBase64エンコードする
85+
def get_image_base64(self, path: str):
86+
if not path:
87+
return ""
88+
try:
89+
with open(path, 'rb') as f:
90+
data = base64.b64encode(f.read())
91+
return data.decode('utf-8')
92+
except:
93+
return ""
94+
8395
# チャットの情報をUIに通知する
8496
def set_chatinfo_to_ui(self):
8597
display_name = self.settings.settings.get("display_name", "")
8698
user_name = self.settings.user["name"]
8799
user_color = self.settings.user["name_color"]
100+
user_icon = self.get_image_base64(self.settings.user["icon"])
88101
assistant_name = self.settings.assistant["name"]
89102
assistant_color = self.settings.assistant["name_color"]
103+
assistant_icon = self.get_image_base64(self.settings.assistant["icon"])
90104
welcome_title = self.settings.settings.get("welcome_title", "")
91105
welcome_message = self.settings.settings.get("welcome_message", "")
92106
self._window.evaluate_js(
93-
f"setChatInfo('{display_name}', '{user_name}', '{user_color}', '{assistant_name}', '{assistant_color}', '{welcome_title}', '{welcome_message}')")
107+
f"setChatInfo('{display_name}', '{user_name}', '{user_color}', '{user_icon}', '{assistant_name}', '{assistant_color}', '{assistant_icon}', '{welcome_title}', '{welcome_message}')")
94108

95109
# ひとつ前のチャットを表示して続ける
96110
def prev_chat(self):

0 commit comments

Comments
 (0)