Update app.py
Browse files
app.py
CHANGED
|
@@ -2,16 +2,10 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
from keep_alive import keep_alive
|
| 4 |
import multiprocessing
|
| 5 |
-
import threading
|
| 6 |
-
import time
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
"""
|
| 10 |
-
For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
|
| 11 |
-
"""
|
| 12 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 13 |
|
| 14 |
-
|
| 15 |
def respond(
|
| 16 |
message,
|
| 17 |
history: list[tuple[str, str]] = [],
|
|
@@ -59,8 +53,6 @@ demo = gr.ChatInterface(
|
|
| 59 |
],
|
| 60 |
)
|
| 61 |
|
| 62 |
-
demo.launch()
|
| 63 |
-
|
| 64 |
def tts1():
|
| 65 |
網址1 = os.getenv('test1')
|
| 66 |
網址2 = os.getenv('test2')
|
|
@@ -68,12 +60,12 @@ def tts1():
|
|
| 68 |
keep_alive(urls)
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
-
# 創建
|
| 72 |
p1 = multiprocessing.Process(target=tts1)
|
| 73 |
-
p2 = multiprocessing.Process(target=respond)
|
| 74 |
-
|
| 75 |
p1.start()
|
| 76 |
-
p2.start()
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
p1.join()
|
| 79 |
-
p2.join()
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
from keep_alive import keep_alive
|
| 4 |
import multiprocessing
|
|
|
|
|
|
|
| 5 |
import os
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
| 8 |
|
|
|
|
| 9 |
def respond(
|
| 10 |
message,
|
| 11 |
history: list[tuple[str, str]] = [],
|
|
|
|
| 53 |
],
|
| 54 |
)
|
| 55 |
|
|
|
|
|
|
|
| 56 |
def tts1():
|
| 57 |
網址1 = os.getenv('test1')
|
| 58 |
網址2 = os.getenv('test2')
|
|
|
|
| 60 |
keep_alive(urls)
|
| 61 |
|
| 62 |
if __name__ == "__main__":
|
| 63 |
+
# 創建一個進程用於 keep_alive
|
| 64 |
p1 = multiprocessing.Process(target=tts1)
|
|
|
|
|
|
|
| 65 |
p1.start()
|
|
|
|
| 66 |
|
| 67 |
+
# 啟動 Gradio 介面
|
| 68 |
+
demo.launch()
|
| 69 |
+
|
| 70 |
+
# 等待 keep_alive 進程結束
|
| 71 |
p1.join()
|
|
|