rapacious commited on
Commit
8a73b48
·
verified ·
1 Parent(s): 1f5a613

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -36,7 +36,6 @@ def generate_text(prompt, max_length=100):
36
 
37
  # Hàm hiển thị thông tin API
38
  def get_api_info():
39
- # Dùng placeholder, người dùng sẽ thay bằng URL thực tế của Space
40
  base_url = "https://<your-space-name>.hf.space"
41
  return (
42
  "Welcome to Qwen2.5-0.5B API!\n"
@@ -78,7 +77,7 @@ with gr.Blocks(title="Qwen2.5-0.5B Text Generator") as demo:
78
  )
79
 
80
  # Định nghĩa API endpoints với Gradio
81
- demo = gr.Interface(
82
  fn=generate_text,
83
  inputs=["text", "number"],
84
  outputs="text",
@@ -86,7 +85,6 @@ demo = gr.Interface(
86
  api_name="/generate" # API endpoint: /api/generate
87
  ).queue()
88
 
89
- # Thêm endpoint health check
90
  health_interface = gr.Interface(
91
  fn=health_check,
92
  inputs=None,
@@ -94,8 +92,8 @@ health_interface = gr.Interface(
94
  api_name="/health_check" # API endpoint: /api/health_check
95
  )
96
 
97
- # Kết hợp giao diện và API
98
- app = gr.mount_gradio_app(demo, health_interface)
99
 
100
  # Chạy ứng dụng
101
  demo.launch(server_name="0.0.0.0", server_port=7860)
 
36
 
37
  # Hàm hiển thị thông tin API
38
  def get_api_info():
 
39
  base_url = "https://<your-space-name>.hf.space"
40
  return (
41
  "Welcome to Qwen2.5-0.5B API!\n"
 
77
  )
78
 
79
  # Định nghĩa API endpoints với Gradio
80
+ interface = gr.Interface(
81
  fn=generate_text,
82
  inputs=["text", "number"],
83
  outputs="text",
 
85
  api_name="/generate" # API endpoint: /api/generate
86
  ).queue()
87
 
 
88
  health_interface = gr.Interface(
89
  fn=health_check,
90
  inputs=None,
 
92
  api_name="/health_check" # API endpoint: /api/health_check
93
  )
94
 
95
+ # Gắn các interface vào demo
96
+ demo = gr.TabbedInterface([interface, health_interface], ["Generate Text", "Health Check"])
97
 
98
  # Chạy ứng dụng
99
  demo.launch(server_name="0.0.0.0", server_port=7860)