|
|
""" |
|
|
Hugging Face Spaces compatible app |
|
|
""" |
|
|
import os |
|
|
import gradio as gr |
|
|
from main import app as fastapi_app |
|
|
|
|
|
|
|
|
def create_gradio_interface(): |
|
|
""" |
|
|
Tạo Gradio interface để deploy trên Hugging Face Spaces |
|
|
""" |
|
|
with gr.Blocks(title="Event Social Media Embeddings API") as demo: |
|
|
gr.Markdown(""" |
|
|
# 🔍 Event Social Media Embeddings API |
|
|
|
|
|
API để embeddings và search multimodal (text + images) với **Jina CLIP v2** + **Qdrant Cloud** |
|
|
|
|
|
## 🌟 Features: |
|
|
- ✅ Multimodal: Text + Image embeddings |
|
|
- ✅ Tiếng Việt: 100% support |
|
|
- ✅ High Performance: ONNX + HNSW |
|
|
- ✅ Cloud: Qdrant Cloud |
|
|
|
|
|
## 📡 API Endpoints: |
|
|
- `POST /index` - Index data |
|
|
- `POST /search` - Hybrid search |
|
|
- `POST /search/text` - Text search |
|
|
- `POST /search/image` - Image search |
|
|
|
|
|
### 🔗 API Docs: |
|
|
Truy cập `/docs` để xem API documentation đầy đủ |
|
|
""") |
|
|
|
|
|
gr.Markdown("### API is running at the `/docs` endpoint") |
|
|
|
|
|
return demo |
|
|
|
|
|
|
|
|
demo = create_gradio_interface() |
|
|
|
|
|
|
|
|
app = gr.mount_gradio_app(fastapi_app, demo, path="/") |
|
|
|
|
|
if __name__ == "__main__": |
|
|
import uvicorn |
|
|
uvicorn.run(app, host="0.0.0.0", port=7860) |
|
|
|