GOGO198 commited on
Commit
d19b751
·
verified ·
1 Parent(s): 4d65f0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -7
app.py CHANGED
@@ -177,13 +177,23 @@ if __name__ == "__main__":
177
  print("="*50)
178
 
179
  # 使用 Gradio 接口暴露 API 端点(自动生成 /api/predict)
180
- demo = gr.Interface(
181
- fn=respond,
182
- inputs="text",
183
- outputs="json",
184
- api_name="predict",
185
- live=False
186
- )
 
 
 
 
 
 
 
 
 
 
187
 
188
  demo.launch(
189
  server_name="0.0.0.0",
 
177
  print("="*50)
178
 
179
  # 使用 Gradio 接口暴露 API 端点(自动生成 /api/predict)
180
+ # demo = gr.Interface(
181
+ # fn=respond,
182
+ # inputs="text",
183
+ # outputs="json",
184
+ # api_name="predict",
185
+ # live=False
186
+ # )
187
+
188
+ with gr.Blocks() as app:
189
+ input_text = gr.Textbox(label="Input")
190
+ output_text = gr.JSON(label="Output")
191
+ input_text.change(
192
+ fn=respond,
193
+ inputs=input_text,
194
+ outputs=output_text,
195
+ api_name="predict" # 显式声明 API 名称
196
+ )
197
 
198
  demo.launch(
199
  server_name="0.0.0.0",