Spaces:
Runtime error
Runtime error
deveix
commited on
Commit
·
dc43c61
1
Parent(s):
59371b3
fix host
Browse files- Dockerfile +1 -1
- app/main.py +11 -2
Dockerfile
CHANGED
|
@@ -31,7 +31,7 @@ ENV PORT=8000
|
|
| 31 |
EXPOSE 8000
|
| 32 |
|
| 33 |
# execute the command python main.py (in the WORKDIR) to start the app
|
| 34 |
-
CMD ["
|
| 35 |
|
| 36 |
# Tell uvicorn to start spin up our code, which will be running inside the container now
|
| 37 |
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
|
|
|
|
| 31 |
EXPOSE 8000
|
| 32 |
|
| 33 |
# execute the command python main.py (in the WORKDIR) to start the app
|
| 34 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
| 35 |
|
| 36 |
# Tell uvicorn to start spin up our code, which will be running inside the container now
|
| 37 |
# CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "80"]
|
app/main.py
CHANGED
|
@@ -6,6 +6,7 @@ from langchain.embeddings import SentenceTransformerEmbeddings
|
|
| 6 |
from langchain_community.vectorstores import MongoDBAtlasVectorSearch
|
| 7 |
import uvicorn
|
| 8 |
from dotenv import load_dotenv
|
|
|
|
| 9 |
|
| 10 |
load_dotenv()
|
| 11 |
|
|
@@ -31,6 +32,14 @@ vector_search = MongoDBAtlasVectorSearch.from_connection_string(
|
|
| 31 |
# FastAPI application setup
|
| 32 |
app = FastAPI()
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# Existing API endpoints
|
| 35 |
@app.get("/")
|
| 36 |
async def read_root():
|
|
@@ -72,5 +81,5 @@ async def get_answer(item: Item, token: str = Depends(verify_token)):
|
|
| 72 |
# If there's an error, return a 500 error with the error's details
|
| 73 |
raise HTTPException(status_code=500, detail=str(e))
|
| 74 |
|
| 75 |
-
if __name__ == "__main__":
|
| 76 |
-
|
|
|
|
| 6 |
from langchain_community.vectorstores import MongoDBAtlasVectorSearch
|
| 7 |
import uvicorn
|
| 8 |
from dotenv import load_dotenv
|
| 9 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 10 |
|
| 11 |
load_dotenv()
|
| 12 |
|
|
|
|
| 32 |
# FastAPI application setup
|
| 33 |
app = FastAPI()
|
| 34 |
|
| 35 |
+
app.add_middleware(
|
| 36 |
+
CORSMiddleware,
|
| 37 |
+
allow_origins=["*"],
|
| 38 |
+
allow_credentials=True,
|
| 39 |
+
allow_methods=["*"],
|
| 40 |
+
allow_headers=["*"],
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
# Existing API endpoints
|
| 44 |
@app.get("/")
|
| 45 |
async def read_root():
|
|
|
|
| 81 |
# If there's an error, return a 500 error with the error's details
|
| 82 |
raise HTTPException(status_code=500, detail=str(e))
|
| 83 |
|
| 84 |
+
# if __name__ == "__main__":
|
| 85 |
+
# uvicorn.run("main:app", host="0.0.0.0", port=8080, reload=False)
|