Skip to content

Commit

Permalink
Merge pull request #73 from Integration-Automation/dev
Browse files Browse the repository at this point in the history
Update dev and stable version
  • Loading branch information
JE-Chen authored Aug 23, 2023
2 parents 49aa2c7 + 3c7f75d commit f1d45da
Show file tree
Hide file tree
Showing 19 changed files with 135 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from frontengine.ui.setting.scene_setting.scene_setting_ui import SceneSettingUI
from frontengine.ui.main.main_ui import FrontEngineMainUI
from frontengine.ui.setting.scene_setting.scene_setting_ui import SceneControlSettingUI
from frontengine.ui.setting.chat_scene.chat_scene_setting import ChatSceneUI
from frontengine.ui.setting.chat.chat_scene_setting import ChatSceneUI
from frontengine.ui.main.main_ui import FrontEngine_EXTEND_TAB

__all__ = [
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions frontengine/show/image_generation/image_generation_show.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QWidget, QLabel, QGridLayout


class ImageGenerateShow(QWidget):

def __init__(self, pixmap: QPixmap):
super().__init__()
self.label = QLabel()
self.label.setPixmap(pixmap)
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.grid_layout.addWidget(self.label)
self.setLayout(self.grid_layout)
8 changes: 7 additions & 1 deletion frontengine/ui/main/main_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from frontengine.ui.main.language_menu import build_language_menu
from frontengine.ui.main.system_tray.extend_system_tray import ExtendSystemTray
from frontengine.ui.setting.chat_scene.chat_scene_setting import ChatSceneUI
from frontengine.ui.setting.chat.chat_scene_setting import ChatSceneUI
from frontengine.ui.setting.control_center.control_center_ui import ControlCenterUI
from frontengine.ui.setting.gif.gif_setting_ui import GIFSettingUI
from frontengine.ui.setting.image.image_setting_ui import ImageSettingUI
Expand All @@ -19,6 +19,7 @@
from frontengine.ui.setting.text.text_setting_ui import TextSettingUI
from frontengine.ui.setting.video.video_setting_ui import VideoSettingUI
from frontengine.ui.setting.web.web_setting_ui import WEBSettingUI
from frontengine.ui.setting.image_generation.image_generation_input import ImageGenerationUI
from frontengine.user_setting.user_setting_file import write_user_setting, read_user_setting, user_setting_dict
from frontengine.utils.multi_language.language_wrapper import language_wrapper

Expand Down Expand Up @@ -51,6 +52,7 @@ def __init__(self, debug: bool = False):
self.text_setting_ui = TextSettingUI()
self.scene_setting_ui = SceneSettingUI()
self.chat_scene_ui = ChatSceneUI()
self.image_generation_ui = ImageGenerationUI()
self.control_center_ui = ControlCenterUI(
self.video_setting_ui,
self.image_setting_ui,
Expand Down Expand Up @@ -96,6 +98,10 @@ def __init__(self, debug: bool = False):
self.control_center_ui,
language_wrapper.language_word_dict.get("tab_control_center_text")
)
self.tab_widget.addTab(
self.image_generation_ui,
language_wrapper.language_word_dict.get("image_generation_tab")
)
for widget_name, widget in FrontEngine_EXTEND_TAB.items():
self.tab_widget.addTab(widget(), widget_name)
self.setCentralWidget(self.tab_widget)
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PySide6.QtWidgets import QBoxLayout, QWidget, QPushButton, QHBoxLayout, QTextEdit, QMessageBox

from frontengine.show.chat.chat_toast import ChatToast
from frontengine.ui.chat.chatthread import MESSAGE_QUEUE, EXCEPTION_QUEUE
from frontengine.ui.setting.chat.chatthread import MESSAGE_QUEUE, EXCEPTION_QUEUE
from frontengine.utils.multi_language.language_wrapper import language_wrapper


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
QPlainTextEdit, QLineEdit, QBoxLayout

from frontengine.show.scene.scene import SceneManager
from frontengine.ui.chat.chat_model import load_scene_json, chat_model
from frontengine.ui.chat.chat_scene_input import ChatInputDialog
from frontengine.ui.chat.chatthread import ChatThread, DELEGATE_CHAT, PANEL_MESSAGE_QUEUE
from frontengine.ui.chat.speech_to_text import ChatSpeechToText
from frontengine.ui.setting.chat.chat_model import load_scene_json, chat_model
from frontengine.ui.setting.chat.chat_scene_input import ChatInputDialog
from frontengine.ui.setting.chat.chatthread import ChatThread, DELEGATE_CHAT, PANEL_MESSAGE_QUEUE
from frontengine.ui.setting.chat.speech_to_text import ChatSpeechToText
from frontengine.utils.logging.loggin_instance import front_engine_logger
from frontengine.utils.multi_language.language_wrapper import language_wrapper

Expand All @@ -19,7 +19,6 @@ class ChatSceneUI(QWidget):
def __init__(self):
super().__init__()
self.voice_input = None
self.grid_layout = QGridLayout()
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
# Init
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion frontengine/ui/setting/control_center/control_center_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PySide6.QtWidgets import QGridLayout, QWidget, QPushButton, QTextEdit, QScrollArea

from frontengine.ui.color.global_color import error_color, output_color
from frontengine.ui.setting.chat_scene.chat_scene_setting import ChatSceneUI
from frontengine.ui.setting.chat.chat_scene_setting import ChatSceneUI
from frontengine.ui.setting.gif.gif_setting_ui import GIFSettingUI
from frontengine.ui.setting.image.image_setting_ui import ImageSettingUI
from frontengine.ui.setting.scene_setting.scene_setting_ui import SceneSettingUI
Expand Down
Empty file.
32 changes: 32 additions & 0 deletions frontengine/ui/setting/image_generation/generation_image_thread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import asyncio
from queue import Queue
from threading import Thread
from re_edge_gpt import ImageGenAsync


class ImageGenThread(Thread):

def __init__(self, image_keyword: str):
super().__init__()
auth_cooker = open("bing_cookies.txt", "r+").read()
self.async_gen = ImageGenAsync(auth_cookie=auth_cooker)
self.image_keyword = image_keyword

def run(self) -> None:
try:
image_list = list()

async def send_chat_async():
nonlocal image_list
image_list = await self.async_gen.get_images(self.image_keyword)

asyncio.run(send_chat_async())
for image in image_list:
IMAGE_QUEUE.put_nowait(image)
except Exception as error:
EXCEPTION_QUEUE.put_nowait(repr(error))
raise error


IMAGE_QUEUE = Queue()
EXCEPTION_QUEUE = Queue()
62 changes: 62 additions & 0 deletions frontengine/ui/setting/image_generation/image_generation_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from typing import List

import requests
from PySide6.QtCore import QTimer
from PySide6.QtGui import QPixmap
from PySide6.QtWidgets import QWidget, QPushButton, QLineEdit, QGridLayout, QMessageBox, QPlainTextEdit

from frontengine.show.image_generation.image_generation_show import ImageGenerateShow
from frontengine.ui.setting.image_generation.generation_image_thread import ImageGenThread, IMAGE_QUEUE
from frontengine.utils.multi_language.language_wrapper import language_wrapper


class ImageGenerationUI(QWidget):
def __init__(self):
super().__init__()
# UI
self.image_keyword_input = QLineEdit()
self.send_text_button = QPushButton()
self.send_text_button.setText(language_wrapper.language_word_dict.get("start_generate_image"))
self.image_panel = QPlainTextEdit()
self.image_panel.setReadOnly(True)
self.send_text_button.clicked.connect(self.generate_image)
# Layout
self.grid_layout = QGridLayout(self)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.grid_layout.addWidget(self.image_keyword_input, 0, 0)
self.grid_layout.addWidget(self.send_text_button, 0, 1)
self.grid_layout.addWidget(self.image_panel, 1, 0, -1, -1)
# Pull image timer
self.pull_image_timer = QTimer()
self.pull_image_timer.setInterval(1000)
self.pull_image_timer.timeout.connect(self.get_image)
self.pull_image_timer.start()
# Manage show
self.show_list: List[QWidget] = list()

def generate_image(self):
if self.image_keyword_input.text() == "" or self.image_keyword_input.text().isspace():
input_error_message = QMessageBox(self)
input_error_message.setText(language_wrapper.language_word_dict.get("input_error"))
input_error_message.show()
else:
image_thread = ImageGenThread(self.image_keyword_input.text())
image_thread.daemon = True
image_thread.start()

def get_image(self):
if not IMAGE_QUEUE.empty():
image_link = IMAGE_QUEUE.get_nowait()
image_response = requests.get(image_link)
image = QPixmap()
image.loadFromData(image_response.content)
image_show = ImageGenerateShow(image)
self.show_list.append(image_show)
image_show.show()
self.image_panel.appendPlainText(image_link)

def close(self) -> bool:
for widget in self.show_list:
widget.close()
return super().close()

Empty file.
6 changes: 5 additions & 1 deletion frontengine/utils/multi_language/english.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@
"chat_gpt_exception": "GPT error, pls retry or new topic",
# Chat voice input
"start_chat_voice_input_ui": "Open voice input ui",
"chat_recognizer_voice_button": "Start listen voice"
"chat_recognizer_voice_button": "Start listen voice",
# Image Generation
"image_generation_tab": "Image generation",
"start_generate_image": "Star generate",
"input_error": "Please input something"
}
6 changes: 5 additions & 1 deletion frontengine/utils/multi_language/traditional_chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@
"chat_gpt_exception": "GPT 錯誤,請重試或開始一個新話題",
# Chat voice input
"start_chat_voice_input_ui": "開啟聲音輸入介面",
"chat_recognizer_voice_button": "開始錄製聲音"
"chat_recognizer_voice_button": "開始錄製聲音",
# Image Generation
"image_generation_tab": "圖片產生",
"start_generate_image": "開始產生圖片",
"input_error": "請勿無輸入或空格"
}
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "frontengine"
version = "0.0.41"
name = "frontengine_dev"
version = "0.0.43"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
]
Expand Down
2 changes: 1 addition & 1 deletion dev.toml → stable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "frontengine_dev"
name = "frontengine"
version = "0.0.42"
authors = [
{ name = "JE-Chen", email = "jechenmailman@gmail.com" },
Expand Down

0 comments on commit f1d45da

Please sign in to comment.