Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -106,7 +106,7 @@ def gradio_embedding(text: str) -> Dict:
|
|
| 106 |
return response.dict()
|
| 107 |
|
| 108 |
# 创建 Gradio 界面
|
| 109 |
-
|
| 110 |
fn=gradio_embedding,
|
| 111 |
inputs=gr.Textbox(lines=3, placeholder="输入要进行编码的文本..."),
|
| 112 |
outputs=gr.Json(),
|
|
@@ -118,10 +118,19 @@ iface = gr.Interface(
|
|
| 118 |
]
|
| 119 |
)
|
| 120 |
|
| 121 |
-
# 挂载 Gradio 应用到 FastAPI
|
| 122 |
-
app = gr.mount_gradio_app(app, iface, path="/")
|
| 123 |
-
|
| 124 |
# 启动服务
|
| 125 |
if __name__ == "__main__":
|
| 126 |
import uvicorn
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
return response.dict()
|
| 107 |
|
| 108 |
# 创建 Gradio 界面
|
| 109 |
+
demo = gr.Interface(
|
| 110 |
fn=gradio_embedding,
|
| 111 |
inputs=gr.Textbox(lines=3, placeholder="输入要进行编码的文本..."),
|
| 112 |
outputs=gr.Json(),
|
|
|
|
| 118 |
]
|
| 119 |
)
|
| 120 |
|
|
|
|
|
|
|
|
|
|
| 121 |
# 启动服务
|
| 122 |
if __name__ == "__main__":
|
| 123 |
import uvicorn
|
| 124 |
+
|
| 125 |
+
# 首先启动 Gradio
|
| 126 |
+
demo.queue()
|
| 127 |
+
|
| 128 |
+
# 然后启动 FastAPI
|
| 129 |
+
config = uvicorn.Config(
|
| 130 |
+
app=app,
|
| 131 |
+
host="0.0.0.0",
|
| 132 |
+
port=7860,
|
| 133 |
+
log_level="info"
|
| 134 |
+
)
|
| 135 |
+
server = uvicorn.Server(config)
|
| 136 |
+
server.run()
|