Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -570,7 +570,7 @@ def process_uploads(uploaded_files, project_dir):
|
|
| 570 |
}, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 571 |
return "\n".join(messages)
|
| 572 |
|
| 573 |
-
# FIXED
|
| 574 |
FILE_BLOCK_PATTERN = re.compile(
|
| 575 |
r"<<<FILE:\s*(.*?)>>>\s*(.*?)\s*<<<END FILE>>>",
|
| 576 |
re.DOTALL | re.IGNORECASE,
|
|
@@ -619,7 +619,7 @@ def make_html_preview(project_dir):
|
|
| 619 |
project_dir = Path(project_dir)
|
| 620 |
html_files = list(project_dir.rglob("index.html")) or list(project_dir.rglob("*.html"))
|
| 621 |
if not html_files:
|
| 622 |
-
return "<div style='padding:25px;color:#
|
| 623 |
html_file = html_files[0]
|
| 624 |
try:
|
| 625 |
html = html_file.read_text(encoding="utf-8", errors="replace")
|
|
@@ -643,13 +643,14 @@ def make_html_preview(project_dir):
|
|
| 643 |
|
| 644 |
return f"""
|
| 645 |
<iframe sandbox="allow-scripts allow-forms"
|
| 646 |
-
style="width:100%;height:650px;border:
|
| 647 |
srcdoc="{html.replace('&', '&').replace('"', '"').replace('<', '<').replace('>', '>')}"
|
| 648 |
></iframe>
|
| 649 |
"""
|
| 650 |
except Exception as error:
|
| 651 |
return f"<div style='padding:20px;color:#ff9999'>Preview error: {error}</div>"
|
| 652 |
|
|
|
|
| 653 |
class StopCriteria(StoppingCriteria):
|
| 654 |
def __init__(self, event):
|
| 655 |
self.event = event
|
|
@@ -749,7 +750,7 @@ def run_coding_worker(job_id, session_id, conversation_id, prompt, model_name, m
|
|
| 749 |
final_response = response
|
| 750 |
if changed_files:
|
| 751 |
file_status = "\n".join(
|
| 752 |
-
f"-
|
| 753 |
)
|
| 754 |
final_response += "\n\n---\n### Project File Updates\n" + file_status
|
| 755 |
|
|
@@ -795,8 +796,7 @@ def coding_assistant(prompt, model_name, max_tokens, temperature, uploaded_files
|
|
| 795 |
job_threads[job_id] = worker
|
| 796 |
worker.start()
|
| 797 |
|
| 798 |
-
yield ("⏳ ARISE AI is analyzing
|
| 799 |
-
upload_status or "Job started.", None, None, job_id)
|
| 800 |
|
| 801 |
previous_response = ""
|
| 802 |
while True:
|
|
@@ -833,23 +833,6 @@ def coding_assistant(prompt, model_name, max_tokens, temperature, uploaded_files
|
|
| 833 |
return
|
| 834 |
time.sleep(1)
|
| 835 |
|
| 836 |
-
def resume_job(job_id, request: gr.Request):
|
| 837 |
-
session_id = request.session_hash if request else "default"
|
| 838 |
-
if not job_id:
|
| 839 |
-
yield ("No active job selected.", "Nothing to resume.", None, None)
|
| 840 |
-
return
|
| 841 |
-
while True:
|
| 842 |
-
job = get_job(job_id, session_id)
|
| 843 |
-
if not job:
|
| 844 |
-
yield ("Job not found for this session.", "Job unavailable.", None, None)
|
| 845 |
-
return
|
| 846 |
-
status = job["status"]
|
| 847 |
-
response = job["response"] or ""
|
| 848 |
-
yield (response, f"Job status: {status}", None, None)
|
| 849 |
-
if status not in ["queued", "running"]:
|
| 850 |
-
return
|
| 851 |
-
time.sleep(2)
|
| 852 |
-
|
| 853 |
def stop_job(job_id):
|
| 854 |
if not job_id:
|
| 855 |
return "No active job."
|
|
@@ -860,887 +843,282 @@ def stop_job(job_id):
|
|
| 860 |
return "⏹ Stop requested."
|
| 861 |
return "No running job found."
|
| 862 |
|
| 863 |
-
# =========================================================
|
| 864 |
-
# HISTORY
|
| 865 |
-
# =========================================================
|
| 866 |
-
|
| 867 |
def refresh_history(request: gr.Request):
|
| 868 |
session_id = request.session_hash if request else "default"
|
| 869 |
return gr.Dropdown(choices=get_conversations(session_id), value=None)
|
| 870 |
|
| 871 |
-
def load_selected_history(conversation_id, request: gr.Request):
|
| 872 |
-
session_id = request.session_hash if request else "default"
|
| 873 |
-
if not conversation_id:
|
| 874 |
-
return ("", None, "Select a history item.", None)
|
| 875 |
-
conversation = get_conversation(session_id, conversation_id)
|
| 876 |
-
if not conversation:
|
| 877 |
-
return ("", None, "History not found.", None)
|
| 878 |
-
display = ""
|
| 879 |
-
for item in conversation["history"]:
|
| 880 |
-
role = item.get("role", "assistant").title()
|
| 881 |
-
content = item.get("content", "")
|
| 882 |
-
display += f"\n\n### {role}\n{content}\n"
|
| 883 |
-
active_job = get_active_job(session_id, conversation_id)
|
| 884 |
-
job_id = active_job["id"] if active_job else None
|
| 885 |
-
return (display or "This conversation is empty.", conversation_id,
|
| 886 |
-
f"Loaded: {conversation['title']}", job_id)
|
| 887 |
-
|
| 888 |
-
def delete_selected_history(conversation_ids, request: gr.Request):
|
| 889 |
-
session_id = request.session_hash if request else "default"
|
| 890 |
-
delete_conversations(session_id, conversation_ids or [])
|
| 891 |
-
return (gr.Dropdown(choices=get_conversations(session_id), value=None), "Selected history deleted.")
|
| 892 |
-
|
| 893 |
-
def clear_current_conversation():
|
| 894 |
-
return ("", None, "Ready for a new conversation.", None)
|
| 895 |
-
|
| 896 |
def preview_project(conversation_id):
|
| 897 |
if not conversation_id:
|
| 898 |
-
return "<p>No project selected.</p>"
|
| 899 |
return make_html_preview(get_project_dir(conversation_id))
|
| 900 |
|
|
|
|
| 901 |
# =========================================================
|
| 902 |
-
#
|
| 903 |
# =========================================================
|
| 904 |
|
| 905 |
-
CSS =
|
| 906 |
-
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');
|
| 907 |
-
|
| 908 |
-
:root {
|
| 909 |
-
color-scheme: dark;
|
| 910 |
-
--arise-violet: #8b5cf6;
|
| 911 |
-
--arise-cyan: #22d3ee;
|
| 912 |
-
--arise-pink: #f472b6;
|
| 913 |
-
--arise-deep: #06080f;
|
| 914 |
-
}
|
| 915 |
-
|
| 916 |
-
* { box-sizing: border-box; }
|
| 917 |
-
|
| 918 |
body, .gradio-container {
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
content:
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
|
| 941 |
-
background:
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
| 950 |
-
|
| 951 |
-
|
| 952 |
-
|
| 953 |
-
|
| 954 |
-
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
background-
|
| 963 |
-
|
| 964 |
-
radial-gradient(1px 1px at 80% 70%, #8b5cf6, transparent),
|
| 965 |
-
radial-gradient(1.5px 1.5px at 40% 80%, #22d3ee, transparent),
|
| 966 |
-
radial-gradient(1px 1px at 60% 20%, #f472b6, transparent),
|
| 967 |
-
radial-gradient(1px 1px at 90% 40%, #fff, transparent),
|
| 968 |
-
radial-gradient(1.5px 1.5px at 10% 60%, #22d3ee, transparent);
|
| 969 |
-
background-size: 300px 300px, 400px 400px, 500px 500px, 350px 350px, 450px 450px, 550px 550px;
|
| 970 |
-
animation: starsFloat 60s linear infinite;
|
| 971 |
-
pointer-events: none;
|
| 972 |
-
z-index: 0;
|
| 973 |
-
opacity: 0.55;
|
| 974 |
-
}
|
| 975 |
-
|
| 976 |
-
@keyframes starsFloat {
|
| 977 |
-
from { background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
|
| 978 |
-
to { background-position: 300px 600px, -400px 400px, 500px -500px, -350px -350px, 450px 450px, -550px 550px; }
|
| 979 |
-
}
|
| 980 |
-
|
| 981 |
-
/* === CONTAINER === */
|
| 982 |
-
.gradio-container {
|
| 983 |
-
width: 100% !important;
|
| 984 |
-
max-width: 1300px !important;
|
| 985 |
-
margin: auto !important;
|
| 986 |
-
background: transparent !important;
|
| 987 |
-
padding: 14px !important;
|
| 988 |
-
position: relative;
|
| 989 |
-
z-index: 1;
|
| 990 |
-
animation: fadeBoot 1s ease-out;
|
| 991 |
-
}
|
| 992 |
-
|
| 993 |
-
@keyframes fadeBoot {
|
| 994 |
-
from { opacity: 0; transform: translateY(20px); }
|
| 995 |
-
to { opacity: 1; transform: translateY(0); }
|
| 996 |
-
}
|
| 997 |
-
|
| 998 |
-
/* === HEADER BANNER === */
|
| 999 |
-
#main-header {
|
| 1000 |
-
position: relative;
|
| 1001 |
-
overflow: hidden;
|
| 1002 |
-
text-align: center;
|
| 1003 |
-
padding: 46px 20px;
|
| 1004 |
-
border: 1px solid rgba(139,92,246,0.4);
|
| 1005 |
-
border-radius: 26px;
|
| 1006 |
-
background:
|
| 1007 |
-
linear-gradient(135deg, rgba(45,26,90,0.95) 0%, rgba(9,35,57,0.95) 50%, rgba(30,17,70,0.95) 100%);
|
| 1008 |
-
box-shadow:
|
| 1009 |
-
0 0 40px rgba(139,92,246,0.25),
|
| 1010 |
-
0 0 80px rgba(34,211,238,0.12),
|
| 1011 |
-
inset 0 1px 0 rgba(255,255,255,0.08);
|
| 1012 |
-
animation: bannerPulse 4s ease-in-out infinite alternate;
|
| 1013 |
-
}
|
| 1014 |
-
|
| 1015 |
-
@keyframes bannerPulse {
|
| 1016 |
-
from {
|
| 1017 |
-
box-shadow: 0 0 30px rgba(139,92,246,0.2), 0 0 60px rgba(34,211,238,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
|
| 1018 |
-
}
|
| 1019 |
-
to {
|
| 1020 |
-
box-shadow: 0 0 50px rgba(139,92,246,0.4), 0 0 100px rgba(34,211,238,0.2), inset 0 1px 0 rgba(255,255,255,0.1);
|
| 1021 |
-
}
|
| 1022 |
-
}
|
| 1023 |
-
|
| 1024 |
-
#main-header::before {
|
| 1025 |
-
content: '';
|
| 1026 |
-
position: absolute;
|
| 1027 |
-
inset: -2px;
|
| 1028 |
-
border-radius: 26px;
|
| 1029 |
-
padding: 2px;
|
| 1030 |
-
background: linear-gradient(135deg, #8b5cf6, #22d3ee, #f472b6, #8b5cf6);
|
| 1031 |
-
background-size: 300% 300%;
|
| 1032 |
-
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
|
| 1033 |
-
-webkit-mask-composite: xor;
|
| 1034 |
-
mask-composite: exclude;
|
| 1035 |
-
animation: borderFlow 6s linear infinite;
|
| 1036 |
-
pointer-events: none;
|
| 1037 |
-
}
|
| 1038 |
-
|
| 1039 |
-
@keyframes borderFlow {
|
| 1040 |
-
0% { background-position: 0% 50%; }
|
| 1041 |
-
100% { background-position: 300% 50%; }
|
| 1042 |
-
}
|
| 1043 |
-
|
| 1044 |
-
.hero-title {
|
| 1045 |
-
font-family: 'Space Grotesk', sans-serif;
|
| 1046 |
-
font-size: clamp(32px, 6vw, 62px);
|
| 1047 |
-
font-weight: 800;
|
| 1048 |
-
letter-spacing: -2px;
|
| 1049 |
-
background: linear-gradient(90deg, #fff 0%, #b8a5ff 25%, #56e8ff 50%, #f472b6 75%, #fff 100%);
|
| 1050 |
-
background-size: 300% auto;
|
| 1051 |
-
-webkit-background-clip: text;
|
| 1052 |
-
-webkit-text-fill-color: transparent;
|
| 1053 |
-
background-clip: text;
|
| 1054 |
-
animation: heroShine 5s linear infinite;
|
| 1055 |
-
text-shadow: 0 0 40px rgba(139,92,246,0.4);
|
| 1056 |
-
}
|
| 1057 |
-
|
| 1058 |
-
@keyframes heroShine {
|
| 1059 |
-
0% { background-position: 0% center; }
|
| 1060 |
-
100% { background-position: 300% center; }
|
| 1061 |
-
}
|
| 1062 |
-
|
| 1063 |
-
.hero-subtitle {
|
| 1064 |
-
color: #bdc7df;
|
| 1065 |
-
font-size: 13px;
|
| 1066 |
-
letter-spacing: 4px;
|
| 1067 |
-
margin-top: 14px;
|
| 1068 |
-
font-weight: 600;
|
| 1069 |
-
text-transform: uppercase;
|
| 1070 |
-
}
|
| 1071 |
-
|
| 1072 |
-
.hero-badges span {
|
| 1073 |
-
display: inline-flex;
|
| 1074 |
-
align-items: center;
|
| 1075 |
-
gap: 6px;
|
| 1076 |
-
background: rgba(255,255,255,0.06);
|
| 1077 |
-
backdrop-filter: blur(10px);
|
| 1078 |
-
padding: 8px 16px;
|
| 1079 |
-
border-radius: 30px;
|
| 1080 |
-
color: #d8d5ff;
|
| 1081 |
-
font-size: 12px;
|
| 1082 |
-
font-weight: 500;
|
| 1083 |
-
margin: 4px;
|
| 1084 |
-
border: 1px solid rgba(255,255,255,0.1);
|
| 1085 |
-
transition: all 0.3s ease;
|
| 1086 |
-
}
|
| 1087 |
-
|
| 1088 |
-
.hero-badges span:hover {
|
| 1089 |
-
background: rgba(139,92,246,0.25);
|
| 1090 |
-
border-color: rgba(139,92,246,0.6);
|
| 1091 |
-
box-shadow: 0 0 20px rgba(139,92,246,0.5);
|
| 1092 |
-
transform: translateY(-3px);
|
| 1093 |
-
}
|
| 1094 |
-
|
| 1095 |
-
/* === TABS === */
|
| 1096 |
-
.gradio-container .tab-nav {
|
| 1097 |
-
border: 1px solid rgba(139,92,246,0.3) !important;
|
| 1098 |
-
border-radius: 18px !important;
|
| 1099 |
-
background: rgba(18,24,40,0.85) !important;
|
| 1100 |
-
backdrop-filter: blur(14px);
|
| 1101 |
-
padding: 8px !important;
|
| 1102 |
-
box-shadow: 0 0 30px rgba(139,92,246,0.1);
|
| 1103 |
-
}
|
| 1104 |
-
|
| 1105 |
-
.gradio-container .tab-nav button {
|
| 1106 |
-
border-radius: 12px !important;
|
| 1107 |
-
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
| 1108 |
-
font-weight: 600 !important;
|
| 1109 |
-
letter-spacing: 0.3px;
|
| 1110 |
-
}
|
| 1111 |
-
|
| 1112 |
-
.gradio-container .tab-nav button:hover {
|
| 1113 |
-
background: rgba(139,92,246,0.15) !important;
|
| 1114 |
-
color: #b8a5ff !important;
|
| 1115 |
-
}
|
| 1116 |
-
|
| 1117 |
-
.gradio-container .tab-nav button.selected {
|
| 1118 |
-
background: linear-gradient(135deg, #7045ed, #168edb) !important;
|
| 1119 |
-
color: #fff !important;
|
| 1120 |
-
box-shadow: 0 0 25px rgba(139,92,246,0.6) !important;
|
| 1121 |
-
}
|
| 1122 |
-
|
| 1123 |
-
/* === BUTTONS === */
|
| 1124 |
-
.gradio-container button {
|
| 1125 |
border-radius: 12px !important;
|
| 1126 |
-
|
| 1127 |
-
|
| 1128 |
-
position: relative;
|
| 1129 |
-
overflow: hidden;
|
| 1130 |
-
}
|
| 1131 |
-
|
| 1132 |
-
.gradio-container button::before {
|
| 1133 |
-
content: '';
|
| 1134 |
-
position: absolute;
|
| 1135 |
-
top: 50%;
|
| 1136 |
-
left: 50%;
|
| 1137 |
-
width: 0;
|
| 1138 |
-
height: 0;
|
| 1139 |
-
border-radius: 50%;
|
| 1140 |
-
background: rgba(255,255,255,0.3);
|
| 1141 |
-
transform: translate(-50%, -50%);
|
| 1142 |
-
transition: width 0.6s, height 0.6s;
|
| 1143 |
-
pointer-events: none;
|
| 1144 |
-
}
|
| 1145 |
-
|
| 1146 |
-
.gradio-container button:active::before {
|
| 1147 |
-
width: 300px;
|
| 1148 |
-
height: 300px;
|
| 1149 |
}
|
| 1150 |
-
|
| 1151 |
-
|
| 1152 |
-
|
| 1153 |
-
box-shadow: 0 8px 25px rgba(139,92,246,0.4);
|
| 1154 |
}
|
| 1155 |
-
|
| 1156 |
.primary {
|
| 1157 |
-
background:
|
| 1158 |
-
background-size: 200% 200% !important;
|
| 1159 |
color: white !important;
|
| 1160 |
-
|
| 1161 |
-
letter-spacing: 0.5px;
|
| 1162 |
-
animation: gradientShift 3s ease infinite;
|
| 1163 |
-
box-shadow: 0 4px 20px rgba(139,92,246,0.4) !important;
|
| 1164 |
-
}
|
| 1165 |
-
|
| 1166 |
-
@keyframes gradientShift {
|
| 1167 |
-
0%, 100% { background-position: 0% 50%; }
|
| 1168 |
-
50% { background-position: 100% 50%; }
|
| 1169 |
}
|
| 1170 |
-
|
| 1171 |
.primary:hover {
|
| 1172 |
-
|
| 1173 |
-
}
|
| 1174 |
-
|
| 1175 |
-
.stop-btn, button[variant="stop"] {
|
| 1176 |
-
background: linear-gradient(135deg, #dc2626, #f97316) !important;
|
| 1177 |
-
color: white !important;
|
| 1178 |
-
box-shadow: 0 4px 20px rgba(220,38,38,0.4) !important;
|
| 1179 |
-
}
|
| 1180 |
-
|
| 1181 |
-
.stop-btn:hover, button[variant="stop"]:hover {
|
| 1182 |
-
box-shadow: 0 8px 30px rgba(220,38,38,0.7) !important;
|
| 1183 |
-
}
|
| 1184 |
-
|
| 1185 |
-
/* === INPUTS === */
|
| 1186 |
-
textarea, input[type="text"], input[type="number"], .gr-box {
|
| 1187 |
-
border-radius: 14px !important;
|
| 1188 |
-
background: rgba(15,20,35,0.7) !important;
|
| 1189 |
-
border: 1px solid rgba(139,92,246,0.2) !important;
|
| 1190 |
-
transition: all 0.3s ease !important;
|
| 1191 |
-
backdrop-filter: blur(10px);
|
| 1192 |
-
}
|
| 1193 |
-
|
| 1194 |
-
textarea:focus, input:focus {
|
| 1195 |
-
border-color: rgba(139,92,246,0.7) !important;
|
| 1196 |
-
box-shadow: 0 0 0 3px rgba(139,92,246,0.2), 0 0 30px rgba(139,92,246,0.3) !important;
|
| 1197 |
-
outline: none !important;
|
| 1198 |
-
}
|
| 1199 |
-
|
| 1200 |
-
/* === CODING OUTPUT — the star of the show === */
|
| 1201 |
-
#coding-output {
|
| 1202 |
-
min-height: 320px;
|
| 1203 |
-
padding: 22px;
|
| 1204 |
-
border: 1px solid rgba(34,211,238,0.3);
|
| 1205 |
-
border-radius: 18px;
|
| 1206 |
-
background:
|
| 1207 |
-
linear-gradient(135deg, rgba(9,15,28,0.92), rgba(18,15,40,0.92));
|
| 1208 |
-
backdrop-filter: blur(16px);
|
| 1209 |
-
overflow-wrap: anywhere;
|
| 1210 |
-
position: relative;
|
| 1211 |
-
box-shadow:
|
| 1212 |
-
0 0 30px rgba(34,211,238,0.15),
|
| 1213 |
-
inset 0 1px 0 rgba(255,255,255,0.05);
|
| 1214 |
-
transition: all 0.4s ease;
|
| 1215 |
-
font-family: 'JetBrains Mono', 'Space Grotesk', monospace;
|
| 1216 |
-
font-size: 14px;
|
| 1217 |
-
line-height: 1.7;
|
| 1218 |
-
}
|
| 1219 |
-
|
| 1220 |
-
#coding-output::before {
|
| 1221 |
-
content: '';
|
| 1222 |
-
position: absolute;
|
| 1223 |
-
top: 0;
|
| 1224 |
-
left: 0;
|
| 1225 |
-
right: 0;
|
| 1226 |
-
height: 2px;
|
| 1227 |
-
background: linear-gradient(90deg, transparent, #22d3ee, #8b5cf6, transparent);
|
| 1228 |
-
border-radius: 18px 18px 0 0;
|
| 1229 |
-
animation: scanline 3s ease-in-out infinite;
|
| 1230 |
-
}
|
| 1231 |
-
|
| 1232 |
-
@keyframes scanline {
|
| 1233 |
-
0%, 100% { opacity: 0.4; }
|
| 1234 |
-
50% { opacity: 1; box-shadow: 0 0 15px #22d3ee; }
|
| 1235 |
-
}
|
| 1236 |
-
|
| 1237 |
-
#coding-output pre {
|
| 1238 |
-
max-width: 100%;
|
| 1239 |
-
overflow-x: auto;
|
| 1240 |
-
background: rgba(0,0,0,0.5) !important;
|
| 1241 |
-
padding: 14px !important;
|
| 1242 |
-
border-radius: 10px !important;
|
| 1243 |
-
border: 1px solid rgba(139,92,246,0.15);
|
| 1244 |
-
}
|
| 1245 |
-
|
| 1246 |
-
/* Blinking cursor while streaming */
|
| 1247 |
-
#coding-output.streaming::after {
|
| 1248 |
-
content: '▋';
|
| 1249 |
-
color: #22d3ee;
|
| 1250 |
-
animation: cursorBlink 0.8s step-end infinite;
|
| 1251 |
-
margin-left: 2px;
|
| 1252 |
-
text-shadow: 0 0 10px #22d3ee;
|
| 1253 |
}
|
| 1254 |
-
|
| 1255 |
-
|
| 1256 |
-
|
| 1257 |
-
|
| 1258 |
-
|
| 1259 |
-
|
| 1260 |
-
/* === STATUS BADGE === */
|
| 1261 |
-
#coding-status {
|
| 1262 |
-
display: inline-block;
|
| 1263 |
-
padding: 8px 16px;
|
| 1264 |
-
border-radius: 20px;
|
| 1265 |
-
background: rgba(34,211,238,0.1);
|
| 1266 |
-
border: 1px solid rgba(34,211,238,0.3);
|
| 1267 |
-
color: #a5f3fc;
|
| 1268 |
-
font-size: 12px;
|
| 1269 |
-
font-weight: 600;
|
| 1270 |
-
letter-spacing: 0.5px;
|
| 1271 |
-
animation: statusPulse 2s ease-in-out infinite;
|
| 1272 |
-
}
|
| 1273 |
-
|
| 1274 |
-
@keyframes statusPulse {
|
| 1275 |
-
0%, 100% { box-shadow: 0 0 10px rgba(34,211,238,0.3); }
|
| 1276 |
-
50% { box-shadow: 0 0 25px rgba(34,211,238,0.6); }
|
| 1277 |
-
}
|
| 1278 |
-
|
| 1279 |
-
/* === SCROLLBAR === */
|
| 1280 |
-
::-webkit-scrollbar {
|
| 1281 |
-
width: 8px;
|
| 1282 |
-
height: 8px;
|
| 1283 |
-
}
|
| 1284 |
-
|
| 1285 |
-
::-webkit-scrollbar-track {
|
| 1286 |
-
background: rgba(255,255,255,0.03);
|
| 1287 |
-
border-radius: 10px;
|
| 1288 |
-
}
|
| 1289 |
-
|
| 1290 |
-
::-webkit-scrollbar-thumb {
|
| 1291 |
-
background: linear-gradient(180deg, #8b5cf6, #22d3ee);
|
| 1292 |
-
border-radius: 10px;
|
| 1293 |
-
box-shadow: 0 0 10px rgba(139,92,246,0.5);
|
| 1294 |
-
}
|
| 1295 |
-
|
| 1296 |
-
::-webkit-scrollbar-thumb:hover {
|
| 1297 |
-
background: linear-gradient(180deg, #a855f7, #67e8f9);
|
| 1298 |
-
}
|
| 1299 |
-
|
| 1300 |
-
/* === MENU PANEL === */
|
| 1301 |
-
#menu-panel {
|
| 1302 |
-
border: 1px solid rgba(139,92,246,0.4);
|
| 1303 |
-
background: rgba(16,22,39,0.92);
|
| 1304 |
-
backdrop-filter: blur(20px);
|
| 1305 |
-
border-radius: 16px;
|
| 1306 |
-
padding: 16px;
|
| 1307 |
-
box-shadow: 0 0 40px rgba(139,92,246,0.2);
|
| 1308 |
-
animation: menuSlide 0.4s ease-out;
|
| 1309 |
-
}
|
| 1310 |
-
|
| 1311 |
-
@keyframes menuSlide {
|
| 1312 |
-
from { opacity: 0; transform: translateY(-10px); }
|
| 1313 |
-
to { opacity: 1; transform: translateY(0); }
|
| 1314 |
-
}
|
| 1315 |
-
|
| 1316 |
-
/* === FOOTER === */
|
| 1317 |
-
#footer {
|
| 1318 |
-
text-align: center;
|
| 1319 |
-
color: #8390ad;
|
| 1320 |
-
padding: 30px 20px;
|
| 1321 |
-
border-top: 1px solid rgba(139,92,246,0.15);
|
| 1322 |
-
margin-top: 30px;
|
| 1323 |
-
position: relative;
|
| 1324 |
-
}
|
| 1325 |
-
|
| 1326 |
-
#footer::before {
|
| 1327 |
-
content: '';
|
| 1328 |
-
position: absolute;
|
| 1329 |
-
top: 0;
|
| 1330 |
-
left: 30%;
|
| 1331 |
-
right: 30%;
|
| 1332 |
-
height: 1px;
|
| 1333 |
-
background: linear-gradient(90deg, transparent, #8b5cf6, transparent);
|
| 1334 |
-
animation: footerGlow 3s ease-in-out infinite;
|
| 1335 |
-
}
|
| 1336 |
-
|
| 1337 |
-
@keyframes footerGlow {
|
| 1338 |
-
0%, 100% { opacity: 0.3; box-shadow: none; }
|
| 1339 |
-
50% { opacity: 1; box-shadow: 0 0 15px #8b5cf6; }
|
| 1340 |
-
}
|
| 1341 |
-
|
| 1342 |
-
#footer a {
|
| 1343 |
-
color: #a5b4fc;
|
| 1344 |
-
text-decoration: none;
|
| 1345 |
-
transition: all 0.3s;
|
| 1346 |
-
}
|
| 1347 |
-
|
| 1348 |
-
#footer a:hover {
|
| 1349 |
-
color: #67e8f9;
|
| 1350 |
-
text-shadow: 0 0 15px #67e8f9;
|
| 1351 |
-
}
|
| 1352 |
-
|
| 1353 |
-
/* === CARD HOVER EFFECT for blocks === */
|
| 1354 |
-
.gradio-container .block {
|
| 1355 |
-
transition: all 0.3s ease;
|
| 1356 |
-
}
|
| 1357 |
-
|
| 1358 |
-
.gradio-container .block:hover {
|
| 1359 |
-
border-color: rgba(139,92,246,0.4) !important;
|
| 1360 |
-
}
|
| 1361 |
-
|
| 1362 |
-
/* === LOADING SPINNER === */
|
| 1363 |
-
.generating {
|
| 1364 |
-
position: relative;
|
| 1365 |
}
|
| 1366 |
-
|
| 1367 |
-
|
| 1368 |
-
|
| 1369 |
-
position: absolute;
|
| 1370 |
-
top: 12px;
|
| 1371 |
-
right: 12px;
|
| 1372 |
-
width: 16px;
|
| 1373 |
-
height: 16px;
|
| 1374 |
-
border: 2px solid rgba(34,211,238,0.3);
|
| 1375 |
-
border-top-color: #22d3ee;
|
| 1376 |
-
border-radius: 50%;
|
| 1377 |
-
animation: spin 0.8s linear infinite;
|
| 1378 |
-
}
|
| 1379 |
-
|
| 1380 |
-
@keyframes spin {
|
| 1381 |
-
to { transform: rotate(360deg); }
|
| 1382 |
}
|
| 1383 |
-
|
| 1384 |
-
|
| 1385 |
-
|
| 1386 |
-
.gradio-container { padding: 6px !important; }
|
| 1387 |
-
#main-header { padding: 28px 12px; border-radius: 18px; }
|
| 1388 |
-
.hero-title { font-size: 30px; letter-spacing: -1px; }
|
| 1389 |
-
.hero-subtitle { font-size: 10px; letter-spacing: 2px; }
|
| 1390 |
-
.gradio-container .tab-nav button {
|
| 1391 |
-
font-size: 11px !important;
|
| 1392 |
-
padding: 8px 5px !important;
|
| 1393 |
-
}
|
| 1394 |
-
#coding-output {
|
| 1395 |
-
min-height: 240px;
|
| 1396 |
-
padding: 12px;
|
| 1397 |
-
font-size: 12px;
|
| 1398 |
-
}
|
| 1399 |
}
|
| 1400 |
-
|
| 1401 |
-
|
| 1402 |
-
# =========================================================
|
| 1403 |
-
# PREMIUM JS — TYPING CURSOR + RIPPLE + SMOOTH SCROLL
|
| 1404 |
-
# =========================================================
|
| 1405 |
-
|
| 1406 |
-
PREMIUM_JS = """
|
| 1407 |
-
() => {
|
| 1408 |
-
// Typing cursor effect on streaming output
|
| 1409 |
-
const attachCursor = () => {
|
| 1410 |
-
const output = document.querySelector('#coding-output');
|
| 1411 |
-
if (!output) return;
|
| 1412 |
-
if (output.dataset.cursorAttached) return;
|
| 1413 |
-
output.dataset.cursorAttached = '1';
|
| 1414 |
-
|
| 1415 |
-
let streamTimer = null;
|
| 1416 |
-
const observer = new MutationObserver(() => {
|
| 1417 |
-
output.classList.add('streaming');
|
| 1418 |
-
clearTimeout(streamTimer);
|
| 1419 |
-
streamTimer = setTimeout(() => {
|
| 1420 |
-
output.classList.remove('streaming');
|
| 1421 |
-
}, 1200);
|
| 1422 |
-
});
|
| 1423 |
-
observer.observe(output, { childList: true, subtree: true, characterData: true });
|
| 1424 |
-
};
|
| 1425 |
-
|
| 1426 |
-
// Ripple effect on all buttons
|
| 1427 |
-
const attachRipple = () => {
|
| 1428 |
-
document.querySelectorAll('button').forEach((btn) => {
|
| 1429 |
-
if (btn.dataset.rippleAttached) return;
|
| 1430 |
-
btn.dataset.rippleAttached = '1';
|
| 1431 |
-
btn.style.position = 'relative';
|
| 1432 |
-
btn.style.overflow = 'hidden';
|
| 1433 |
-
});
|
| 1434 |
-
};
|
| 1435 |
-
|
| 1436 |
-
// Smooth auto-scroll for output
|
| 1437 |
-
const attachAutoScroll = () => {
|
| 1438 |
-
const output = document.querySelector('#coding-output');
|
| 1439 |
-
if (!output || output.dataset.scrollAttached) return;
|
| 1440 |
-
output.dataset.scrollAttached = '1';
|
| 1441 |
-
const observer = new MutationObserver(() => {
|
| 1442 |
-
const nearBottom = output.scrollHeight - output.scrollTop - output.clientHeight < 200;
|
| 1443 |
-
if (nearBottom) {
|
| 1444 |
-
output.scrollTop = output.scrollHeight;
|
| 1445 |
-
}
|
| 1446 |
-
});
|
| 1447 |
-
observer.observe(output, { childList: true, subtree: true, characterData: true });
|
| 1448 |
-
};
|
| 1449 |
-
|
| 1450 |
-
// Apply on load
|
| 1451 |
-
attachCursor();
|
| 1452 |
-
attachRipple();
|
| 1453 |
-
attachAutoScroll();
|
| 1454 |
-
|
| 1455 |
-
// Re-apply on Gradio re-renders
|
| 1456 |
-
const globalObserver = new MutationObserver(() => {
|
| 1457 |
-
attachCursor();
|
| 1458 |
-
attachRipple();
|
| 1459 |
-
attachAutoScroll();
|
| 1460 |
-
});
|
| 1461 |
-
globalObserver.observe(document.body, { childList: true, subtree: true });
|
| 1462 |
-
|
| 1463 |
-
// Console signature
|
| 1464 |
-
console.log('%c⚡ ARISE AI STUDIO', 'color:#8b5cf6;font-size:20px;font-weight:bold;text-shadow:0 0 10px #8b5cf6;');
|
| 1465 |
-
console.log('%cPremium AI Workspace Loaded', 'color:#22d3ee;font-size:12px;');
|
| 1466 |
}
|
| 1467 |
"""
|
| 1468 |
|
| 1469 |
# =========================================================
|
| 1470 |
-
#
|
| 1471 |
# =========================================================
|
| 1472 |
|
| 1473 |
-
|
| 1474 |
-
<div id="main-header">
|
| 1475 |
-
<div style="
|
| 1476 |
-
font-size: 12px;
|
| 1477 |
-
color: #83eaff;
|
| 1478 |
-
letter-spacing: 4px;
|
| 1479 |
-
font-weight: 800;
|
| 1480 |
-
margin-bottom: 14px;
|
| 1481 |
-
text-shadow: 0 0 20px #22d3ee;
|
| 1482 |
-
">
|
| 1483 |
-
✦ NEXT GENERATION ARTIFICIAL INTELLIGENCE ✦
|
| 1484 |
-
</div>
|
| 1485 |
-
|
| 1486 |
-
<div class="hero-title">⚡ ARISE AI STUDIO</div>
|
| 1487 |
-
|
| 1488 |
-
<div class="hero-subtitle">
|
| 1489 |
-
CREATE · TRANSFORM · CODE · INNOVATE
|
| 1490 |
-
</div>
|
| 1491 |
-
|
| 1492 |
-
<div class="hero-badges" style="
|
| 1493 |
-
display: flex;
|
| 1494 |
-
justify-content: center;
|
| 1495 |
-
flex-wrap: wrap;
|
| 1496 |
-
gap: 10px;
|
| 1497 |
-
margin-top: 24px;
|
| 1498 |
-
">
|
| 1499 |
-
<span>🎨 AI Art</span>
|
| 1500 |
-
<span>🖼 Image Transform</span>
|
| 1501 |
-
<span>💻 AI Coding</span>
|
| 1502 |
-
<span>⚡ Live Stream</span>
|
| 1503 |
-
</div>
|
| 1504 |
-
</div>
|
| 1505 |
-
"""
|
| 1506 |
-
|
| 1507 |
-
# =========================================================
|
| 1508 |
-
# GRADIO APP
|
| 1509 |
-
# =========================================================
|
| 1510 |
-
|
| 1511 |
-
with gr.Blocks(title=APP_NAME) as demo:
|
| 1512 |
-
|
| 1513 |
conversation_state = gr.State(None)
|
| 1514 |
job_state = gr.State(None)
|
| 1515 |
-
|
| 1516 |
-
gr.HTML(HEADER)
|
| 1517 |
|
| 1518 |
with gr.Row():
|
| 1519 |
-
|
| 1520 |
-
gr.
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
|
| 1524 |
-
|
| 1525 |
-
|
| 1526 |
-
|
| 1527 |
-
|
| 1528 |
-
|
| 1529 |
-
gr.Markdown("""
|
| 1530 |
-
<div style="text-align:center;color:#9ba9c5;padding:12px;font-size:13px;letter-spacing:1px">
|
| 1531 |
-
✦ PREMIUM AI WORKSPACE · OPEN MODELS · LIVE GENERATION ✦
|
| 1532 |
-
</div>
|
| 1533 |
-
""")
|
| 1534 |
-
|
| 1535 |
-
with gr.Tabs():
|
| 1536 |
-
|
| 1537 |
-
# --- TEXT TO IMAGE ---
|
| 1538 |
-
with gr.Tab("🎨 Text to Image"):
|
| 1539 |
-
gr.Markdown("## 🎨 Create Images with AI")
|
| 1540 |
-
|
| 1541 |
-
image_model = gr.Dropdown(
|
| 1542 |
-
choices=list(IMAGE_MODELS.keys()),
|
| 1543 |
-
value="SDXL Turbo",
|
| 1544 |
-
label="Select Image Model",
|
| 1545 |
-
)
|
| 1546 |
-
image_prompt = gr.Textbox(
|
| 1547 |
-
label="Image Prompt",
|
| 1548 |
-
placeholder="Describe your image in detail...",
|
| 1549 |
-
lines=4,
|
| 1550 |
-
)
|
| 1551 |
-
negative_prompt = gr.Textbox(label="Negative Prompt", lines=2)
|
| 1552 |
-
|
| 1553 |
-
with gr.Row():
|
| 1554 |
-
width = gr.Slider(256, 768, value=512, step=64, label="Image Width")
|
| 1555 |
-
height = gr.Slider(256, 768, value=512, step=64, label="Image Height")
|
| 1556 |
-
|
| 1557 |
-
steps = gr.Slider(1, 30, value=4, step=1, label="Inference Steps")
|
| 1558 |
-
|
| 1559 |
-
with gr.Row():
|
| 1560 |
-
seed = gr.Number(value=0, precision=0, label="Seed")
|
| 1561 |
-
random_seed = gr.Checkbox(value=True, label="Random Seed")
|
| 1562 |
-
|
| 1563 |
-
generate_button = gr.Button("✨ Generate Image", variant="primary")
|
| 1564 |
-
image_output = gr.Image(label="Generated Artwork", type="pil", height=400)
|
| 1565 |
-
seed_output = gr.Number(label="Used Seed", precision=0)
|
| 1566 |
-
|
| 1567 |
-
generate_button.click(
|
| 1568 |
-
fn=generate_image,
|
| 1569 |
-
inputs=[image_prompt, negative_prompt, image_model, width, height, steps, seed, random_seed],
|
| 1570 |
-
outputs=[image_output, seed_output],
|
| 1571 |
-
)
|
| 1572 |
-
|
| 1573 |
-
# --- IMAGE TO IMAGE ---
|
| 1574 |
-
with gr.Tab("🖼 Image to Image"):
|
| 1575 |
-
gr.Markdown("## 🖼 Transform Your Images")
|
| 1576 |
-
|
| 1577 |
-
input_image = gr.Image(label="Upload Original Image", type="pil", height=300)
|
| 1578 |
-
img2img_model = gr.Dropdown(
|
| 1579 |
-
choices=list(IMAGE_TO_IMAGE_MODELS.keys()),
|
| 1580 |
-
value="Stable Diffusion 1.5 Img2Img",
|
| 1581 |
-
label="Image-to-Image Model",
|
| 1582 |
-
)
|
| 1583 |
-
img2img_prompt = gr.Textbox(label="Transformation Prompt",
|
| 1584 |
-
placeholder="Describe the new image style...", lines=4)
|
| 1585 |
-
img2img_negative = gr.Textbox(label="Negative Prompt", lines=2)
|
| 1586 |
-
strength = gr.Slider(0.05, 0.95, value=0.70, step=0.05, label="Transformation Strength")
|
| 1587 |
-
|
| 1588 |
-
with gr.Row():
|
| 1589 |
-
img2img_steps = gr.Slider(1, 30, value=25, step=1, label="Inference Steps")
|
| 1590 |
-
img2img_guidance = gr.Slider(1, 15, value=7.5, step=0.5, label="Guidance Scale")
|
| 1591 |
-
|
| 1592 |
-
with gr.Row():
|
| 1593 |
-
img2img_seed = gr.Number(value=0, precision=0, label="Seed")
|
| 1594 |
-
img2img_random = gr.Checkbox(value=True, label="Random Seed")
|
| 1595 |
-
|
| 1596 |
-
img2img_button = gr.Button("🪄 Transform Image", variant="primary")
|
| 1597 |
-
img2img_output = gr.Image(label="Transformed Image", type="pil", height=400)
|
| 1598 |
-
img2img_seed_output = gr.Number(label="Used Seed", precision=0)
|
| 1599 |
-
|
| 1600 |
-
img2img_button.click(
|
| 1601 |
-
fn=generate_image_to_image,
|
| 1602 |
-
inputs=[input_image, img2img_prompt, img2img_negative, img2img_model,
|
| 1603 |
-
strength, img2img_steps, img2img_guidance, img2img_seed, img2img_random],
|
| 1604 |
-
outputs=[img2img_output, img2img_seed_output],
|
| 1605 |
-
)
|
| 1606 |
-
|
| 1607 |
-
# --- AI CODING ---
|
| 1608 |
-
with gr.Tab("💻 AI Coding"):
|
| 1609 |
-
gr.Markdown("""
|
| 1610 |
-
## 💻 ARISE AI Coding Workspace
|
| 1611 |
-
Upload an existing project, describe your changes,
|
| 1612 |
-
and download the updated project.
|
| 1613 |
-
""")
|
| 1614 |
-
|
| 1615 |
-
code_model = gr.Dropdown(
|
| 1616 |
-
choices=list(CODE_MODELS.keys()),
|
| 1617 |
-
value="Qwen Coder 0.5B",
|
| 1618 |
-
label="Select Coding Model",
|
| 1619 |
-
)
|
| 1620 |
-
project_upload = gr.File(
|
| 1621 |
-
label="+ Upload ZIP, Images or Project Files",
|
| 1622 |
-
file_count="multiple",
|
| 1623 |
-
type="filepath",
|
| 1624 |
-
)
|
| 1625 |
-
code_prompt = gr.Textbox(
|
| 1626 |
-
label="Your Coding Request",
|
| 1627 |
-
placeholder="Example: Change the app theme and update the home screen...",
|
| 1628 |
-
lines=5,
|
| 1629 |
-
)
|
| 1630 |
-
|
| 1631 |
-
with gr.Row():
|
| 1632 |
-
max_tokens = gr.Slider(128, 2048, value=768, step=128, label="Maximum Output Tokens")
|
| 1633 |
temperature = gr.Slider(0.1, 1.0, value=0.3, step=0.1, label="Temperature")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1634 |
|
| 1635 |
-
|
| 1636 |
-
|
| 1637 |
-
|
| 1638 |
-
|
| 1639 |
-
|
| 1640 |
-
|
| 1641 |
-
|
| 1642 |
-
|
| 1643 |
-
|
| 1644 |
-
|
| 1645 |
-
|
| 1646 |
-
|
| 1647 |
-
|
| 1648 |
-
|
| 1649 |
-
|
| 1650 |
-
|
| 1651 |
-
|
| 1652 |
-
|
| 1653 |
-
|
| 1654 |
-
|
| 1655 |
-
|
| 1656 |
-
|
| 1657 |
-
|
| 1658 |
-
|
| 1659 |
-
|
| 1660 |
-
|
| 1661 |
-
|
| 1662 |
-
|
| 1663 |
-
|
| 1664 |
-
|
| 1665 |
-
|
| 1666 |
-
|
| 1667 |
-
|
| 1668 |
-
|
| 1669 |
-
|
| 1670 |
-
|
| 1671 |
-
|
| 1672 |
-
|
| 1673 |
-
|
| 1674 |
-
|
| 1675 |
-
|
| 1676 |
-
|
| 1677 |
-
|
| 1678 |
-
|
| 1679 |
-
|
| 1680 |
-
|
| 1681 |
-
|
| 1682 |
-
|
| 1683 |
-
|
| 1684 |
-
|
| 1685 |
-
|
| 1686 |
-
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
|
| 1690 |
-
|
| 1691 |
-
|
| 1692 |
-
|
| 1693 |
-
|
| 1694 |
-
|
| 1695 |
-
|
| 1696 |
-
|
| 1697 |
-
|
| 1698 |
-
|
| 1699 |
-
|
| 1700 |
-
|
| 1701 |
-
def delete_all(request: gr.Request):
|
| 1702 |
-
session_id = request.session_hash if request else "default"
|
| 1703 |
-
choices = get_conversations(session_id)
|
| 1704 |
-
ids = [value for _, value in choices]
|
| 1705 |
-
delete_conversations(session_id, ids)
|
| 1706 |
-
return (gr.Dropdown(choices=[], value=None), "All history deleted.")
|
| 1707 |
-
|
| 1708 |
-
delete_all_history_button.click(
|
| 1709 |
-
fn=delete_all,
|
| 1710 |
-
outputs=[history_dropdown, history_status],
|
| 1711 |
-
)
|
| 1712 |
-
resume_button.click(
|
| 1713 |
-
fn=resume_job,
|
| 1714 |
-
inputs=job_state,
|
| 1715 |
-
outputs=[history_output, history_status, project_zip_download, single_file_download],
|
| 1716 |
-
)
|
| 1717 |
|
| 1718 |
-
# --- FOOTER ---
|
| 1719 |
-
gr.HTML(f"""
|
| 1720 |
-
<div id="footer">
|
| 1721 |
-
<div style="font-size:22px;font-weight:800;
|
| 1722 |
-
background:linear-gradient(90deg,#c7b7ff,#67e8f9);
|
| 1723 |
-
-webkit-background-clip:text;-webkit-text-fill-color:transparent;
|
| 1724 |
-
margin-bottom:8px;">
|
| 1725 |
-
⚡ ARISE AI STUDIO
|
| 1726 |
-
</div>
|
| 1727 |
-
<div style="color:#a5b4fc;font-size:13px;letter-spacing:1px">
|
| 1728 |
-
Premium AI Workspace
|
| 1729 |
-
</div>
|
| 1730 |
-
<div style="margin-top:10px;font-size:12px">
|
| 1731 |
-
Developer: <a href="{DEVELOPER_TELEGRAM}" target="_blank">@hardhackar009</a>
|
| 1732 |
-
</div>
|
| 1733 |
-
<div style="margin-top:8px;font-size:11px;color:#64748b">
|
| 1734 |
-
Powered by Open Source Models and Hugging Face
|
| 1735 |
-
</div>
|
| 1736 |
-
</div>
|
| 1737 |
-
""")
|
| 1738 |
-
|
| 1739 |
-
# Attach premium JS on load
|
| 1740 |
-
demo.load(fn=None, js=PREMIUM_JS)
|
| 1741 |
|
| 1742 |
# =========================================================
|
| 1743 |
-
# LAUNCH
|
| 1744 |
# =========================================================
|
| 1745 |
|
| 1746 |
if __name__ == "__main__":
|
|
@@ -1748,12 +1126,9 @@ if __name__ == "__main__":
|
|
| 1748 |
default_concurrency_limit=1,
|
| 1749 |
max_size=20,
|
| 1750 |
).launch(
|
| 1751 |
-
theme=gr.themes.Soft(
|
| 1752 |
-
primary_hue="violet",
|
| 1753 |
-
secondary_hue="cyan",
|
| 1754 |
-
neutral_hue="slate",
|
| 1755 |
-
),
|
| 1756 |
css=CSS,
|
|
|
|
| 1757 |
show_error=True,
|
| 1758 |
share=False,
|
| 1759 |
)
|
|
|
|
| 570 |
}, ensure_ascii=False, indent=2), encoding="utf-8")
|
| 571 |
return "\n".join(messages)
|
| 572 |
|
| 573 |
+
# FIXED REGEX BUG: Changed (.?) to (.*?) and fixed <> brackets
|
| 574 |
FILE_BLOCK_PATTERN = re.compile(
|
| 575 |
r"<<<FILE:\s*(.*?)>>>\s*(.*?)\s*<<<END FILE>>>",
|
| 576 |
re.DOTALL | re.IGNORECASE,
|
|
|
|
| 619 |
project_dir = Path(project_dir)
|
| 620 |
html_files = list(project_dir.rglob("index.html")) or list(project_dir.rglob("*.html"))
|
| 621 |
if not html_files:
|
| 622 |
+
return "<div style='padding:25px;color:#aaa'>No HTML file found in this project.</div>"
|
| 623 |
html_file = html_files[0]
|
| 624 |
try:
|
| 625 |
html = html_file.read_text(encoding="utf-8", errors="replace")
|
|
|
|
| 643 |
|
| 644 |
return f"""
|
| 645 |
<iframe sandbox="allow-scripts allow-forms"
|
| 646 |
+
style="width:100%;height:650px;border:none;border-radius:10px;background:white;"
|
| 647 |
srcdoc="{html.replace('&', '&').replace('"', '"').replace('<', '<').replace('>', '>')}"
|
| 648 |
></iframe>
|
| 649 |
"""
|
| 650 |
except Exception as error:
|
| 651 |
return f"<div style='padding:20px;color:#ff9999'>Preview error: {error}</div>"
|
| 652 |
|
| 653 |
+
# FIXED INIT BUG
|
| 654 |
class StopCriteria(StoppingCriteria):
|
| 655 |
def __init__(self, event):
|
| 656 |
self.event = event
|
|
|
|
| 750 |
final_response = response
|
| 751 |
if changed_files:
|
| 752 |
file_status = "\n".join(
|
| 753 |
+
f"- ✅ `{name}` — Edited" for name in changed_files
|
| 754 |
)
|
| 755 |
final_response += "\n\n---\n### Project File Updates\n" + file_status
|
| 756 |
|
|
|
|
| 796 |
job_threads[job_id] = worker
|
| 797 |
worker.start()
|
| 798 |
|
| 799 |
+
yield ("⏳ ARISE AI is analyzing...", conversation_id, upload_status or "Job started.", None, None, job_id)
|
|
|
|
| 800 |
|
| 801 |
previous_response = ""
|
| 802 |
while True:
|
|
|
|
| 833 |
return
|
| 834 |
time.sleep(1)
|
| 835 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 836 |
def stop_job(job_id):
|
| 837 |
if not job_id:
|
| 838 |
return "No active job."
|
|
|
|
| 843 |
return "⏹ Stop requested."
|
| 844 |
return "No running job found."
|
| 845 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 846 |
def refresh_history(request: gr.Request):
|
| 847 |
session_id = request.session_hash if request else "default"
|
| 848 |
return gr.Dropdown(choices=get_conversations(session_id), value=None)
|
| 849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 850 |
def preview_project(conversation_id):
|
| 851 |
if not conversation_id:
|
| 852 |
+
return "<p style='color:#aaa;'>No project selected.</p>"
|
| 853 |
return make_html_preview(get_project_dir(conversation_id))
|
| 854 |
|
| 855 |
+
|
| 856 |
# =========================================================
|
| 857 |
+
# CHATGPT UI CSS
|
| 858 |
# =========================================================
|
| 859 |
|
| 860 |
+
CSS = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
body, .gradio-container {
|
| 862 |
+
background-color: #212121 !important;
|
| 863 |
+
color: #ececec !important;
|
| 864 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
|
| 865 |
+
}
|
| 866 |
+
#sidebar {
|
| 867 |
+
background-color: #171717 !important;
|
| 868 |
+
padding: 10px;
|
| 869 |
+
border-right: 1px solid #2f2f2f;
|
| 870 |
+
height: 100vh;
|
| 871 |
+
overflow-y: auto;
|
| 872 |
+
}
|
| 873 |
+
#sidebar .gr-button {
|
| 874 |
+
background-color: transparent !important;
|
| 875 |
+
border: 1px solid #444 !important;
|
| 876 |
+
color: #ececec !important;
|
| 877 |
+
text-align: left !important;
|
| 878 |
+
justify-content: flex-start !important;
|
| 879 |
+
}
|
| 880 |
+
#sidebar .gr-button:hover {
|
| 881 |
+
background-color: #2f2f2f !important;
|
| 882 |
+
}
|
| 883 |
+
#main-chat {
|
| 884 |
+
background-color: #212121 !important;
|
| 885 |
+
height: 100vh;
|
| 886 |
+
display: flex;
|
| 887 |
+
flex-direction: column;
|
| 888 |
+
padding: 0 !important;
|
| 889 |
+
}
|
| 890 |
+
#chat-container {
|
| 891 |
+
flex-grow: 1;
|
| 892 |
+
overflow-y: auto;
|
| 893 |
+
padding: 20px;
|
| 894 |
+
max-width: 800px;
|
| 895 |
+
margin: 0 auto;
|
| 896 |
+
width: 100%;
|
| 897 |
+
}
|
| 898 |
+
#input-container {
|
| 899 |
+
padding: 20px;
|
| 900 |
+
max-width: 800px;
|
| 901 |
+
margin: 0 auto;
|
| 902 |
+
width: 100%;
|
| 903 |
+
}
|
| 904 |
+
textarea {
|
| 905 |
+
background-color: #2f2f2f !important;
|
| 906 |
+
border: 1px solid #444 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 907 |
border-radius: 12px !important;
|
| 908 |
+
color: #ececec !important;
|
| 909 |
+
padding: 12px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 910 |
}
|
| 911 |
+
textarea:focus {
|
| 912 |
+
border-color: #10a37f !important;
|
| 913 |
+
box-shadow: 0 0 0 1px #10a37f !important;
|
|
|
|
| 914 |
}
|
|
|
|
| 915 |
.primary {
|
| 916 |
+
background-color: #10a37f !important;
|
|
|
|
| 917 |
color: white !important;
|
| 918 |
+
border: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 919 |
}
|
|
|
|
| 920 |
.primary:hover {
|
| 921 |
+
background-color: #1a7f64 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 922 |
}
|
| 923 |
+
.message-wrap .message {
|
| 924 |
+
border-radius: 8px !important;
|
| 925 |
+
padding: 12px 16px !important;
|
| 926 |
+
max-width: 85% !important;
|
| 927 |
+
margin-bottom: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 928 |
}
|
| 929 |
+
.user-message {
|
| 930 |
+
background-color: #2f2f2f !important;
|
| 931 |
+
align-self: flex-end !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 932 |
}
|
| 933 |
+
.bot-message {
|
| 934 |
+
background-color: #212121 !important;
|
| 935 |
+
border: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
}
|
| 937 |
+
.bot-message p {
|
| 938 |
+
margin: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 939 |
}
|
| 940 |
"""
|
| 941 |
|
| 942 |
# =========================================================
|
| 943 |
+
# GRADIO APP (CHATGPT LAYOUT)
|
| 944 |
# =========================================================
|
| 945 |
|
| 946 |
+
with gr.Blocks(title=APP_NAME, css=CSS) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 947 |
conversation_state = gr.State(None)
|
| 948 |
job_state = gr.State(None)
|
| 949 |
+
chat_history_state = gr.State([])
|
|
|
|
| 950 |
|
| 951 |
with gr.Row():
|
| 952 |
+
# LEFT SIDEBAR
|
| 953 |
+
with gr.Column(scale=1, elem_id="sidebar"):
|
| 954 |
+
gr.Markdown(f"### ⚡ {APP_NAME}")
|
| 955 |
+
|
| 956 |
+
new_chat_btn = gr.Button("➕ New Chat", variant="secondary")
|
| 957 |
+
|
| 958 |
+
with gr.Accordion("⚙️ Settings", open=False):
|
| 959 |
+
code_model = gr.Dropdown(choices=list(CODE_MODELS.keys()), value="Qwen Coder 0.5B", label="Model")
|
| 960 |
+
max_tokens = gr.Slider(128, 2048, value=768, step=128, label="Max Tokens")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 961 |
temperature = gr.Slider(0.1, 1.0, value=0.3, step=0.1, label="Temperature")
|
| 962 |
+
|
| 963 |
+
with gr.Accordion("📁 Project Upload", open=False):
|
| 964 |
+
project_upload = gr.File(label="Upload Files/ZIP", file_count="multiple", type="filepath")
|
| 965 |
+
preview_button = gr.Button("🌐 Preview HTML Project")
|
| 966 |
+
|
| 967 |
+
history_dropdown = gr.Dropdown(choices=[], label="History", interactive=True)
|
| 968 |
+
refresh_history_button = gr.Button("🔄 Refresh History", size="sm")
|
| 969 |
+
|
| 970 |
+
gr.Markdown(f"[Developer ↗]({DEVELOPER_TELEGRAM})", elem_classes="footer-link")
|
| 971 |
+
|
| 972 |
+
# RIGHT MAIN AREA
|
| 973 |
+
with gr.Column(scale=4, elem_id="main-chat"):
|
| 974 |
+
with gr.Tabs():
|
| 975 |
+
# TAB 1: CHAT & CODE
|
| 976 |
+
with gr.Tab("💬 Chat & Code"):
|
| 977 |
+
with gr.Column(elem_id="chat-container"):
|
| 978 |
+
chatbot = gr.Chatbot(
|
| 979 |
+
value=[{"role": "assistant", "content": "Hello! I am ARISE AI. How can I help you with your code today?"}],
|
| 980 |
+
type="messages",
|
| 981 |
+
height=600,
|
| 982 |
+
show_label=False,
|
| 983 |
+
show_copy_button=True,
|
| 984 |
+
elem_id="chatbot-ui"
|
| 985 |
+
)
|
| 986 |
+
with gr.Column(elem_id="input-container"):
|
| 987 |
+
with gr.Row():
|
| 988 |
+
code_prompt = gr.Textbox(
|
| 989 |
+
show_label=False,
|
| 990 |
+
placeholder="Message ARISE AI...",
|
| 991 |
+
lines=1,
|
| 992 |
+
max_lines=5,
|
| 993 |
+
scale=9
|
| 994 |
+
)
|
| 995 |
+
generate_code = gr.Button("🚀", variant="primary", scale=1)
|
| 996 |
+
with gr.Row():
|
| 997 |
+
stop_button = gr.Button("⏹ Stop Generation", variant="stop", size="sm")
|
| 998 |
+
coding_status = gr.Markdown("Ready.", elem_id="coding-status")
|
| 999 |
+
|
| 1000 |
+
# Hidden Download Components
|
| 1001 |
+
with gr.Row(visible=True):
|
| 1002 |
+
project_zip_download = gr.File(label="Download Full Project ZIP", interactive=False)
|
| 1003 |
+
single_file_download = gr.File(label="Download Last Edited File", interactive=False)
|
| 1004 |
+
|
| 1005 |
+
# TAB 2: TEXT TO IMAGE
|
| 1006 |
+
with gr.Tab("🎨 Text to Image"):
|
| 1007 |
+
with gr.Column(elem_id="chat-container"):
|
| 1008 |
+
image_model = gr.Dropdown(choices=list(IMAGE_MODELS.keys()), value="SDXL Turbo", label="Model")
|
| 1009 |
+
image_prompt = gr.Textbox(label="Prompt", placeholder="Describe your image...", lines=3)
|
| 1010 |
+
negative_prompt = gr.Textbox(label="Negative Prompt", lines=2)
|
| 1011 |
+
with gr.Row():
|
| 1012 |
+
width = gr.Slider(256, 768, value=512, step=64, label="Width")
|
| 1013 |
+
height = gr.Slider(256, 768, value=512, step=64, label="Height")
|
| 1014 |
+
with gr.Row():
|
| 1015 |
+
steps = gr.Slider(1, 30, value=4, step=1, label="Steps")
|
| 1016 |
+
seed = gr.Number(value=0, precision=0, label="Seed")
|
| 1017 |
+
random_seed = gr.Checkbox(value=True, label="Random")
|
| 1018 |
+
generate_button = gr.Button("✨ Generate", variant="primary")
|
| 1019 |
+
image_output = gr.Image(label="Result", type="pil")
|
| 1020 |
+
seed_output = gr.Number(label="Used Seed", precision=0)
|
| 1021 |
+
|
| 1022 |
+
# TAB 3: IMAGE TO IMAGE
|
| 1023 |
+
with gr.Tab("🖼 Image to Image"):
|
| 1024 |
+
with gr.Column(elem_id="chat-container"):
|
| 1025 |
+
input_image = gr.Image(label="Input Image", type="pil", height=300)
|
| 1026 |
+
img2img_model = gr.Dropdown(choices=list(IMAGE_TO_IMAGE_MODELS.keys()), value="Stable Diffusion 1.5 Img2Img", label="Model")
|
| 1027 |
+
img2img_prompt = gr.Textbox(label="Prompt", lines=3)
|
| 1028 |
+
img2img_negative = gr.Textbox(label="Negative Prompt", lines=2)
|
| 1029 |
+
with gr.Row():
|
| 1030 |
+
strength = gr.Slider(0.05, 0.95, value=0.70, step=0.05, label="Strength")
|
| 1031 |
+
img2img_steps = gr.Slider(1, 30, value=25, step=1, label="Steps")
|
| 1032 |
+
with gr.Row():
|
| 1033 |
+
img2img_guidance = gr.Slider(1, 15, value=7.5, step=0.5, label="Guidance")
|
| 1034 |
+
img2img_seed = gr.Number(value=0, precision=0, label="Seed")
|
| 1035 |
+
img2img_button = gr.Button("🪄 Transform", variant="primary")
|
| 1036 |
+
img2img_output = gr.Image(label="Result", type="pil")
|
| 1037 |
+
img2img_seed_output = gr.Number(label="Used Seed", precision=0)
|
| 1038 |
+
|
| 1039 |
+
# TAB 4: HTML PREVIEW
|
| 1040 |
+
with gr.Tab("🌐 Preview"):
|
| 1041 |
+
html_preview = gr.HTML(value="<div style='padding:15px;color:#aaa'>Preview will appear here. Click 'Preview HTML' in the sidebar.</div>")
|
| 1042 |
+
|
| 1043 |
+
# =====================================================
|
| 1044 |
+
# EVENT HANDLERS
|
| 1045 |
+
# =====================================================
|
| 1046 |
+
|
| 1047 |
+
# Chat logic
|
| 1048 |
+
def chat_and_code(prompt, model_name, max_tokens, temperature, uploaded_files, conversation_id, chat_history, request: gr.Request):
|
| 1049 |
+
if not prompt or not prompt.strip():
|
| 1050 |
+
yield chat_history, conversation_id, "Waiting for prompt.", None, None, None
|
| 1051 |
+
return
|
| 1052 |
|
| 1053 |
+
new_history = chat_history + [{"role": "user", "content": prompt}]
|
| 1054 |
+
yield new_history, conversation_id, "⏳ Analyzing...", None, None, None
|
| 1055 |
+
|
| 1056 |
+
for output in coding_assistant(prompt, model_name, max_tokens, temperature, uploaded_files, conversation_id, request):
|
| 1057 |
+
response_text = output[0]
|
| 1058 |
+
status = output[2]
|
| 1059 |
+
zip_file = output[3]
|
| 1060 |
+
single_file = output[4]
|
| 1061 |
+
job_id = output[5]
|
| 1062 |
+
|
| 1063 |
+
if new_history[-1]["role"] == "assistant":
|
| 1064 |
+
new_history[-1]["content"] = response_text
|
| 1065 |
+
else:
|
| 1066 |
+
new_history.append({"role": "assistant", "content": response_text})
|
| 1067 |
+
|
| 1068 |
+
yield new_history, conversation_id, status, zip_file, single_file, job_id
|
| 1069 |
+
|
| 1070 |
+
generate_code.click(
|
| 1071 |
+
fn=chat_and_code,
|
| 1072 |
+
inputs=[code_prompt, code_model, max_tokens, temperature, project_upload, conversation_state, chatbot],
|
| 1073 |
+
outputs=[chatbot, conversation_state, coding_status, project_zip_download, single_file_download, job_state],
|
| 1074 |
+
).then(lambda: "", outputs=code_prompt) # Clear input after send
|
| 1075 |
+
|
| 1076 |
+
# History logic
|
| 1077 |
+
def load_history_chat(conversation_id, request: gr.Request):
|
| 1078 |
+
session_id = request.session_hash if request else "default"
|
| 1079 |
+
if not conversation_id:
|
| 1080 |
+
return [{"role": "assistant", "content": "Hello! Select a conversation or start a new one."}], None, "Select a history item.", None
|
| 1081 |
+
conversation = get_conversation(session_id, conversation_id)
|
| 1082 |
+
if not conversation:
|
| 1083 |
+
return [], None, "History not found.", None
|
| 1084 |
+
|
| 1085 |
+
chatbot_history = [{"role": item.get("role", "assistant"), "content": item.get("content", "")} for item in conversation["history"]]
|
| 1086 |
+
active_job = get_active_job(session_id, conversation_id)
|
| 1087 |
+
job_id = active_job["id"] if active_job else None
|
| 1088 |
+
return chatbot_history, conversation_id, f"Loaded: {conversation['title']}", job_id
|
| 1089 |
+
|
| 1090 |
+
history_dropdown.change(
|
| 1091 |
+
fn=load_history_chat,
|
| 1092 |
+
inputs=history_dropdown,
|
| 1093 |
+
outputs=[chatbot, conversation_state, coding_status, job_state],
|
| 1094 |
+
)
|
| 1095 |
+
|
| 1096 |
+
refresh_history_button.click(fn=refresh_history, outputs=history_dropdown)
|
| 1097 |
+
|
| 1098 |
+
# New Chat
|
| 1099 |
+
new_chat_btn.click(
|
| 1100 |
+
fn=lambda: ([{"role": "assistant", "content": "Hello! I am ARISE AI. How can I help you with your code today?"}], None, "Ready for a new conversation.", None),
|
| 1101 |
+
outputs=[chatbot, conversation_state, coding_status, job_state]
|
| 1102 |
+
)
|
| 1103 |
+
|
| 1104 |
+
stop_button.click(fn=stop_job, inputs=job_state, outputs=coding_status)
|
| 1105 |
+
preview_button.click(fn=preview_project, inputs=conversation_state, outputs=html_preview)
|
| 1106 |
+
|
| 1107 |
+
# Image Gen events
|
| 1108 |
+
generate_button.click(
|
| 1109 |
+
fn=generate_image,
|
| 1110 |
+
inputs=[image_prompt, negative_prompt, image_model, width, height, steps, seed, random_seed],
|
| 1111 |
+
outputs=[image_output, seed_output],
|
| 1112 |
+
)
|
| 1113 |
+
img2img_button.click(
|
| 1114 |
+
fn=generate_image_to_image,
|
| 1115 |
+
inputs=[input_image, img2img_prompt, img2img_negative, img2img_model, strength, img2img_steps, img2img_guidance, img2img_seed, random_seed],
|
| 1116 |
+
outputs=[img2img_output, img2img_seed_output],
|
| 1117 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1119 |
|
| 1120 |
# =========================================================
|
| 1121 |
+
# LAUNCH (WITH FIXES)
|
| 1122 |
# =========================================================
|
| 1123 |
|
| 1124 |
if __name__ == "__main__":
|
|
|
|
| 1126 |
default_concurrency_limit=1,
|
| 1127 |
max_size=20,
|
| 1128 |
).launch(
|
| 1129 |
+
theme=gr.themes.Soft(),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1130 |
css=CSS,
|
| 1131 |
+
allowed_paths=[str(DATA_DIR.resolve())], # 👈 FIX: Allowed Paths for Download Error
|
| 1132 |
show_error=True,
|
| 1133 |
share=False,
|
| 1134 |
)
|