hsuwill000 commited on
Commit
9871750
·
verified ·
1 Parent(s): 0801ebc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -58,7 +58,18 @@ with gr.Blocks() as demo:
58
  )
59
  # 使用 .render() 將 hidden_api 組件加入佈局,雖然 UI 不會顯示,但 API 端點仍會註冊
60
  hidden_api.render()
61
-
 
 
 
 
 
 
 
 
 
 
 
62
  if __name__ == "__main__":
63
  print("Launching Gradio app...")
64
  demo.launch(server_name="0.0.0.0", server_port=7860, share=True)
 
58
  )
59
  # 使用 .render() 將 hidden_api 組件加入佈局,雖然 UI 不會顯示,但 API 端點仍會註冊
60
  hidden_api.render()
61
+ # 將隱藏的接口作為一個組件加入 Blocks,設定 visible=False
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
  print("Launching Gradio app...")
75
  demo.launch(server_name="0.0.0.0", server_port=7860, share=True)