Spaces:
Paused
Paused
Download app.py from Ashad001/llama3hackathon: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/Ashad001/llama3hackathon/resolve/main/app.py
- Command line
-
hf download hf://spaces/Ashad001/llama3hackathon/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Ashad001/llama3hackathon/resolve/main/app.py
610 Bytes
| 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=["*"], | |
| ) | |
| 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) | |