Spaces:
Runtime error
Runtime error
Update app-backup.py
Browse files- app-backup.py +452 -125
app-backup.py
CHANGED
|
@@ -16,7 +16,7 @@ import modelscope_studio.components.legacy as legacy
|
|
| 16 |
import modelscope_studio.components.antd as antd
|
| 17 |
import html
|
| 18 |
import urllib.parse
|
| 19 |
-
from huggingface_hub import HfApi, create_repo
|
| 20 |
import string
|
| 21 |
import requests
|
| 22 |
from selenium import webdriver
|
|
@@ -27,7 +27,64 @@ from selenium.common.exceptions import WebDriverException, TimeoutException
|
|
| 27 |
from PIL import Image
|
| 28 |
from io import BytesIO
|
| 29 |
from datetime import datetime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
# SystemPrompt 부분을 직접 정의
|
| 32 |
SystemPrompt = """You are 'MOUSE-I', an advanced AI visualization expert. Your mission is to transform every response into a visually stunning and highly informative presentation.
|
| 33 |
|
|
@@ -211,7 +268,7 @@ async def try_claude_api(system_message, claude_messages, timeout=15):
|
|
| 211 |
start_time = time.time()
|
| 212 |
with claude_client.messages.stream(
|
| 213 |
model="claude-3-5-sonnet-20241022",
|
| 214 |
-
max_tokens=
|
| 215 |
system=system_message,
|
| 216 |
messages=claude_messages
|
| 217 |
) as stream:
|
|
@@ -256,35 +313,36 @@ class Demo:
|
|
| 256 |
def __init__(self):
|
| 257 |
pass
|
| 258 |
|
| 259 |
-
async def generation_code(self, query: Optional[str], _setting: Dict[str, str]
|
| 260 |
if not query or query.strip() == '':
|
| 261 |
query = get_random_placeholder()
|
| 262 |
|
| 263 |
-
|
| 264 |
-
|
|
|
|
| 265 |
|
| 266 |
-
|
| 267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
for msg in messages[1:] + [{'role': Role.USER, 'content': query}]
|
| 272 |
-
if msg["content"].strip() != ''
|
| 273 |
-
]
|
| 274 |
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
openai_messages.append({"role": "user", "content": query})
|
| 282 |
|
| 283 |
try:
|
| 284 |
-
# 로딩 시작
|
| 285 |
yield [
|
| 286 |
-
"",
|
| 287 |
-
_history,
|
| 288 |
None,
|
| 289 |
gr.update(active_key="loading"),
|
| 290 |
gr.update(open=True)
|
|
@@ -295,8 +353,7 @@ class Demo:
|
|
| 295 |
try:
|
| 296 |
async for content in try_claude_api(system_message, claude_messages):
|
| 297 |
yield [
|
| 298 |
-
"",
|
| 299 |
-
_history,
|
| 300 |
None,
|
| 301 |
gr.update(active_key="loading"),
|
| 302 |
gr.update(open=True)
|
|
@@ -309,8 +366,7 @@ class Demo:
|
|
| 309 |
|
| 310 |
async for content in try_openai_api(openai_messages):
|
| 311 |
yield [
|
| 312 |
-
"",
|
| 313 |
-
_history,
|
| 314 |
None,
|
| 315 |
gr.update(active_key="loading"),
|
| 316 |
gr.update(open=True)
|
|
@@ -319,22 +375,72 @@ class Demo:
|
|
| 319 |
collected_content = content
|
| 320 |
|
| 321 |
if collected_content:
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
yield [
|
| 331 |
collected_content,
|
| 332 |
-
_history,
|
| 333 |
send_to_sandbox(remove_code_block(collected_content)),
|
| 334 |
gr.update(active_key="render"),
|
| 335 |
gr.update(open=False)
|
| 336 |
]
|
| 337 |
-
|
| 338 |
else:
|
| 339 |
raise ValueError("No content was generated from either API")
|
| 340 |
|
|
@@ -457,7 +563,7 @@ def get_random_placeholder():
|
|
| 457 |
|
| 458 |
def update_placeholder():
|
| 459 |
return gr.update(placeholder=get_random_placeholder())
|
| 460 |
-
|
| 461 |
def create_main_interface():
|
| 462 |
"""메인 인터페이스 생성 함수"""
|
| 463 |
|
|
@@ -480,29 +586,150 @@ def create_main_interface():
|
|
| 480 |
with open('app.css', 'r', encoding='utf-8') as f:
|
| 481 |
custom_css = f.read()
|
| 482 |
|
| 483 |
-
demo = gr.Blocks(css=custom_css
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
with demo:
|
| 486 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
| 487 |
with gr.Tab("Visual AI Assistant", elem_id="mouse-tab", elem_classes="mouse-tab"):
|
| 488 |
-
|
| 489 |
setting = gr.State({
|
| 490 |
"system": SystemPrompt,
|
| 491 |
})
|
| 492 |
-
|
| 493 |
with ms.Application() as app:
|
| 494 |
with antd.ConfigProvider():
|
| 495 |
-
|
| 496 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 497 |
gr.HTML("""
|
| 498 |
<div class="thinking-container">
|
| 499 |
<style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 500 |
.thinking-container {
|
| 501 |
text-align: center;
|
| 502 |
padding: 20px;
|
| 503 |
background: #f8f9fa;
|
| 504 |
border-radius: 15px;
|
| 505 |
-
font-family:
|
| 506 |
}
|
| 507 |
|
| 508 |
.progress-bar {
|
|
@@ -517,7 +744,7 @@ def create_main_interface():
|
|
| 517 |
.progress-bar-inner {
|
| 518 |
width: 30%;
|
| 519 |
height: 100%;
|
| 520 |
-
background: linear-gradient(90deg, #
|
| 521 |
animation: progress 2s ease-in-out infinite;
|
| 522 |
}
|
| 523 |
|
|
@@ -536,13 +763,8 @@ def create_main_interface():
|
|
| 536 |
transition: all 0.3s ease;
|
| 537 |
}
|
| 538 |
|
| 539 |
-
.tip-box:hover {
|
| 540 |
-
transform: translateY(-5px);
|
| 541 |
-
box-shadow: 0 6px 16px rgba(0,0,0,0.15);
|
| 542 |
-
}
|
| 543 |
-
|
| 544 |
.status-text {
|
| 545 |
-
color: #
|
| 546 |
font-size: 18px;
|
| 547 |
margin: 15px 0;
|
| 548 |
animation: fade 1.5s ease infinite;
|
|
@@ -557,7 +779,7 @@ def create_main_interface():
|
|
| 557 |
|
| 558 |
.icon-item {
|
| 559 |
padding: 10px;
|
| 560 |
-
background: rgba(
|
| 561 |
border-radius: 8px;
|
| 562 |
animation: pulse 2s ease infinite;
|
| 563 |
}
|
|
@@ -585,22 +807,18 @@ def create_main_interface():
|
|
| 585 |
</style>
|
| 586 |
|
| 587 |
<div class="thinking-icon">🎨</div>
|
| 588 |
-
|
| 589 |
<div class="status-text">Creating Your Visualization...</div>
|
| 590 |
-
|
| 591 |
<div class="progress-bar">
|
| 592 |
<div class="progress-bar-inner"></div>
|
| 593 |
</div>
|
| 594 |
-
|
| 595 |
<div class="icon-grid">
|
| 596 |
<div class="icon-item">📊</div>
|
| 597 |
<div class="icon-item">🎯</div>
|
| 598 |
<div class="icon-item">💡</div>
|
| 599 |
<div class="icon-item">✨</div>
|
| 600 |
</div>
|
| 601 |
-
|
| 602 |
<div class="tip-box">
|
| 603 |
-
<h3 style="color: #
|
| 604 |
<div id="tip-content" style="font-size: 16px; line-height: 1.6;"></div>
|
| 605 |
</div>
|
| 606 |
|
|
@@ -637,106 +855,120 @@ def create_main_interface():
|
|
| 637 |
code_output = legacy.Markdown(visible=False)
|
| 638 |
|
| 639 |
|
| 640 |
-
|
| 641 |
-
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
| 642 |
-
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
with antd.Drawer(open=False, title="history", placement="left", width="900px") as history_drawer:
|
| 646 |
-
history_output = legacy.Chatbot(show_label=False, flushing=False, height=960, elem_classes="history_chatbot")
|
| 647 |
-
|
| 648 |
-
# 메인 컨텐츠를 위한 Row
|
| 649 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 650 |
# 좌측 패널
|
| 651 |
with antd.Col(span=24, md=8):
|
| 652 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 653 |
-
# 헤더
|
| 654 |
-
header = gr.HTML(
|
| 655 |
-
<div class="
|
| 656 |
-
<
|
| 657 |
-
|
| 658 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
</div>
|
| 660 |
-
""")
|
| 661 |
-
|
| 662 |
-
|
| 663 |
|
| 664 |
# 입력 영역
|
| 665 |
input = antd.InputTextarea(
|
| 666 |
size="large",
|
| 667 |
-
allow_clear=True,
|
|
|
|
|
|
|
| 668 |
|
| 669 |
-
placeholder=get_random_placeholder()
|
| 670 |
)
|
| 671 |
|
| 672 |
# 버튼 그룹
|
| 673 |
-
with antd.Flex(gap="small", justify="
|
| 674 |
-
btn = antd.Button(
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 683 |
|
| 684 |
# 우측 패널
|
| 685 |
with antd.Col(span=24, md=16):
|
| 686 |
with ms.Div(elem_classes="right_panel"):
|
| 687 |
-
#
|
| 688 |
-
|
| 689 |
-
|
| 690 |
-
|
| 691 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
|
| 693 |
# 탭 컨텐츠
|
| 694 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 695 |
with antd.Tabs.Item(key="empty"):
|
|
|
|
|
|
|
| 696 |
|
| 697 |
-
|
| 698 |
-
|
|
|
|
|
|
|
| 699 |
with antd.Tabs.Item(key="loading"):
|
| 700 |
-
loading = antd.Spin(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 701 |
with antd.Tabs.Item(key="render"):
|
| 702 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
# 이벤트 핸들러 연결
|
| 708 |
-
historyBtn.click(
|
| 709 |
-
history_render,
|
| 710 |
-
inputs=[history],
|
| 711 |
-
outputs=[history_drawer, history_output]
|
| 712 |
-
)
|
| 713 |
-
|
| 714 |
-
history_drawer.close(
|
| 715 |
-
lambda: gr.update(open=False),
|
| 716 |
-
inputs=[],
|
| 717 |
-
outputs=[history_drawer]
|
| 718 |
-
)
|
| 719 |
|
| 720 |
btn.click(
|
| 721 |
demo_instance.generation_code,
|
| 722 |
-
inputs=[input, setting,
|
| 723 |
-
outputs=[code_output,
|
| 724 |
-
).then(
|
| 725 |
fn=update_placeholder,
|
| 726 |
inputs=[],
|
| 727 |
outputs=[input]
|
| 728 |
)
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
clear_btn.click(
|
| 733 |
-
fn=lambda: (
|
| 734 |
-
demo_instance.clear_history(), # history 초기화
|
| 735 |
-
update_placeholder() # placeholder 업데이트
|
| 736 |
-
),
|
| 737 |
-
inputs=[],
|
| 738 |
-
outputs=[history, input] # input도 출력에 추가
|
| 739 |
-
)
|
| 740 |
|
| 741 |
|
| 742 |
boost_btn.click(
|
|
@@ -746,11 +978,97 @@ def create_main_interface():
|
|
| 746 |
)
|
| 747 |
|
| 748 |
deploy_btn.click(
|
| 749 |
-
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "
|
| 750 |
inputs=[code_output],
|
| 751 |
outputs=[deploy_result]
|
| 752 |
)
|
| 753 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 754 |
return demo
|
| 755 |
|
| 756 |
# 메인 실행 부분
|
|
@@ -758,7 +1076,16 @@ if __name__ == "__main__":
|
|
| 758 |
try:
|
| 759 |
demo_instance = Demo() # Demo 인스턴스 생성
|
| 760 |
demo = create_main_interface() # 인터페이스 생성
|
| 761 |
-
demo.queue(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 762 |
except Exception as e:
|
| 763 |
print(f"Initialization error: {e}")
|
| 764 |
raise
|
|
|
|
| 16 |
import modelscope_studio.components.antd as antd
|
| 17 |
import html
|
| 18 |
import urllib.parse
|
| 19 |
+
from huggingface_hub import HfApi, create_repo, hf_hub_download
|
| 20 |
import string
|
| 21 |
import requests
|
| 22 |
from selenium import webdriver
|
|
|
|
| 27 |
from PIL import Image
|
| 28 |
from io import BytesIO
|
| 29 |
from datetime import datetime
|
| 30 |
+
import spaces
|
| 31 |
+
from safetensors.torch import load_file
|
| 32 |
+
from diffusers import FluxPipeline
|
| 33 |
+
import torch
|
| 34 |
+
from os import path # 이 줄을 추가
|
| 35 |
|
| 36 |
+
# 캐시 경로 설정
|
| 37 |
+
cache_path = path.join(path.dirname(path.abspath(__file__)), "models")
|
| 38 |
+
os.environ["TRANSFORMERS_CACHE"] = cache_path
|
| 39 |
+
os.environ["HF_HUB_CACHE"] = cache_path
|
| 40 |
+
os.environ["HF_HOME"] = cache_path
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# Hugging Face 토큰 설정
|
| 44 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 45 |
+
if not HF_TOKEN:
|
| 46 |
+
print("Warning: HF_TOKEN not found in environment variables")
|
| 47 |
+
|
| 48 |
+
# FLUX 모델 초기화
|
| 49 |
+
if not path.exists(cache_path):
|
| 50 |
+
os.makedirs(cache_path, exist_ok=True)
|
| 51 |
+
|
| 52 |
+
try:
|
| 53 |
+
pipe = FluxPipeline.from_pretrained(
|
| 54 |
+
"black-forest-labs/FLUX.1-dev",
|
| 55 |
+
torch_dtype=torch.bfloat16,
|
| 56 |
+
use_auth_token=HF_TOKEN # Hugging Face 토큰 추가
|
| 57 |
+
)
|
| 58 |
+
pipe.load_lora_weights(
|
| 59 |
+
hf_hub_download(
|
| 60 |
+
"ByteDance/Hyper-SD",
|
| 61 |
+
"Hyper-FLUX.1-dev-8steps-lora.safetensors",
|
| 62 |
+
token=HF_TOKEN # Hugging Face 토큰 추가
|
| 63 |
+
)
|
| 64 |
+
)
|
| 65 |
+
pipe.fuse_lora(lora_scale=0.125)
|
| 66 |
+
pipe.to(device="cuda", dtype=torch.bfloat16)
|
| 67 |
+
print("Successfully initialized FLUX model with authentication")
|
| 68 |
+
except Exception as e:
|
| 69 |
+
print(f"Error initializing FLUX model: {str(e)}")
|
| 70 |
+
pipe = None
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
# 이미지 생성 함수 추가
|
| 75 |
+
@spaces.GPU
|
| 76 |
+
def generate_image(prompt, height=512, width=512, steps=8, scales=3.5, seed=3413):
|
| 77 |
+
with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16):
|
| 78 |
+
return pipe(
|
| 79 |
+
prompt=[prompt],
|
| 80 |
+
generator=torch.Generator().manual_seed(int(seed)),
|
| 81 |
+
num_inference_steps=int(steps),
|
| 82 |
+
guidance_scale=float(scales),
|
| 83 |
+
height=int(height),
|
| 84 |
+
width=int(width),
|
| 85 |
+
max_sequence_length=256
|
| 86 |
+
).images[0]
|
| 87 |
+
|
| 88 |
# SystemPrompt 부분을 직접 정의
|
| 89 |
SystemPrompt = """You are 'MOUSE-I', an advanced AI visualization expert. Your mission is to transform every response into a visually stunning and highly informative presentation.
|
| 90 |
|
|
|
|
| 268 |
start_time = time.time()
|
| 269 |
with claude_client.messages.stream(
|
| 270 |
model="claude-3-5-sonnet-20241022",
|
| 271 |
+
max_tokens=7860,
|
| 272 |
system=system_message,
|
| 273 |
messages=claude_messages
|
| 274 |
) as stream:
|
|
|
|
| 313 |
def __init__(self):
|
| 314 |
pass
|
| 315 |
|
| 316 |
+
async def generation_code(self, query: Optional[str], _setting: Dict[str, str]):
|
| 317 |
if not query or query.strip() == '':
|
| 318 |
query = get_random_placeholder()
|
| 319 |
|
| 320 |
+
# 이미지 생성이 필요한지 확인
|
| 321 |
+
needs_image = '이미지' in query or '그림' in query or 'image' in query.lower()
|
| 322 |
+
image_prompt = None
|
| 323 |
|
| 324 |
+
# 이미지 프롬프트 추출
|
| 325 |
+
if needs_image:
|
| 326 |
+
for keyword in ['이미지:', '그림:', 'image:']:
|
| 327 |
+
if keyword in query.lower():
|
| 328 |
+
image_prompt = query.split(keyword)[1].strip()
|
| 329 |
+
break
|
| 330 |
+
if not image_prompt:
|
| 331 |
+
image_prompt = query # 명시적 프롬프트가 없으면 전체 쿼리 사용
|
| 332 |
|
| 333 |
+
messages = [{'role': Role.SYSTEM, 'content': _setting['system']}]
|
| 334 |
+
messages.append({'role': Role.USER, 'content': query})
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
+
system_message = messages[0]['content']
|
| 337 |
+
claude_messages = [{"role": "user", "content": query}]
|
| 338 |
+
openai_messages = [
|
| 339 |
+
{"role": "system", "content": system_message},
|
| 340 |
+
{"role": "user", "content": query}
|
| 341 |
+
]
|
|
|
|
| 342 |
|
| 343 |
try:
|
|
|
|
| 344 |
yield [
|
| 345 |
+
"",
|
|
|
|
| 346 |
None,
|
| 347 |
gr.update(active_key="loading"),
|
| 348 |
gr.update(open=True)
|
|
|
|
| 353 |
try:
|
| 354 |
async for content in try_claude_api(system_message, claude_messages):
|
| 355 |
yield [
|
| 356 |
+
"",
|
|
|
|
| 357 |
None,
|
| 358 |
gr.update(active_key="loading"),
|
| 359 |
gr.update(open=True)
|
|
|
|
| 366 |
|
| 367 |
async for content in try_openai_api(openai_messages):
|
| 368 |
yield [
|
| 369 |
+
"",
|
|
|
|
| 370 |
None,
|
| 371 |
gr.update(active_key="loading"),
|
| 372 |
gr.update(open=True)
|
|
|
|
| 375 |
collected_content = content
|
| 376 |
|
| 377 |
if collected_content:
|
| 378 |
+
# 이미지 생성이 필요한 경우
|
| 379 |
+
if needs_image and image_prompt:
|
| 380 |
+
try:
|
| 381 |
+
print(f"Generating image for prompt: {image_prompt}")
|
| 382 |
+
# FLUX 모델을 사용하여 이미지 생성
|
| 383 |
+
if pipe is not None:
|
| 384 |
+
image = generate_image(
|
| 385 |
+
prompt=image_prompt,
|
| 386 |
+
height=512,
|
| 387 |
+
width=512,
|
| 388 |
+
steps=8,
|
| 389 |
+
scales=3.5,
|
| 390 |
+
seed=random.randint(1, 10000)
|
| 391 |
+
)
|
| 392 |
+
|
| 393 |
+
# 이미지를 Base64로 인코딩
|
| 394 |
+
buffered = BytesIO()
|
| 395 |
+
image.save(buffered, format="PNG")
|
| 396 |
+
img_str = base64.b64encode(buffered.getvalue()).decode()
|
| 397 |
+
|
| 398 |
+
# HTML에 이미지 추가
|
| 399 |
+
image_html = f'''
|
| 400 |
+
<div class="generated-image" style="margin: 20px 0; text-align: center;">
|
| 401 |
+
<h3 style="color: #333; margin-bottom: 10px;">Generated Image:</h3>
|
| 402 |
+
<img src="data:image/png;base64,{img_str}"
|
| 403 |
+
style="max-width: 100%;
|
| 404 |
+
border-radius: 10px;
|
| 405 |
+
box-shadow: 0 4px 8px rgba(0,0,0,0.1);">
|
| 406 |
+
<p style="color: #666; margin-top: 10px; font-style: italic;">
|
| 407 |
+
Prompt: {html.escape(image_prompt)}
|
| 408 |
+
</p>
|
| 409 |
+
</div>
|
| 410 |
+
'''
|
| 411 |
+
|
| 412 |
+
# HTML 응답에 이미지 삽입
|
| 413 |
+
if '```html' in collected_content:
|
| 414 |
+
# HTML 코드 블록 내부에 이미지 추가
|
| 415 |
+
collected_content = collected_content.replace('```html\n', f'```html\n{image_html}')
|
| 416 |
+
else:
|
| 417 |
+
# HTML 코드 블록으로 감싸서 이미지 추가
|
| 418 |
+
collected_content = f'```html\n{image_html}\n```\n{collected_content}'
|
| 419 |
+
|
| 420 |
+
print("Image generation successful")
|
| 421 |
+
else:
|
| 422 |
+
raise Exception("FLUX model not initialized")
|
| 423 |
+
|
| 424 |
+
except Exception as e:
|
| 425 |
+
print(f"Image generation error: {str(e)}")
|
| 426 |
+
error_message = f'''
|
| 427 |
+
<div style="color: #ff4d4f; padding: 10px; margin: 10px 0;
|
| 428 |
+
border-left: 4px solid #ff4d4f; background: #fff2f0;">
|
| 429 |
+
<p>Failed to generate image: {str(e)}</p>
|
| 430 |
+
</div>
|
| 431 |
+
'''
|
| 432 |
+
if '```html' in collected_content:
|
| 433 |
+
collected_content = collected_content.replace('```html\n', f'```html\n{error_message}')
|
| 434 |
+
else:
|
| 435 |
+
collected_content = f'```html\n{error_message}\n```\n{collected_content}'
|
| 436 |
+
|
| 437 |
+
# 최종 결과 표시
|
| 438 |
yield [
|
| 439 |
collected_content,
|
|
|
|
| 440 |
send_to_sandbox(remove_code_block(collected_content)),
|
| 441 |
gr.update(active_key="render"),
|
| 442 |
gr.update(open=False)
|
| 443 |
]
|
|
|
|
| 444 |
else:
|
| 445 |
raise ValueError("No content was generated from either API")
|
| 446 |
|
|
|
|
| 563 |
|
| 564 |
def update_placeholder():
|
| 565 |
return gr.update(placeholder=get_random_placeholder())
|
| 566 |
+
|
| 567 |
def create_main_interface():
|
| 568 |
"""메인 인터페이스 생성 함수"""
|
| 569 |
|
|
|
|
| 586 |
with open('app.css', 'r', encoding='utf-8') as f:
|
| 587 |
custom_css = f.read()
|
| 588 |
|
| 589 |
+
demo = gr.Blocks(css=custom_css + """
|
| 590 |
+
|
| 591 |
+
.empty-content {
|
| 592 |
+
padding: 40px !important;
|
| 593 |
+
background: #f8f9fa !important;
|
| 594 |
+
border-radius: 10px !important;
|
| 595 |
+
margin: 20px !important;
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
+
.container {
|
| 599 |
+
background: #f0f0f0;
|
| 600 |
+
min-height: 100vh;
|
| 601 |
+
padding: 20px;
|
| 602 |
+
display: flex;
|
| 603 |
+
justify-content: center;
|
| 604 |
+
align-items: center;
|
| 605 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 606 |
+
}
|
| 607 |
+
|
| 608 |
+
.app-window {
|
| 609 |
+
background: white;
|
| 610 |
+
border-radius: 10px;
|
| 611 |
+
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
|
| 612 |
+
width: 100%;
|
| 613 |
+
max-width: 1400px;
|
| 614 |
+
overflow: hidden;
|
| 615 |
+
}
|
| 616 |
+
|
| 617 |
+
.window-header {
|
| 618 |
+
background: #f0f0f0;
|
| 619 |
+
padding: 12px 16px;
|
| 620 |
+
display: flex;
|
| 621 |
+
align-items: center;
|
| 622 |
+
border-bottom: 1px solid #e0e0e0;
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
.window-controls {
|
| 626 |
+
display: flex;
|
| 627 |
+
gap: 8px;
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
.control {
|
| 631 |
+
width: 12px;
|
| 632 |
+
height: 12px;
|
| 633 |
+
border-radius: 50%;
|
| 634 |
+
cursor: pointer;
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
.control.close { background: #ff5f57; }
|
| 638 |
+
.control.minimize { background: #febc2e; }
|
| 639 |
+
.control.maximize { background: #28c840; }
|
| 640 |
+
|
| 641 |
+
.window-title {
|
| 642 |
+
flex: 1;
|
| 643 |
+
text-align: center;
|
| 644 |
+
color: #333;
|
| 645 |
+
font-size: 14px;
|
| 646 |
+
font-weight: 500;
|
| 647 |
+
}
|
| 648 |
+
|
| 649 |
+
.main-content {
|
| 650 |
+
display: flex;
|
| 651 |
+
height: calc(100vh - 100px);
|
| 652 |
+
}
|
| 653 |
+
|
| 654 |
+
.left-panel {
|
| 655 |
+
width: 40%;
|
| 656 |
+
border-right: 1px solid #e0e0e0;
|
| 657 |
+
padding: 20px;
|
| 658 |
+
display: flex;
|
| 659 |
+
flex-direction: column;
|
| 660 |
+
}
|
| 661 |
+
|
| 662 |
+
.right-panel {
|
| 663 |
+
width: 60%;
|
| 664 |
+
background: #fff;
|
| 665 |
+
position: relative;
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
.input-area {
|
| 669 |
+
background: #f8f9fa;
|
| 670 |
+
border-radius: 10px;
|
| 671 |
+
padding: 20px;
|
| 672 |
+
margin-top: 20px;
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
.button-group {
|
| 676 |
+
display: flex;
|
| 677 |
+
gap: 10px;
|
| 678 |
+
margin-top: 20px;
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
.custom-button {
|
| 682 |
+
background: #007aff;
|
| 683 |
+
color: white;
|
| 684 |
+
border: none;
|
| 685 |
+
padding: 10px 20px;
|
| 686 |
+
border-radius: 6px;
|
| 687 |
+
cursor: pointer;
|
| 688 |
+
transition: all 0.2s;
|
| 689 |
+
}
|
| 690 |
+
|
| 691 |
+
.custom-button:hover {
|
| 692 |
+
background: #0056b3;
|
| 693 |
+
}
|
| 694 |
+
""", theme=theme)
|
| 695 |
+
|
| 696 |
+
|
| 697 |
|
| 698 |
with demo:
|
| 699 |
with gr.Tabs(elem_classes="main-tabs") as tabs:
|
| 700 |
with gr.Tab("Visual AI Assistant", elem_id="mouse-tab", elem_classes="mouse-tab"):
|
| 701 |
+
# SystemPrompt 설정을 위한 State 추가
|
| 702 |
setting = gr.State({
|
| 703 |
"system": SystemPrompt,
|
| 704 |
})
|
| 705 |
+
|
| 706 |
with ms.Application() as app:
|
| 707 |
with antd.ConfigProvider():
|
| 708 |
+
|
| 709 |
with antd.Drawer(open=False, title="AI is Creating...", placement="left", width="750px") as code_drawer:
|
| 710 |
gr.HTML("""
|
| 711 |
<div class="thinking-container">
|
| 712 |
<style>
|
| 713 |
+
.custom-textarea {
|
| 714 |
+
background: #f8f9fa !important;
|
| 715 |
+
border: 1px solid #e0e0e0 !important;
|
| 716 |
+
border-radius: 10px !important;
|
| 717 |
+
padding: 15px !important;
|
| 718 |
+
min-height: 150px !important;
|
| 719 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
.custom-textarea:focus {
|
| 723 |
+
border-color: #007aff !important;
|
| 724 |
+
box-shadow: 0 0 0 2px rgba(0,122,255,0.2) !important;
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
.thinking-container {
|
| 728 |
text-align: center;
|
| 729 |
padding: 20px;
|
| 730 |
background: #f8f9fa;
|
| 731 |
border-radius: 15px;
|
| 732 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 733 |
}
|
| 734 |
|
| 735 |
.progress-bar {
|
|
|
|
| 744 |
.progress-bar-inner {
|
| 745 |
width: 30%;
|
| 746 |
height: 100%;
|
| 747 |
+
background: linear-gradient(90deg, #007aff, #28c840);
|
| 748 |
animation: progress 2s ease-in-out infinite;
|
| 749 |
}
|
| 750 |
|
|
|
|
| 763 |
transition: all 0.3s ease;
|
| 764 |
}
|
| 765 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 766 |
.status-text {
|
| 767 |
+
color: #007aff;
|
| 768 |
font-size: 18px;
|
| 769 |
margin: 15px 0;
|
| 770 |
animation: fade 1.5s ease infinite;
|
|
|
|
| 779 |
|
| 780 |
.icon-item {
|
| 781 |
padding: 10px;
|
| 782 |
+
background: rgba(0,122,255,0.1);
|
| 783 |
border-radius: 8px;
|
| 784 |
animation: pulse 2s ease infinite;
|
| 785 |
}
|
|
|
|
| 807 |
</style>
|
| 808 |
|
| 809 |
<div class="thinking-icon">🎨</div>
|
|
|
|
| 810 |
<div class="status-text">Creating Your Visualization...</div>
|
|
|
|
| 811 |
<div class="progress-bar">
|
| 812 |
<div class="progress-bar-inner"></div>
|
| 813 |
</div>
|
|
|
|
| 814 |
<div class="icon-grid">
|
| 815 |
<div class="icon-item">📊</div>
|
| 816 |
<div class="icon-item">🎯</div>
|
| 817 |
<div class="icon-item">💡</div>
|
| 818 |
<div class="icon-item">✨</div>
|
| 819 |
</div>
|
|
|
|
| 820 |
<div class="tip-box">
|
| 821 |
+
<h3 style="color: #007aff; margin-bottom: 10px;">Did You Know?</h3>
|
| 822 |
<div id="tip-content" style="font-size: 16px; line-height: 1.6;"></div>
|
| 823 |
</div>
|
| 824 |
|
|
|
|
| 855 |
code_output = legacy.Markdown(visible=False)
|
| 856 |
|
| 857 |
|
| 858 |
+
# 메인 컨텐츠를 위한 Row
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 859 |
with antd.Row(gutter=[32, 12]) as layout:
|
| 860 |
# 좌측 패널
|
| 861 |
with antd.Col(span=24, md=8):
|
| 862 |
with antd.Flex(vertical=True, gap="middle", wrap=True):
|
| 863 |
+
# macOS 스타일 윈도우 헤더
|
| 864 |
+
header = gr.HTML("""
|
| 865 |
+
<div class="window-frame">
|
| 866 |
+
<div class="window-header">
|
| 867 |
+
<div class="window-controls">
|
| 868 |
+
<div class="control close"></div>
|
| 869 |
+
<div class="control minimize"></div>
|
| 870 |
+
<div class="control maximize"></div>
|
| 871 |
+
</div>
|
| 872 |
+
<div class="window-title">
|
| 873 |
+
<div class="window-address">
|
| 874 |
+
<div class="secure-icon">🔒</div>
|
| 875 |
+
<div class="url-bar">https://VIDraft-mouse-chat.hf.space</div>
|
| 876 |
+
</div>
|
| 877 |
+
</div>
|
| 878 |
+
</div>
|
| 879 |
+
<div class="app-content">
|
| 880 |
+
<img src="data:image/gif;base64,{}" width="360px" />
|
| 881 |
+
<h1 class="app-title">MOUSE-Chat Visual AI</h1>
|
| 882 |
+
<p class="app-description">Creates visualized web pages from text input, and when you include keywords like "image:", "그림:", or "image:" in your input, it automatically generates AI images based on the description and incorporates them into the web page.
|
| 883 |
+
Use the "Generate" button for basic creation, "Enhance" button for prompt improvement, "Share" button to deploy results to the web, and input like "image: a dog playing in the park" to create results containing both text and generated images.</p>
|
| 884 |
+
</div>
|
| 885 |
</div>
|
| 886 |
+
""".format(get_image_base64('mouse.gif')))
|
|
|
|
|
|
|
| 887 |
|
| 888 |
# 입력 영역
|
| 889 |
input = antd.InputTextarea(
|
| 890 |
size="large",
|
| 891 |
+
allow_clear=True,
|
| 892 |
+
placeholder=get_random_placeholder(),
|
| 893 |
+
elem_classes="custom-textarea" # style 대신 class 사용
|
| 894 |
|
|
|
|
| 895 |
)
|
| 896 |
|
| 897 |
# 버튼 그룹
|
| 898 |
+
with antd.Flex(gap="small", justify="flex-start"):
|
| 899 |
+
btn = antd.Button(
|
| 900 |
+
"Generate",
|
| 901 |
+
type="primary",
|
| 902 |
+
size="large",
|
| 903 |
+
elem_classes="generate-btn"
|
| 904 |
+
)
|
| 905 |
+
boost_btn = antd.Button(
|
| 906 |
+
"Enhance",
|
| 907 |
+
type="default",
|
| 908 |
+
size="large",
|
| 909 |
+
elem_classes="enhance-btn"
|
| 910 |
+
)
|
| 911 |
+
deploy_btn = antd.Button(
|
| 912 |
+
"Share",
|
| 913 |
+
type="default",
|
| 914 |
+
size="large",
|
| 915 |
+
elem_classes="share-btn"
|
| 916 |
+
)
|
| 917 |
+
|
| 918 |
+
|
| 919 |
+
deploy_result = gr.HTML(
|
| 920 |
+
label="Share Result",
|
| 921 |
+
elem_classes="deploy-result"
|
| 922 |
+
)
|
| 923 |
|
| 924 |
# 우측 패널
|
| 925 |
with antd.Col(span=24, md=16):
|
| 926 |
with ms.Div(elem_classes="right_panel"):
|
| 927 |
+
# macOS 스타일 윈도우 헤더
|
| 928 |
+
gr.HTML("""
|
| 929 |
+
<div class="window-frame">
|
| 930 |
+
<div class="window-header">
|
| 931 |
+
<div class="window-controls">
|
| 932 |
+
<div class="control close"></div>
|
| 933 |
+
<div class="control minimize"></div>
|
| 934 |
+
<div class="control maximize"></div>
|
| 935 |
+
</div>
|
| 936 |
+
<div class="window-title">Preview</div>
|
| 937 |
+
</div>
|
| 938 |
+
</div>
|
| 939 |
+
""")
|
| 940 |
|
| 941 |
# 탭 컨텐츠
|
| 942 |
with antd.Tabs(active_key="empty", render_tab_bar="() => null") as state_tab:
|
| 943 |
with antd.Tabs.Item(key="empty"):
|
| 944 |
+
empty = antd.Empty(
|
| 945 |
+
description="Enter your question to begin",
|
| 946 |
|
| 947 |
+
elem_classes="right_content empty-content" # style 대신 class 사용
|
| 948 |
+
|
| 949 |
+
)
|
| 950 |
+
|
| 951 |
with antd.Tabs.Item(key="loading"):
|
| 952 |
+
loading = antd.Spin(
|
| 953 |
+
True,
|
| 954 |
+
tip="Creating visual presentation...",
|
| 955 |
+
size="large",
|
| 956 |
+
elem_classes="right_content"
|
| 957 |
+
)
|
| 958 |
+
|
| 959 |
with antd.Tabs.Item(key="render"):
|
| 960 |
sandbox = gr.HTML(elem_classes="html_content")
|
| 961 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
|
| 963 |
btn.click(
|
| 964 |
demo_instance.generation_code,
|
| 965 |
+
inputs=[input, setting], # setting이 이제 정의됨
|
| 966 |
+
outputs=[code_output, sandbox, state_tab, code_drawer]
|
| 967 |
+
).then(
|
| 968 |
fn=update_placeholder,
|
| 969 |
inputs=[],
|
| 970 |
outputs=[input]
|
| 971 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 972 |
|
| 973 |
|
| 974 |
boost_btn.click(
|
|
|
|
| 978 |
)
|
| 979 |
|
| 980 |
deploy_btn.click(
|
| 981 |
+
fn=lambda code: deploy_to_vercel(remove_code_block(code)) if code else "No code to share.",
|
| 982 |
inputs=[code_output],
|
| 983 |
outputs=[deploy_result]
|
| 984 |
)
|
| 985 |
|
| 986 |
+
gr.HTML("""
|
| 987 |
+
<style>
|
| 988 |
+
.generate-btn {
|
| 989 |
+
background: #007aff !important;
|
| 990 |
+
border-radius: 8px !important;
|
| 991 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
|
| 992 |
+
}
|
| 993 |
+
|
| 994 |
+
.enhance-btn {
|
| 995 |
+
border-radius: 8px !important;
|
| 996 |
+
border: 1px solid #007aff !important;
|
| 997 |
+
color: #007aff !important;
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
.share-btn {
|
| 1001 |
+
border-radius: 8px !important;
|
| 1002 |
+
border: 1px solid #28c840 !important;
|
| 1003 |
+
color: #28c840 !important;
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
/* hover 효과 */
|
| 1007 |
+
.generate-btn:hover {
|
| 1008 |
+
background: #0056b3 !important;
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
.enhance-btn:hover {
|
| 1012 |
+
background: rgba(0,122,255,0.1) !important;
|
| 1013 |
+
}
|
| 1014 |
+
|
| 1015 |
+
.share-btn:hover {
|
| 1016 |
+
background: rgba(40,200,64,0.1) !important;
|
| 1017 |
+
}
|
| 1018 |
+
|
| 1019 |
+
.app-content {
|
| 1020 |
+
padding: 20px;
|
| 1021 |
+
text-align: center;
|
| 1022 |
+
}
|
| 1023 |
+
|
| 1024 |
+
.app-title {
|
| 1025 |
+
font-size: 24px;
|
| 1026 |
+
color: #333;
|
| 1027 |
+
margin: 20px 0 10px;
|
| 1028 |
+
font-weight: 600;
|
| 1029 |
+
}
|
| 1030 |
+
|
| 1031 |
+
.app-description {
|
| 1032 |
+
color: #666;
|
| 1033 |
+
font-size: 14px;
|
| 1034 |
+
margin-bottom: 30px;
|
| 1035 |
+
}
|
| 1036 |
+
|
| 1037 |
+
.deploy-result {
|
| 1038 |
+
margin-top: 20px;
|
| 1039 |
+
padding: 15px;
|
| 1040 |
+
background: #f8f9fa;
|
| 1041 |
+
border-radius: 8px;
|
| 1042 |
+
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
| 1043 |
+
}
|
| 1044 |
+
|
| 1045 |
+
.deploy-result a {
|
| 1046 |
+
color: #007aff;
|
| 1047 |
+
text-decoration: none;
|
| 1048 |
+
font-weight: 500;
|
| 1049 |
+
}
|
| 1050 |
+
|
| 1051 |
+
.deploy-result a:hover {
|
| 1052 |
+
text-decoration: underline;
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
/* 반응형 디자인을 위한 미디어 쿼리 */
|
| 1056 |
+
@media (max-width: 768px) {
|
| 1057 |
+
.window-frame {
|
| 1058 |
+
border-radius: 0;
|
| 1059 |
+
}
|
| 1060 |
+
|
| 1061 |
+
.left-panel, .right-panel {
|
| 1062 |
+
width: 100%;
|
| 1063 |
+
}
|
| 1064 |
+
|
| 1065 |
+
.main-content {
|
| 1066 |
+
flex-direction: column;
|
| 1067 |
+
}
|
| 1068 |
+
}
|
| 1069 |
+
</style>
|
| 1070 |
+
""")
|
| 1071 |
+
|
| 1072 |
return demo
|
| 1073 |
|
| 1074 |
# 메인 실행 부분
|
|
|
|
| 1076 |
try:
|
| 1077 |
demo_instance = Demo() # Demo 인스턴스 생성
|
| 1078 |
demo = create_main_interface() # 인터페이스 생성
|
| 1079 |
+
demo.queue(
|
| 1080 |
+
default_concurrency_limit=20, # concurrency_count 대신 default_concurrency_limit 사용
|
| 1081 |
+
status_update_rate=10,
|
| 1082 |
+
api_open=False
|
| 1083 |
+
).launch(
|
| 1084 |
+
server_name="0.0.0.0",
|
| 1085 |
+
server_port=7860,
|
| 1086 |
+
share=False,
|
| 1087 |
+
debug=False
|
| 1088 |
+
)
|
| 1089 |
except Exception as e:
|
| 1090 |
print(f"Initialization error: {e}")
|
| 1091 |
raise
|