Update app.py
Browse files
app.py
CHANGED
@@ -37,6 +37,7 @@ def respond(prompt, history):
|
|
37 |
def maxtest(prompt):
|
38 |
return prompt
|
39 |
|
|
|
40 |
with gr.Blocks() as demo:
|
41 |
gr.Markdown("# DeepSeek-R1-Distill-Qwen-1.5B-openvino")
|
42 |
with gr.Tabs():
|
@@ -46,30 +47,21 @@ with gr.Blocks() as demo:
|
|
46 |
title="聊天介面",
|
47 |
description="DeepSeek-R1-Distill-Qwen-1.5B-openvino 聊天接口"
|
48 |
)
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
hidden_api2 = gr.Interface(
|
63 |
-
fn=respond,
|
64 |
-
inputs=gr.Textbox(label="Prompt"),
|
65 |
-
outputs="text",
|
66 |
-
api_name="/hchat",
|
67 |
-
title="hidden chat",
|
68 |
-
description="hidden chat",
|
69 |
-
visible=False
|
70 |
-
)
|
71 |
-
#hidden_api2.render()
|
72 |
-
|
73 |
if __name__ == "__main__":
|
74 |
-
|
75 |
-
demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
|
|
37 |
def maxtest(prompt):
|
38 |
return prompt
|
39 |
|
40 |
+
# 定義主 Blocks,只包含聊天介面
|
41 |
with gr.Blocks() as demo:
|
42 |
gr.Markdown("# DeepSeek-R1-Distill-Qwen-1.5B-openvino")
|
43 |
with gr.Tabs():
|
|
|
47 |
title="聊天介面",
|
48 |
description="DeepSeek-R1-Distill-Qwen-1.5B-openvino 聊天接口"
|
49 |
)
|
50 |
+
|
51 |
+
# 定義隱藏的 API 介面(不會 render 到 UI)
|
52 |
+
hidden_api = gr.Interface(
|
53 |
+
fn=maxtest,
|
54 |
+
inputs=gr.Textbox(label="Prompt"),
|
55 |
+
outputs="text",
|
56 |
+
api_name="/maxtest",
|
57 |
+
title="MaxTest API",
|
58 |
+
description="回傳輸入內容的測試 API",
|
59 |
+
visible=False
|
60 |
+
)
|
61 |
+
|
62 |
+
# 啟動時,將 hidden_api 作為一個 FastAPI 子應用掛載到主應用上
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
if __name__ == "__main__":
|
64 |
+
# 使用 demo.launch() 返回 FastAPI 應用實例(注意:此方法行為可能因 Gradio 版本而異)
|
65 |
+
app, local_url, share_url = demo.launch(server_name="0.0.0.0", server_port=7860, share=True, inline=False)
|
66 |
+
# 掛載 hidden_api 的 FastAPI app 到 /maxtest
|
67 |
+
app.mount("/maxtest", hidden_api.app)
|