Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
"""
|
|
@@ -7,7 +8,7 @@ For more information on `huggingface_hub` Inference API support, please check th
|
|
| 7 |
client = InferenceClient("microsoft/Phi-3.5-mini-instruct")
|
| 8 |
|
| 9 |
|
| 10 |
-
def respond(
|
| 11 |
message,
|
| 12 |
history: list[tuple[str, str]],
|
| 13 |
system_message,
|
|
@@ -27,7 +28,7 @@ def respond(
|
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
|
| 30 |
-
for message in client.chat_completion(
|
| 31 |
messages,
|
| 32 |
max_tokens=max_tokens,
|
| 33 |
stream=True,
|
|
@@ -59,6 +60,6 @@ demo = gr.ChatInterface(
|
|
| 59 |
],
|
| 60 |
)
|
| 61 |
|
| 62 |
-
|
| 63 |
if __name__ == "__main__":
|
| 64 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import asyncio
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
"""
|
|
|
|
| 8 |
client = InferenceClient("microsoft/Phi-3.5-mini-instruct")
|
| 9 |
|
| 10 |
|
| 11 |
+
async def respond(
|
| 12 |
message,
|
| 13 |
history: list[tuple[str, str]],
|
| 14 |
system_message,
|
|
|
|
| 28 |
|
| 29 |
response = ""
|
| 30 |
|
| 31 |
+
async for message in client.chat_completion(
|
| 32 |
messages,
|
| 33 |
max_tokens=max_tokens,
|
| 34 |
stream=True,
|
|
|
|
| 60 |
],
|
| 61 |
)
|
| 62 |
|
| 63 |
+
# Launch the app with concurrency for 4 users
|
| 64 |
if __name__ == "__main__":
|
| 65 |
+
demo.queue(concurrency_count=4).launch()
|