Spaces:
Sleeping
Sleeping
Commit
·
8e6b116
1
Parent(s):
eaeb210
fixed talk to web
Browse files- .gitignore +2 -0
- __pycache__/dependencies.cpython-311.pyc +0 -0
- __pycache__/main.cpython-311.pyc +0 -0
- __pycache__/schemas.cpython-311.pyc +0 -0
- __pycache__/scraper.cpython-311.pyc +0 -0
- __pycache__/utils.cpython-311.pyc +0 -0
- main.py +14 -3
- requirements.txt +1 -2
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
usage.csv
|
2 |
+
temp_95d8748770ec4615942cc78d473f5cee.csv
|
__pycache__/dependencies.cpython-311.pyc
ADDED
Binary file (1.08 kB). View file
|
|
__pycache__/main.cpython-311.pyc
CHANGED
Binary files a/__pycache__/main.cpython-311.pyc and b/__pycache__/main.cpython-311.pyc differ
|
|
__pycache__/schemas.cpython-311.pyc
CHANGED
Binary files a/__pycache__/schemas.cpython-311.pyc and b/__pycache__/schemas.cpython-311.pyc differ
|
|
__pycache__/scraper.cpython-311.pyc
ADDED
Binary file (3.38 kB). View file
|
|
__pycache__/utils.cpython-311.pyc
ADDED
Binary file (2.86 kB). View file
|
|
main.py
CHANGED
@@ -12,6 +12,7 @@ from datetime import datetime, timezone
|
|
12 |
import csv
|
13 |
from dependencies import get_urls_content
|
14 |
from schemas import TextModelResponse,TextModelRequest
|
|
|
15 |
|
16 |
models = {}
|
17 |
|
@@ -66,17 +67,27 @@ async def monitor_service(
|
|
66 |
def root_controller():
|
67 |
return {"status": "healthy"}
|
68 |
|
69 |
-
@app.
|
70 |
async def serve_language_model_controller(request: Request,
|
71 |
body: TextModelRequest ,
|
72 |
urls_content: str = Depends(get_urls_content)) -> TextModelResponse:
|
73 |
prompt = body.prompt + " " + urls_content
|
74 |
-
output =
|
75 |
return TextModelResponse(content=output, ip=request.client.host)
|
76 |
|
77 |
@app.get("/logs")
|
78 |
def get_logs():
|
79 |
-
return FileResponse("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
@app.get(
|
82 |
"/generate/audio",
|
|
|
12 |
import csv
|
13 |
from dependencies import get_urls_content
|
14 |
from schemas import TextModelResponse,TextModelRequest
|
15 |
+
import shutil, uuid
|
16 |
|
17 |
models = {}
|
18 |
|
|
|
67 |
def root_controller():
|
68 |
return {"status": "healthy"}
|
69 |
|
70 |
+
@app.post("/generate/text")
|
71 |
async def serve_language_model_controller(request: Request,
|
72 |
body: TextModelRequest ,
|
73 |
urls_content: str = Depends(get_urls_content)) -> TextModelResponse:
|
74 |
prompt = body.prompt + " " + urls_content
|
75 |
+
output = generate_text(models["text"], prompt, body.temperature)
|
76 |
return TextModelResponse(content=output, ip=request.client.host)
|
77 |
|
78 |
@app.get("/logs")
|
79 |
def get_logs():
|
80 |
+
# return FileResponse("usage.csv", media_type='text/csv', filename="usage.csv")
|
81 |
+
temp_file = f"temp_{uuid.uuid4().hex}.csv"
|
82 |
+
shutil.copyfile("usage.csv", temp_file)
|
83 |
+
|
84 |
+
# Return file and ensure FastAPI deletes it after sending
|
85 |
+
return FileResponse(
|
86 |
+
temp_file,
|
87 |
+
media_type="text/csv",
|
88 |
+
filename="logs.csv",
|
89 |
+
headers={"Content-Disposition": "attachment; filename=logs.csv"}
|
90 |
+
)
|
91 |
|
92 |
@app.get(
|
93 |
"/generate/audio",
|
requirements.txt
CHANGED
@@ -10,5 +10,4 @@ loguru
|
|
10 |
beautifulsoup4
|
11 |
lxml
|
12 |
aiohttp
|
13 |
-
tiktoken
|
14 |
-
scraper
|
|
|
10 |
beautifulsoup4
|
11 |
lxml
|
12 |
aiohttp
|
13 |
+
tiktoken
|
|