Spaces:
Sleeping
Sleeping
SebastianSchramm
commited on
Commit
•
2dcc710
1
Parent(s):
85a84bf
add first version
Browse files- Dockerfile +13 -0
- requirements.txt +36 -0
- server.py +30 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11-slim
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
COPY . .
|
8 |
+
|
9 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
10 |
+
|
11 |
+
COPY --chown=user . /app
|
12 |
+
|
13 |
+
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|
requirements.txt
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
annotated-types==0.7.0 ; python_version >= "3.11" and python_version < "4.0"
|
2 |
+
anyio==4.4.0 ; python_version >= "3.11" and python_version < "4.0"
|
3 |
+
certifi==2024.6.2 ; python_version >= "3.11" and python_version < "4.0"
|
4 |
+
click==8.1.7 ; python_version >= "3.11" and python_version < "4.0"
|
5 |
+
colorama==0.4.6 ; python_version >= "3.11" and python_version < "4.0" and (sys_platform == "win32" or platform_system == "Windows")
|
6 |
+
dnspython==2.6.1 ; python_version >= "3.11" and python_version < "4.0"
|
7 |
+
email-validator==2.2.0 ; python_version >= "3.11" and python_version < "4.0"
|
8 |
+
fastapi-cli==0.0.4 ; python_version >= "3.11" and python_version < "4.0"
|
9 |
+
fastapi==0.111.0 ; python_version >= "3.11" and python_version < "4.0"
|
10 |
+
h11==0.14.0 ; python_version >= "3.11" and python_version < "4.0"
|
11 |
+
httpcore==1.0.5 ; python_version >= "3.11" and python_version < "4.0"
|
12 |
+
httptools==0.6.1 ; python_version >= "3.11" and python_version < "4.0"
|
13 |
+
httpx==0.27.0 ; python_version >= "3.11" and python_version < "4.0"
|
14 |
+
idna==3.7 ; python_version >= "3.11" and python_version < "4.0"
|
15 |
+
jinja2==3.1.4 ; python_version >= "3.11" and python_version < "4.0"
|
16 |
+
markdown-it-py==3.0.0 ; python_version >= "3.11" and python_version < "4.0"
|
17 |
+
markupsafe==2.1.5 ; python_version >= "3.11" and python_version < "4.0"
|
18 |
+
mdurl==0.1.2 ; python_version >= "3.11" and python_version < "4.0"
|
19 |
+
orjson==3.10.5 ; python_version >= "3.11" and python_version < "4.0"
|
20 |
+
pydantic-core==2.18.4 ; python_version >= "3.11" and python_version < "4.0"
|
21 |
+
pydantic==2.7.4 ; python_version >= "3.11" and python_version < "4.0"
|
22 |
+
pygments==2.18.0 ; python_version >= "3.11" and python_version < "4.0"
|
23 |
+
python-dotenv==1.0.1 ; python_version >= "3.11" and python_version < "4.0"
|
24 |
+
python-multipart==0.0.9 ; python_version >= "3.11" and python_version < "4.0"
|
25 |
+
pyyaml==6.0.1 ; python_version >= "3.11" and python_version < "4.0"
|
26 |
+
rich==13.7.1 ; python_version >= "3.11" and python_version < "4.0"
|
27 |
+
shellingham==1.5.4 ; python_version >= "3.11" and python_version < "4.0"
|
28 |
+
sniffio==1.3.1 ; python_version >= "3.11" and python_version < "4.0"
|
29 |
+
starlette==0.37.2 ; python_version >= "3.11" and python_version < "4.0"
|
30 |
+
typer==0.12.3 ; python_version >= "3.11" and python_version < "4.0"
|
31 |
+
typing-extensions==4.12.2 ; python_version >= "3.11" and python_version < "4.0"
|
32 |
+
ujson==5.10.0 ; python_version >= "3.11" and python_version < "4.0"
|
33 |
+
uvicorn[standard]==0.30.1 ; python_version >= "3.11" and python_version < "4.0"
|
34 |
+
uvloop==0.19.0 ; (sys_platform != "win32" and sys_platform != "cygwin") and platform_python_implementation != "PyPy" and python_version >= "3.11" and python_version < "4.0"
|
35 |
+
watchfiles==0.22.0 ; python_version >= "3.11" and python_version < "4.0"
|
36 |
+
websockets==12.0 ; python_version >= "3.11" and python_version < "4.0"
|
server.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import logging
|
2 |
+
|
3 |
+
from fastapi import FastAPI
|
4 |
+
from pydantic import BaseModel
|
5 |
+
|
6 |
+
|
7 |
+
logging.basicConfig()
|
8 |
+
logger = logging.getLogger(__name__)
|
9 |
+
logger.setLevel(logging.INFO)
|
10 |
+
|
11 |
+
|
12 |
+
class InputLoad(BaseModel):
|
13 |
+
question: str
|
14 |
+
|
15 |
+
|
16 |
+
class ResponseLoad(BaseModel):
|
17 |
+
answer: str
|
18 |
+
|
19 |
+
|
20 |
+
app = FastAPI()
|
21 |
+
|
22 |
+
|
23 |
+
@app.get("/health")
|
24 |
+
def health_check():
|
25 |
+
return {"server": "running"}
|
26 |
+
|
27 |
+
|
28 |
+
@app.post("/answer")
|
29 |
+
async def receive(input_load: InputLoad) -> ResponseLoad:
|
30 |
+
return ResponseLoad(answer="Hi, happy to help you with that. According to my information this is possible! Hope that was helpful!")
|