Spaces:
Running
Running
Switch Coder Helper UI and default prompt to Traditional Chinese
Browse filesTranslate the title, description, control labels and example prompts,
and ask the model to answer in Traditional Chinese by default.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -8,9 +8,9 @@ LLM_API_KEY = os.environ.get("LLM_API_KEY", "")
|
|
| 8 |
LLM_MODEL = os.environ.get("LLM_MODEL", "Qwen/Qwen2.5-Coder-7B-Instruct-AWQ")
|
| 9 |
|
| 10 |
DEFAULT_SYSTEM_PROMPT = (
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
)
|
| 15 |
|
| 16 |
client = OpenAI(base_url=LLM_BASE_URL, api_key=LLM_API_KEY)
|
|
@@ -41,18 +41,18 @@ def respond(message, history, model, system_prompt, max_tokens, temperature):
|
|
| 41 |
|
| 42 |
demo = gr.ChatInterface(
|
| 43 |
fn=respond,
|
| 44 |
-
title="
|
| 45 |
-
description="
|
| 46 |
additional_inputs=[
|
| 47 |
-
gr.Dropdown(choices=[LLM_MODEL], value=LLM_MODEL, allow_custom_value=True, label="
|
| 48 |
-
gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, label="
|
| 49 |
-
gr.Slider(minimum=32, maximum=2048, value=512, step=32, label="
|
| 50 |
-
gr.Slider(minimum=0.0, maximum=1.5, value=0.2, step=0.1, label="
|
| 51 |
],
|
| 52 |
examples=[
|
| 53 |
-
["
|
| 54 |
-
["
|
| 55 |
-
["
|
| 56 |
],
|
| 57 |
cache_examples=False,
|
| 58 |
)
|
|
|
|
| 8 |
LLM_MODEL = os.environ.get("LLM_MODEL", "Qwen/Qwen2.5-Coder-7B-Instruct-AWQ")
|
| 9 |
|
| 10 |
DEFAULT_SYSTEM_PROMPT = (
|
| 11 |
+
"你是一位樂於助人的程式設計助理。請一律使用繁體中文回答,"
|
| 12 |
+
"清楚說明概念,撰寫正確且易讀的程式碼,並指出錯誤或邊界情況。"
|
| 13 |
+
"程式碼請放在附上語言名稱的 fenced code block 中。"
|
| 14 |
)
|
| 15 |
|
| 16 |
client = OpenAI(base_url=LLM_BASE_URL, api_key=LLM_API_KEY)
|
|
|
|
| 41 |
|
| 42 |
demo = gr.ChatInterface(
|
| 43 |
fn=respond,
|
| 44 |
+
title="程式設計小幫手",
|
| 45 |
+
description="提出程式設計相關的問題,回答由自架的開源大型語言模型產生。",
|
| 46 |
additional_inputs=[
|
| 47 |
+
gr.Dropdown(choices=[LLM_MODEL], value=LLM_MODEL, allow_custom_value=True, label="模型"),
|
| 48 |
+
gr.Textbox(value=DEFAULT_SYSTEM_PROMPT, label="系統提示詞", lines=3),
|
| 49 |
+
gr.Slider(minimum=32, maximum=2048, value=512, step=32, label="最大輸出 token 數"),
|
| 50 |
+
gr.Slider(minimum=0.0, maximum=1.5, value=0.2, step=0.1, label="溫度"),
|
| 51 |
],
|
| 52 |
examples=[
|
| 53 |
+
["寫一個 Python 函式,判斷字串是否為回文。"],
|
| 54 |
+
["為什麼 JavaScript 的 `for (var i...)` 迴圈搭配 setTimeout 每次都印出同一個數字?"],
|
| 55 |
+
["請說明行程(process)和執行緒(thread)的差別。"],
|
| 56 |
],
|
| 57 |
cache_examples=False,
|
| 58 |
)
|