|
from fastapi import FastAPI, Depends, HTTPException, Query |
|
from transformers import AutoModelForCausalLM, AutoTokenizer |
|
from typing import List |
|
from fastapi.responses import HTMLResponse |
|
from fastapi.staticfiles import StaticFiles |
|
|
|
app = FastAPI() |
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static") |
|
|
|
@app.get("/", response_class=HTMLResponse) |
|
async def read_root(): |
|
with open("static/index.html", "r") as f: |
|
content = f.read() |
|
return HTMLResponse(content=content) |
|
|
|
|
|
|
|
|
|
|
|
@app.post("/chat/") |
|
def chat(user_input: str, api_key: str): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {"response": f"user input: {user_input}, api_key: {api_key}"} |
|
|