Spaces:
Sleeping
Sleeping
use threads
Browse files
main.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
-
import uvicorn
|
| 5 |
-
import re
|
| 6 |
from typing import List
|
| 7 |
|
|
|
|
| 8 |
app = FastAPI()
|
| 9 |
|
| 10 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
@@ -69,4 +71,7 @@ async def generate_text(
|
|
| 69 |
top_p=top_p,
|
| 70 |
repetition_penalty=repetition_penalty
|
| 71 |
)
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import uvicorn
|
| 2 |
+
import re
|
| 3 |
+
import asyncio
|
| 4 |
from fastapi import FastAPI
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from huggingface_hub import InferenceClient
|
|
|
|
|
|
|
| 7 |
from typing import List
|
| 8 |
|
| 9 |
+
|
| 10 |
app = FastAPI()
|
| 11 |
|
| 12 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
|
|
| 71 |
top_p=top_p,
|
| 72 |
repetition_penalty=repetition_penalty
|
| 73 |
)
|
| 74 |
+
|
| 75 |
+
response = await asyncio.to_thread(generate, item)
|
| 76 |
+
|
| 77 |
+
return {"response": response}
|