Spaces:
Running
on
Zero
Running
on
Zero
feat: Localize UI and add project description
Browse files
app.py
CHANGED
|
@@ -3,13 +3,13 @@ from comp import generate_response
|
|
| 3 |
import re
|
| 4 |
|
| 5 |
# --- Constants ---
|
| 6 |
-
WORKFLOW_SYSTEM_PROMPT = """
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
[
|
| 13 |
"""
|
| 14 |
|
| 15 |
# --- Helper Functions ---
|
|
@@ -17,35 +17,36 @@ def parse_workflow_response(response):
|
|
| 17 |
intent_match = re.search(r"\*\*Intent\*\*:\s*(.*)", response, re.IGNORECASE)
|
| 18 |
steps_match = re.search(r"\*\*Steps\*\*:\s*(.*)", response, re.DOTALL | re.IGNORECASE)
|
| 19 |
|
| 20 |
-
intent = intent_match.group(1).strip() if intent_match else "
|
| 21 |
-
steps = steps_match.group(1).strip() if steps_match else "
|
| 22 |
|
| 23 |
return intent, steps
|
| 24 |
|
| 25 |
# --- Gradio UI ---
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
-
gr.Markdown("# Ling
|
|
|
|
| 29 |
|
| 30 |
with gr.Row():
|
| 31 |
with gr.Column(scale=2):
|
| 32 |
-
gr.Markdown("##
|
| 33 |
-
chat_chatbot = gr.Chatbot(label="
|
| 34 |
with gr.Row():
|
| 35 |
chat_msg = gr.Textbox(
|
| 36 |
-
label="
|
| 37 |
scale=4,
|
| 38 |
)
|
| 39 |
-
send_btn = gr.Button("
|
| 40 |
|
| 41 |
with gr.Column(scale=1):
|
| 42 |
-
gr.Markdown("##
|
| 43 |
-
intent_textbox = gr.Textbox(label="
|
| 44 |
steps_textbox = gr.Textbox(
|
| 45 |
-
label="
|
| 46 |
)
|
| 47 |
|
| 48 |
-
chat_clear = gr.ClearButton([chat_msg, chat_chatbot, intent_textbox, steps_textbox])
|
| 49 |
|
| 50 |
def user(user_message, history):
|
| 51 |
return "", history + [[user_message, None]]
|
|
|
|
| 3 |
import re
|
| 4 |
|
| 5 |
# --- Constants ---
|
| 6 |
+
WORKFLOW_SYSTEM_PROMPT = """你是一位分析对话和提取用户工作流的专家。
|
| 7 |
+
根据提供的聊天记录,识别用户的核心目标或意图。
|
| 8 |
+
然后,将对话分解为一系列可执行的步骤,以实现该目标。
|
| 9 |
+
输出应分为两部分,并明确分隔:
|
| 10 |
+
**意图**: [用户目标的简洁描述]
|
| 11 |
+
**步骤**:
|
| 12 |
+
[步骤的编号列表]
|
| 13 |
"""
|
| 14 |
|
| 15 |
# --- Helper Functions ---
|
|
|
|
| 17 |
intent_match = re.search(r"\*\*Intent\*\*:\s*(.*)", response, re.IGNORECASE)
|
| 18 |
steps_match = re.search(r"\*\*Steps\*\*:\s*(.*)", response, re.DOTALL | re.IGNORECASE)
|
| 19 |
|
| 20 |
+
intent = intent_match.group(1).strip() if intent_match else "未能识别意图。"
|
| 21 |
+
steps = steps_match.group(1).strip() if steps_match else "未能识别步骤。"
|
| 22 |
|
| 23 |
return intent, steps
|
| 24 |
|
| 25 |
# --- Gradio UI ---
|
| 26 |
|
| 27 |
with gr.Blocks() as demo:
|
| 28 |
+
gr.Markdown("# Ling 灵动工作台")
|
| 29 |
+
gr.Markdown("这是一个对 Zero GPU 使用 Ring-mini-2.0 模型能力的验证项目。它会和用户聊天,并实时提取其中潜在有用的工作流。在合适的时机,它会告知用户,并提醒这些工作流未来可以被复用。")
|
| 30 |
|
| 31 |
with gr.Row():
|
| 32 |
with gr.Column(scale=2):
|
| 33 |
+
gr.Markdown("## 聊天")
|
| 34 |
+
chat_chatbot = gr.Chatbot(label="聊天", bubble_full_width=False)
|
| 35 |
with gr.Row():
|
| 36 |
chat_msg = gr.Textbox(
|
| 37 |
+
label="请输入你的消息",
|
| 38 |
scale=4,
|
| 39 |
)
|
| 40 |
+
send_btn = gr.Button("发送", scale=1)
|
| 41 |
|
| 42 |
with gr.Column(scale=1):
|
| 43 |
+
gr.Markdown("## 工作流提取")
|
| 44 |
+
intent_textbox = gr.Textbox(label="任务意图", interactive=False)
|
| 45 |
steps_textbox = gr.Textbox(
|
| 46 |
+
label="提取步骤", interactive=False, lines=15
|
| 47 |
)
|
| 48 |
|
| 49 |
+
chat_clear = gr.ClearButton([chat_msg, chat_chatbot, intent_textbox, steps_textbox], value="清除")
|
| 50 |
|
| 51 |
def user(user_message, history):
|
| 52 |
return "", history + [[user_message, None]]
|