Spaces:
Running
Running
GitHub Action
commited on
Commit
·
5442d39
1
Parent(s):
a4e9ea3
Sync ling-space changes from GitHub commit 8b86524
Browse files- tab_code.py +24 -14
tab_code.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import logging
|
| 3 |
from config import CHAT_MODEL_SPECS, LING_1T, CODE_FRAMEWORK_SPECS, STATIC_PAGE
|
|
@@ -60,6 +61,14 @@ def log_js_error(error_text, chatbot_history):
|
|
| 60 |
return chatbot_history
|
| 61 |
|
| 62 |
def create_code_tab():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
fullscreen_state = gr.State(False)
|
| 64 |
|
| 65 |
with gr.Row(elem_id="indicator-code-tab"):
|
|
@@ -73,21 +82,22 @@ def create_code_tab():
|
|
| 73 |
model_specs=CHAT_MODEL_SPECS,
|
| 74 |
default_model_constant=LING_1T
|
| 75 |
)
|
|
|
|
| 76 |
prompt_input = gr.Textbox(lines=5, placeholder="例如:创建一个带标题和按钮的简单页面", label="提示词")
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
|
| 92 |
with gr.Column():
|
| 93 |
gr.Markdown("### 示例")
|
|
@@ -169,4 +179,4 @@ def create_code_tab():
|
|
| 169 |
fn=log_js_error,
|
| 170 |
inputs=[js_error_channel, log_chatbot],
|
| 171 |
outputs=log_chatbot
|
| 172 |
-
)
|
|
|
|
| 1 |
+
from tkinter import Label
|
| 2 |
import gradio as gr
|
| 3 |
import logging
|
| 4 |
from config import CHAT_MODEL_SPECS, LING_1T, CODE_FRAMEWORK_SPECS, STATIC_PAGE
|
|
|
|
| 61 |
return chatbot_history
|
| 62 |
|
| 63 |
def create_code_tab():
|
| 64 |
+
# Inject custom CSS to hide components
|
| 65 |
+
gr.HTML("""
|
| 66 |
+
<style>
|
| 67 |
+
.hidden-component {
|
| 68 |
+
display: none;
|
| 69 |
+
}
|
| 70 |
+
</style>
|
| 71 |
+
""")
|
| 72 |
fullscreen_state = gr.State(False)
|
| 73 |
|
| 74 |
with gr.Row(elem_id="indicator-code-tab"):
|
|
|
|
| 82 |
model_specs=CHAT_MODEL_SPECS,
|
| 83 |
default_model_constant=LING_1T
|
| 84 |
)
|
| 85 |
+
|
| 86 |
prompt_input = gr.Textbox(lines=5, placeholder="例如:创建一个带标题和按钮的简单页面", label="提示词")
|
| 87 |
|
| 88 |
+
overall_style_input = gr.Textbox(label="整体风格", placeholder="例如:类似一本羊皮纸的书", lines=2)
|
| 89 |
+
|
| 90 |
+
decoration_input = gr.Textbox(label="装饰风格", placeholder="例如:粗边框,无圆角", lines=2)
|
| 91 |
+
|
| 92 |
+
# Hidden textbox to store the raw palette string for the prompt
|
| 93 |
+
palette_input = gr.Textbox(label="Palette (Raw)", elem_classes="hidden-component")
|
| 94 |
+
|
| 95 |
+
palette_display = gr.HTML(value='<div style="color: #999; font-size: 12px;">(生成风格后展示)</div>',
|
| 96 |
+
container=True,
|
| 97 |
+
label="风格色板",
|
| 98 |
+
show_label=True)
|
| 99 |
+
|
| 100 |
+
generate_style_btn = gr.Button("🎲 随机生成风格", size="sm")
|
| 101 |
|
| 102 |
with gr.Column():
|
| 103 |
gr.Markdown("### 示例")
|
|
|
|
| 179 |
fn=log_js_error,
|
| 180 |
inputs=[js_error_channel, log_chatbot],
|
| 181 |
outputs=log_chatbot
|
| 182 |
+
)
|