FrostIce commited on
Commit
d1ec138
·
verified ·
1 Parent(s): eabb976

Upload config.py

Browse files
Files changed (1) hide show
  1. config.py +230 -0
config.py ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from modelscope_studio.components.pro.chatbot import ChatbotActionConfig, ChatbotBotConfig, ChatbotUserConfig, ChatbotWelcomeConfig
3
+
4
+ # Env
5
+ is_cn = os.getenv('MODELSCOPE_ENVIRONMENT') == 'studio'
6
+ api_key = os.getenv('API_KEY')
7
+
8
+
9
+ def get_text(text: str, cn_text: str):
10
+ if is_cn:
11
+ return cn_text
12
+ return text
13
+
14
+
15
+ # Save history in browser
16
+ save_history = True
17
+
18
+
19
+ # Chatbot Config
20
+ def user_config(disabled_actions=None):
21
+ return ChatbotUserConfig(
22
+ class_names=dict(content="user-message-content"),
23
+ actions=[
24
+ "copy", "edit",
25
+ ChatbotActionConfig(
26
+ action="delete",
27
+ popconfirm=dict(title=get_text("Delete the message", "删除消息"),
28
+ description=get_text(
29
+ "Are you sure to delete this message?",
30
+ "确认删除该消息?"),
31
+ okButtonProps=dict(danger=True)))
32
+ ],
33
+ disabled_actions=disabled_actions)
34
+
35
+
36
+ def bot_config(disabled_actions=None):
37
+ return ChatbotBotConfig(actions=[
38
+ "copy", "edit",
39
+ ChatbotActionConfig(
40
+ action="retry",
41
+ popconfirm=dict(
42
+ title=get_text("Regenerate the message", "重新生成消息"),
43
+ description=get_text(
44
+ "Regenerate the message will also delete all subsequent messages.",
45
+ "重新生成消息会删除所有后续消息。"),
46
+ okButtonProps=dict(danger=True))),
47
+ ChatbotActionConfig(action="delete",
48
+ popconfirm=dict(
49
+ title=get_text("Delete the message", "删除消息"),
50
+ description=get_text(
51
+ "Are you sure to delete this message?",
52
+ "确认删除该消息?"),
53
+ okButtonProps=dict(danger=True)))
54
+ ],
55
+ avatar="./assets/qwen.png",
56
+ disabled_actions=disabled_actions)
57
+
58
+
59
+ def welcome_config():
60
+ return ChatbotWelcomeConfig(
61
+ variant="borderless",
62
+ icon="./assets/qwen.png",
63
+ title=get_text("Hello, I'm Qwen3", "你好,我是 Qwen3"),
64
+ description=get_text("Select a model and enter text to get started.",
65
+ "选择模型并输入文本,开始对话吧。"),
66
+ prompts=dict(
67
+ title=get_text("How can I help you today?", "有什么我能帮助你的吗?"),
68
+ styles={
69
+ "list": {
70
+ "width": '100%',
71
+ },
72
+ "item": {
73
+ "flex": 1,
74
+ },
75
+ },
76
+ items=[{
77
+ "label":
78
+ get_text("📅 Make a plan", "📅 制定计划"),
79
+ "children": [{
80
+ "description":
81
+ get_text("Help me with a plan to start a business",
82
+ "帮助我制定一个创业计划")
83
+ }, {
84
+ "description":
85
+ get_text("Help me with a plan to achieve my goals",
86
+ "帮助我制定一个实现目标的计划")
87
+ }, {
88
+ "description":
89
+ get_text("Help me with a plan for a successful interview",
90
+ "帮助我制定一个成功的面试计划")
91
+ }]
92
+ }, {
93
+ "label":
94
+ get_text("🖋 Help me write", "🖋 帮我写"),
95
+ "children": [{
96
+ "description":
97
+ get_text("Help me write a story with a twist ending",
98
+ "帮助我写一个带有意外结局的故事")
99
+ }, {
100
+ "description":
101
+ get_text("Help me write a blog post on mental health",
102
+ "帮助我写一篇关于心理健康的博客文章")
103
+ }, {
104
+ "description":
105
+ get_text("Help me write a letter to my future self",
106
+ "帮助我写一封给未来自己的信")
107
+ }]
108
+ }]),
109
+ )
110
+
111
+
112
+ DEFAULT_SUGGESTIONS = [{
113
+ "label":
114
+ get_text('Make a plan', '制定计划'),
115
+ "value":
116
+ get_text('Make a plan', '制定计划'),
117
+ "children": [{
118
+ "label":
119
+ get_text("Start a business", "开始创业"),
120
+ "value":
121
+ get_text("Help me with a plan to start a business", "帮助我制定一个创业计划")
122
+ }, {
123
+ "label":
124
+ get_text("Achieve my goals", "实现我的目标"),
125
+ "value":
126
+ get_text("Help me with a plan to achieve my goals", "帮助我制定一个实现目标的计划")
127
+ }, {
128
+ "label":
129
+ get_text("Successful interview", "成功的面试"),
130
+ "value":
131
+ get_text("Help me with a plan for a successful interview",
132
+ "帮助我制定一个成功的面试计划")
133
+ }]
134
+ }, {
135
+ "label":
136
+ get_text('Help me write', '帮我写'),
137
+ "value":
138
+ get_text("Help me write", '帮我写'),
139
+ "children": [{
140
+ "label":
141
+ get_text("Story with a twist ending", "带有意外结局的故事"),
142
+ "value":
143
+ get_text("Help me write a story with a twist ending",
144
+ "帮助我写一个带有意外结局的故事")
145
+ }, {
146
+ "label":
147
+ get_text("Blog post on mental health", "关于心理健康的博客文章"),
148
+ "value":
149
+ get_text("Help me write a blog post on mental health",
150
+ "帮助我写一篇关于心理健康的博客文章")
151
+ }, {
152
+ "label":
153
+ get_text("Letter to my future self", "给未来自己的信"),
154
+ "value":
155
+ get_text("Help me write a letter to my future self", "帮助我写一封给未来自己的信")
156
+ }]
157
+ }]
158
+
159
+ DEFAULT_SYS_PROMPT = "You are a helpful and harmless assistant."
160
+
161
+ MIN_THINKING_BUDGET = 1
162
+
163
+ MAX_THINKING_BUDGET = 38
164
+
165
+ DEFAULT_THINKING_BUDGET = 38
166
+
167
+ DEFAULT_MODEL = "qwen3-235b-a22b"
168
+
169
+ MODEL_OPTIONS = [
170
+ {
171
+ "label": get_text("Qwen3-235B-A22B", "通义千问3-235B-A22B"),
172
+ "modelId": "Qwen/Qwen3-235B-A22B",
173
+ "value": "qwen3-235b-a22b"
174
+ },
175
+ {
176
+ "label": get_text("Qwen3-32B", "通义千问3-32B"),
177
+ "modelId": "Qwen/Qwen3-32B",
178
+ "value": "qwen3-32b"
179
+ },
180
+ {
181
+ "label": get_text("Qwen3-30B-A3B", "通义千问3-30B-A3B"),
182
+ "modelId": "Qwen/Qwen3-30B-A3B",
183
+ "value": "qwen3-30b-a3b"
184
+ },
185
+ {
186
+ "label": get_text("Qwen3-14B", "通义千问3-14B"),
187
+ "modelId": "Qwen/Qwen3-14B",
188
+ "value": "qwen3-14b"
189
+ },
190
+ {
191
+ "label": get_text("Qwen3-8B", "通义千问3-8B"),
192
+ "modelId": "Qwen/Qwen3-8B",
193
+ "value": "qwen3-8b"
194
+ },
195
+ {
196
+ "label": get_text("Qwen3-4B", "通义千问3-4B"),
197
+ "modelId": "Qwen/Qwen3-4B",
198
+ "value": "qwen3-4b"
199
+ },
200
+ {
201
+ "label": get_text("Qwen3-1.7B", "通义千问3-1.7B"),
202
+ "modelId": "Qwen/Qwen3-1.7B",
203
+ "value": "qwen3-1.7b"
204
+ },
205
+ {
206
+ "label": get_text("Qwen3-0.6B", "通义千问3-0.6B"),
207
+ "modelId": "Qwen/Qwen3-0.6B",
208
+ "value": "qwen3-0.6b"
209
+ },
210
+ ]
211
+
212
+ for model in MODEL_OPTIONS:
213
+ model[
214
+ "link"] = is_cn and f"https://modelscope.cn/models/{model['modelId']}" or f"https://huggingface.co/{model['modelId']}"
215
+
216
+ MODEL_OPTIONS_MAP = {model["value"]: model for model in MODEL_OPTIONS}
217
+
218
+ DEFAULT_LOCALE = 'zh_CN' if is_cn else 'en_US'
219
+
220
+ DEFAULT_THEME = {
221
+ "token": {
222
+ "colorPrimary": "#6A57FF",
223
+ }
224
+ }
225
+
226
+ DEFAULT_SETTINGS = {
227
+ "model": DEFAULT_MODEL,
228
+ "sys_prompt": DEFAULT_SYS_PROMPT,
229
+ "thinking_budget": DEFAULT_THINKING_BUDGET
230
+ }