GitHub Action commited on
Commit
efd0da0
·
1 Parent(s): 00973ce

Sync ling-space changes from GitHub commit 0c0ec4d

Browse files
Files changed (4) hide show
  1. app.py +4 -4
  2. i18n/tab_welcome.py +6 -6
  3. run_dev_server.py +4 -1
  4. tab_welcome.py +25 -7
app.py CHANGED
@@ -70,7 +70,7 @@ if __name__ == "__main__":
70
  all_i18n_outputs = []
71
 
72
  with gr.Tabs(elem_id="indicator-space-app") as tabs:
73
- welcome_components = create_welcome_tab(current_lang_state.value)
74
 
75
  # The order of components MUST be consistent
76
  welcome_outputs = [
@@ -92,7 +92,7 @@ if __name__ == "__main__":
92
 
93
  # --- Chat Tab ---
94
  with gr.TabItem(
95
- get_text("chat_tab_title", current_lang_state.value)
96
  ) as chat_tab:
97
  chat_components = create_chat_tab(
98
  current_lang_state.value, current_lang_state
@@ -119,7 +119,7 @@ if __name__ == "__main__":
119
 
120
  # --- Code Tab ---
121
  with gr.TabItem(
122
- get_text("code_tab_title", current_lang_state.value)
123
  ) as code_tab:
124
  code_components = create_code_tab(
125
  current_lang_state.value, current_lang_state
@@ -154,7 +154,7 @@ if __name__ == "__main__":
154
 
155
  # --- Writer Tab ---
156
  with gr.TabItem(
157
- get_text("writer_tab_title", current_lang_state.value)
158
  ) as writer_tab:
159
  writer_components = create_smart_writer_tab(current_lang_state)
160
 
 
70
  all_i18n_outputs = []
71
 
72
  with gr.Tabs(elem_id="indicator-space-app") as tabs:
73
+ welcome_components = create_welcome_tab(current_lang_state.value, tabs)
74
 
75
  # The order of components MUST be consistent
76
  welcome_outputs = [
 
92
 
93
  # --- Chat Tab ---
94
  with gr.TabItem(
95
+ get_text("chat_tab_title", current_lang_state.value), id="chat"
96
  ) as chat_tab:
97
  chat_components = create_chat_tab(
98
  current_lang_state.value, current_lang_state
 
119
 
120
  # --- Code Tab ---
121
  with gr.TabItem(
122
+ get_text("code_tab_title", current_lang_state.value), id="code"
123
  ) as code_tab:
124
  code_components = create_code_tab(
125
  current_lang_state.value, current_lang_state
 
154
 
155
  # --- Writer Tab ---
156
  with gr.TabItem(
157
+ get_text("writer_tab_title", current_lang_state.value), id="writer"
158
  ) as writer_tab:
159
  writer_components = create_smart_writer_tab(current_lang_state)
160
 
i18n/tab_welcome.py CHANGED
@@ -14,16 +14,16 @@ ui_translations = {
14
  "zh": "#### 通过这些演示体验 Ling 系列模型的能力:"
15
  },
16
  "welcome_chat_desc": {
17
- "en": """**Chat** - Communicate with the models for various text generation tasks.""",
18
- "zh": """**文本聊天** - 与模型沟通,完成各种文本生成任务。"""
19
  },
20
  "welcome_code_desc": {
21
- "en": """**Code Generation** - Generate rich web applications using natural language.""",
22
- "zh": """**代码生成** - 用自然语言生成效果丰富的 Web 应用并预览。"""
23
  },
24
  "welcome_writer_desc": {
25
- "en": """**Writing Assistant** - Get help with your writing tasks, leveraging multiple model capabilities.""",
26
- "zh": """**写作助手** - 综合多种模型能力,提供专业的写作辅助。"""
27
  },
28
  "welcome_select_language": {
29
  "en": "## Select Language",
 
14
  "zh": "#### 通过这些演示体验 Ling 系列模型的能力:"
15
  },
16
  "welcome_chat_desc": {
17
+ "en": """Chat - Communicate with the models for various text generation tasks.""",
18
+ "zh": """文本聊天 - 与模型沟通,完成各种文本生成任务。"""
19
  },
20
  "welcome_code_desc": {
21
+ "en": """Code Generation - Generate rich web applications using natural language.""",
22
+ "zh": """代码生成 - 用自然语言生成效果丰富的 Web 应用并预览。"""
23
  },
24
  "welcome_writer_desc": {
25
+ "en": """Writing Assistant - Get help with your writing tasks, leveraging multiple model capabilities.""",
26
+ "zh": """写作助手 - 综合多种模型能力,提供专业的写作辅助。"""
27
  },
28
  "welcome_select_language": {
29
  "en": "## Select Language",
run_dev_server.py CHANGED
@@ -24,5 +24,8 @@ if __name__ == '__main__':
24
  watchfiles.run_process(
25
  '.', # Watch the current directory
26
  target=f'{sys.executable} app.py --color', # Command to run
27
- target_type='command'
 
 
 
28
  )
 
24
  watchfiles.run_process(
25
  '.', # Watch the current directory
26
  target=f'{sys.executable} app.py --color', # Command to run
27
+ target_type='command',
28
+ debounce=2_000,
29
+ step=1_000,
30
+ sigint_timeout=1,
31
  )
tab_welcome.py CHANGED
@@ -1,7 +1,7 @@
1
  import gradio as gr
2
  from i18n import get_text
3
 
4
- def create_welcome_tab(initial_lang: str):
5
  """
6
  Creates the UI components for the Welcome Tab.
7
  Returns a dictionary of all component handles that need dynamic updates.
@@ -11,9 +11,9 @@ def create_welcome_tab(initial_lang: str):
11
  welcome_header_md = gr.Markdown(f"# {get_text('welcome_header', initial_lang)}")
12
  welcome_desc_md = gr.Markdown(get_text('welcome_description', initial_lang))
13
  with gr.Row(equal_height=True):
14
- welcome_chat_desc_md = gr.Markdown(get_text('welcome_chat_desc', initial_lang), padding=True, container=True)
15
- welcome_code_desc_md = gr.Markdown(get_text('welcome_code_desc', initial_lang), padding=True, container=True)
16
- welcome_writer_desc_md = gr.Markdown(get_text('welcome_writer_desc', initial_lang), padding=True, container=True)
17
 
18
  gr.Markdown(" ")
19
  welcome_model_links_header_md = gr.Markdown(get_text('welcome_model_links_header', initial_lang))
@@ -42,14 +42,32 @@ def create_welcome_tab(initial_lang: str):
42
  js="() => { window.dispatchEvent(new CustomEvent('langChange.SpaceApp', { detail: { lang: 'zh' } })); }"
43
  )
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  # Return a dictionary for easier access in app.py
46
  components = {
47
  "tab": welcome_tab,
48
  "header": welcome_header_md,
49
  "description": welcome_desc_md,
50
- "chat_description": welcome_chat_desc_md,
51
- "code_description": welcome_code_desc_md,
52
- "writer_description": welcome_writer_desc_md,
53
  "model_links_header": welcome_model_links_header_md,
54
  "hf_link": welcome_hf_link_md,
55
  "hf_report": welcome_hf_report_md,
 
1
  import gradio as gr
2
  from i18n import get_text
3
 
4
+ def create_welcome_tab(initial_lang: str, tabs: gr.Tabs):
5
  """
6
  Creates the UI components for the Welcome Tab.
7
  Returns a dictionary of all component handles that need dynamic updates.
 
11
  welcome_header_md = gr.Markdown(f"# {get_text('welcome_header', initial_lang)}")
12
  welcome_desc_md = gr.Markdown(get_text('welcome_description', initial_lang))
13
  with gr.Row(equal_height=True):
14
+ welcome_chat_desc_btn = gr.Button(get_text('welcome_chat_desc', initial_lang))
15
+ welcome_code_desc_btn = gr.Button(get_text('welcome_code_desc', initial_lang))
16
+ welcome_writer_desc_btn = gr.Button(get_text('welcome_writer_desc', initial_lang))
17
 
18
  gr.Markdown(" ")
19
  welcome_model_links_header_md = gr.Markdown(get_text('welcome_model_links_header', initial_lang))
 
42
  js="() => { window.dispatchEvent(new CustomEvent('langChange.SpaceApp', { detail: { lang: 'zh' } })); }"
43
  )
44
 
45
+ welcome_chat_desc_btn.click(
46
+ fn=lambda: gr.Tabs(selected="chat"),
47
+ inputs=[],
48
+ outputs=[tabs]
49
+ )
50
+
51
+ welcome_code_desc_btn.click(
52
+ fn=lambda: gr.Tabs(selected="code"),
53
+ inputs=[],
54
+ outputs=[tabs]
55
+ )
56
+
57
+ welcome_writer_desc_btn.click(
58
+ fn=lambda: gr.Tabs(selected="writer"),
59
+ inputs=[],
60
+ outputs=[tabs]
61
+ )
62
+
63
  # Return a dictionary for easier access in app.py
64
  components = {
65
  "tab": welcome_tab,
66
  "header": welcome_header_md,
67
  "description": welcome_desc_md,
68
+ "chat_description": welcome_chat_desc_btn,
69
+ "code_description": welcome_code_desc_btn,
70
+ "writer_description": welcome_writer_desc_btn,
71
  "model_links_header": welcome_model_links_header_md,
72
  "hf_link": welcome_hf_link_md,
73
  "hf_report": welcome_hf_report_md,