Spaces:
Sleeping
Sleeping
File size: 916 Bytes
dab34f2 dd6015f dab34f2 c575e18 b916cdf c575e18 572d4e2 dd6015f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
from fastapi import FastAPI, Query, Request
from fastapi.responses import JSONResponse, HTMLResponse
from transformers import pipeline
import subprocess
import httpx
from transformers import pipeline
app = FastAPI()
pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
@app.get("/infer_t5")
def t5(input):
output = pipe_flan(input)
return {"output": output[0]["generated_text"]}
@app.get("/", response_class=HTMLResponse)
async def streamlit_proxy(request: Request):
async with httpx.AsyncClient() as client:
streamlit_url = "http://localhost:8501/"
response = await client.get(streamlit_url)
return HTMLResponse(content=response.text, status_code=response.status_code)
@app.on_event("startup")
async def startup_event():
# Запуск Streamlit в отдельном процессе
subprocess.Popen(["streamlit", "run", "streamlit_app.py"]) |