Spaces:
Sleeping
Sleeping
tarikko
commited on
Commit
·
c5b694d
1
Parent(s):
553f828
cors
Browse files
app.py
CHANGED
@@ -6,6 +6,9 @@ from transformers import AutoTokenizer, AutoModel, AutoModelForCausalLM
|
|
6 |
from fastapi import FastAPI, HTTPException
|
7 |
from fastapi.responses import JSONResponse
|
8 |
|
|
|
|
|
|
|
9 |
embedding_model_name = "intfloat/multilingual-e5-large"
|
10 |
embedding_tokenizer = AutoTokenizer.from_pretrained(embedding_model_name)
|
11 |
embedding_model = AutoModel.from_pretrained(embedding_model_name)
|
@@ -107,6 +110,13 @@ def rag_pipeline(query):
|
|
107 |
|
108 |
app = FastAPI()
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
@app.get("/generate")
|
111 |
async def generate(query: str = None):
|
112 |
if not query:
|
|
|
6 |
from fastapi import FastAPI, HTTPException
|
7 |
from fastapi.responses import JSONResponse
|
8 |
|
9 |
+
from fastapi.middleware.cors import CORSMiddleware
|
10 |
+
|
11 |
+
|
12 |
embedding_model_name = "intfloat/multilingual-e5-large"
|
13 |
embedding_tokenizer = AutoTokenizer.from_pretrained(embedding_model_name)
|
14 |
embedding_model = AutoModel.from_pretrained(embedding_model_name)
|
|
|
110 |
|
111 |
app = FastAPI()
|
112 |
|
113 |
+
app.add_middleware(
|
114 |
+
CORSMiddleware,
|
115 |
+
allow_origins=["*"], # Replace '*' with specific domains in production for security
|
116 |
+
allow_credentials=True,
|
117 |
+
allow_methods=["*"],
|
118 |
+
allow_headers=["*"],
|
119 |
+
)
|
120 |
@app.get("/generate")
|
121 |
async def generate(query: str = None):
|
122 |
if not query:
|