Spaces:
Runtime error
Runtime error
David Li
commited on
Commit
·
deb8b74
1
Parent(s):
475e445
feat: basic app
Browse files- Dockerfile +13 -0
- app/__init__.py +0 -0
- app/main.py +27 -0
- requirements.txt +4 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
2 |
+
# you will also find guides on how best to write your Dockerfile
|
3 |
+
|
4 |
+
FROM python:3.9
|
5 |
+
|
6 |
+
WORKDIR /code
|
7 |
+
|
8 |
+
COPY ./requirements.txt requirements.txt
|
9 |
+
RUN pip install -r requirements.txt -v --progress-bar off
|
10 |
+
|
11 |
+
COPY . .
|
12 |
+
|
13 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
app/__init__.py
ADDED
File without changes
|
app/main.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import os
|
3 |
+
from fastapi.responses import StreamingResponse, FileResponse
|
4 |
+
from io import BytesIO
|
5 |
+
from claude_api import Client
|
6 |
+
from fastapi.middleware.cors import CORSMiddleware
|
7 |
+
|
8 |
+
app = FastAPI()
|
9 |
+
|
10 |
+
app.add_middleware(
|
11 |
+
CORSMiddleware,
|
12 |
+
allow_origins=["*"],
|
13 |
+
allow_credentials=True,
|
14 |
+
allow_methods=["*"],
|
15 |
+
allow_headers=["*"],
|
16 |
+
)
|
17 |
+
|
18 |
+
@app.get("/prompt/")
|
19 |
+
async def get_prompt(prompt: str = "Hello World"):
|
20 |
+
"""
|
21 |
+
"""
|
22 |
+
cookie = os.environ.get('CLAUDE_TOKEN', None)
|
23 |
+
claude_api = Client(cookie)
|
24 |
+
new_chat = claude_api.create_new_chat()
|
25 |
+
conversation_id = new_chat['uuid']
|
26 |
+
response = claude_api.send_message(prompt, conversation_id)
|
27 |
+
return all_files
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
requests
|
2 |
+
claude-api
|
3 |
+
fastapi
|
4 |
+
uvicorn
|