Spaces:
Paused
Paused
File size: 610 Bytes
4210028 a40b220 4210028 a40b220 4210028 7cdaf78 | 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 | import gradio as gr
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.api import chat
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.post("/chat/")
async def chat_endpoint(input_data: dict):
response = await chat(input_data)
return {"response": response}
async def gradio_chat(text):
response = await chat({"text": text})
return response
iface = gr.Interface(fn=gradio_chat, inputs="text", outputs="text")
iface.launch(share=True)
|