Spaces:
Sleeping
Sleeping
Commit
·
2cd7197
1
Parent(s):
a81da59
Update main.py
Browse files
main.py
CHANGED
@@ -1,10 +1,18 @@
|
|
1 |
-
from fastapi import
|
2 |
from pydantic import BaseModel
|
3 |
from huggingface_hub import InferenceClient
|
4 |
|
5 |
app = FastAPI()
|
6 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
class InputData(BaseModel):
|
9 |
input: str
|
10 |
temperature: float = 0.2
|
|
|
1 |
+
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
|
2 |
from pydantic import BaseModel
|
3 |
from huggingface_hub import InferenceClient
|
4 |
|
5 |
app = FastAPI()
|
6 |
client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
7 |
|
8 |
+
app.add_middleware(
|
9 |
+
CORSMiddleware,
|
10 |
+
allow_origins=["*"],
|
11 |
+
allow_credentials=True,
|
12 |
+
allow_methods=["*"],
|
13 |
+
allow_headers=["*"],
|
14 |
+
)
|
15 |
+
|
16 |
class InputData(BaseModel):
|
17 |
input: str
|
18 |
temperature: float = 0.2
|