Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -23,12 +23,10 @@ AVAILABLE_MODELS = [
|
|
23 |
|
24 |
|
25 |
# Default System Prompt
|
26 |
-
DEFAULT_SYSTEM_PROMPT = """
|
27 |
1. 如果查詢是以中文輸入,使用標準繁體中文回答,符合官方文書規範
|
28 |
2. 要提供引用規則依据
|
29 |
-
3. 如果查詢是以英文輸入,使用英文回答
|
30 |
-
Answer everything in simple, smart, relevant and accurate style, within 20 words. No chatty!
|
31 |
-
"""
|
32 |
|
33 |
# --- Gradio Interface ---
|
34 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="neutral")) as demo:
|
@@ -109,6 +107,20 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="neutra
|
|
109 |
queue=False
|
110 |
)
|
111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
# --- Core Chat Logic ---
|
113 |
# This function is the heart of the application.
|
114 |
def respond(history, system_prompt, stream_output, current_selected_model, selected_prompt_key, use_custom_prompt): # Added selected_prompt_key and use_custom_prompt
|
@@ -169,4 +181,4 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="neutra
|
|
169 |
)
|
170 |
|
171 |
# Launch the Gradio interface
|
172 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
23 |
|
24 |
|
25 |
# Default System Prompt
|
26 |
+
DEFAULT_SYSTEM_PROMPT = """Answer everything in simple, smart, relevant and accurate style. No chatty! Besides, pls:
|
27 |
1. 如果查詢是以中文輸入,使用標準繁體中文回答,符合官方文書規範
|
28 |
2. 要提供引用規則依据
|
29 |
+
3. 如果查詢是以英文輸入,使用英文回答"""
|
|
|
|
|
30 |
|
31 |
# --- Gradio Interface ---
|
32 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue", secondary_hue="neutral")) as demo:
|
|
|
107 |
queue=False
|
108 |
)
|
109 |
|
110 |
+
# Function to update textbox when prompt style changes
|
111 |
+
def update_prompt_text(selected_key, use_custom):
|
112 |
+
if not use_custom:
|
113 |
+
return gr.update(value=SYSTEM_PROMPT_OPTIONS[selected_key])
|
114 |
+
else:
|
115 |
+
return gr.update()
|
116 |
+
|
117 |
+
system_prompt_selector.change(
|
118 |
+
fn=update_prompt_text,
|
119 |
+
inputs=[system_prompt_selector, use_custom_prompt_checkbox],
|
120 |
+
outputs=system_prompt_textbox,
|
121 |
+
queue=False
|
122 |
+
)
|
123 |
+
|
124 |
# --- Core Chat Logic ---
|
125 |
# This function is the heart of the application.
|
126 |
def respond(history, system_prompt, stream_output, current_selected_model, selected_prompt_key, use_custom_prompt): # Added selected_prompt_key and use_custom_prompt
|
|
|
181 |
)
|
182 |
|
183 |
# Launch the Gradio interface
|
184 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|