Spaces:
Running
Running
chore: styling app
Browse files
lightweight_embeddings/__init__.py
CHANGED
|
@@ -25,10 +25,38 @@ from gradio.routes import mount_gradio_app
|
|
| 25 |
__version__ = "1.0.0"
|
| 26 |
__author__ = "lamhieu"
|
| 27 |
__description__ = "Fast, lightweight, multilingual embeddings solution."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# Set your embeddings API URL here (change host/port if needed)
|
| 30 |
EMBEDDINGS_API_URL = "http://localhost:7860/v1/embeddings"
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Initialize FastAPI application
|
| 33 |
app = FastAPI(
|
| 34 |
title="Lightweight Embeddings API",
|
|
@@ -86,19 +114,6 @@ def create_main_interface():
|
|
| 86 |
"""
|
| 87 |
Creates a Gradio Blocks interface showing project info and an embeddings playground.
|
| 88 |
"""
|
| 89 |
-
# Metadata to be displayed
|
| 90 |
-
root_data = {
|
| 91 |
-
"project": "Lightweight Embeddings Service",
|
| 92 |
-
"version": "1.0.0",
|
| 93 |
-
"description": (
|
| 94 |
-
"Fast and efficient multilingual text and image embeddings service "
|
| 95 |
-
"powered by sentence-transformers, supporting 100+ languages and multi-modal inputs"
|
| 96 |
-
),
|
| 97 |
-
"docs": "https://lamhieu-lightweight-embeddings.hf.space/docs",
|
| 98 |
-
"github": "https://github.com/lh0x00/lightweight-embeddings",
|
| 99 |
-
"spaces": "https://huggingface.co/spaces/lamhieu/lightweight-embeddings",
|
| 100 |
-
}
|
| 101 |
-
|
| 102 |
# Available model options for the dropdown
|
| 103 |
model_options = [
|
| 104 |
"multilingual-e5-small",
|
|
@@ -109,20 +124,7 @@ def create_main_interface():
|
|
| 109 |
|
| 110 |
with gr.Blocks(title="Lightweight Embeddings", theme="default") as demo:
|
| 111 |
# Project Info
|
| 112 |
-
gr.Markdown(
|
| 113 |
-
"""
|
| 114 |
-
## π **Lightweight Embeddings API**
|
| 115 |
-
The **Lightweight Embeddings API** is a fast, free, and multilingual service designed for generating embeddings and reranking with support for both **text** and **image** inputs. Get started below by exploring our interactive playground or using the cURL examples provided.
|
| 116 |
-
---
|
| 117 |
-
### π¦ Features
|
| 118 |
-
- **Multilingual Support**: Process inputs in multiple languages.
|
| 119 |
-
- **Versatile API**: Generate embeddings, perform ranking, and more.
|
| 120 |
-
- **Developer-Friendly**: Quick to integrate with documentation and examples.
|
| 121 |
-
|
| 122 |
-
### π Links
|
| 123 |
-
- [Documentation]({root_data["docs"]}) | [GitHub]({root_data["github"]}) | [Playground]({root_data["spaces"]})
|
| 124 |
-
"""
|
| 125 |
-
)
|
| 126 |
|
| 127 |
# Split Layout: Playground and cURL Examples
|
| 128 |
with gr.Row():
|
|
|
|
| 25 |
__version__ = "1.0.0"
|
| 26 |
__author__ = "lamhieu"
|
| 27 |
__description__ = "Fast, lightweight, multilingual embeddings solution."
|
| 28 |
+
__metadata__ = {
|
| 29 |
+
"project": "Lightweight Embeddings Service",
|
| 30 |
+
"version": __version__,
|
| 31 |
+
"description": (
|
| 32 |
+
"Fast and efficient multilingual text and image embeddings service "
|
| 33 |
+
"powered by sentence-transformers, supporting 100+ languages and multi-modal inputs"
|
| 34 |
+
),
|
| 35 |
+
"docs": "https://lamhieu-lightweight-embeddings.hf.space/docs",
|
| 36 |
+
"github": "https://github.com/lh0x00/lightweight-embeddings",
|
| 37 |
+
"spaces": "https://huggingface.co/spaces/lamhieu/lightweight-embeddings",
|
| 38 |
+
}
|
| 39 |
|
| 40 |
# Set your embeddings API URL here (change host/port if needed)
|
| 41 |
EMBEDDINGS_API_URL = "http://localhost:7860/v1/embeddings"
|
| 42 |
|
| 43 |
+
# Markdown description for the main interface
|
| 44 |
+
APP_DESCRIPTION = f"""\
|
| 45 |
+
## π **Lightweight Embeddings API**
|
| 46 |
+
|
| 47 |
+
The **Lightweight Embeddings API** is a fast, free, and multilingual service designed for generating embeddings and reranking with support for both **text** and **image** inputs. Get started below by exploring our interactive playground or using the cURL examples provided.
|
| 48 |
+
|
| 49 |
+
---
|
| 50 |
+
|
| 51 |
+
### π¦ Features
|
| 52 |
+
- **Multilingual Support**: Process inputs in multiple languages.
|
| 53 |
+
- **Versatile API**: Generate embeddings, perform ranking, and more.
|
| 54 |
+
- **Developer-Friendly**: Quick to integrate with documentation and examples.
|
| 55 |
+
|
| 56 |
+
### π Links
|
| 57 |
+
- [Documentation]({__metadata__["docs"]}) | [GitHub]({__metadata__["github"]}) | [Playground]({__metadata__["spaces"]})
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
# Initialize FastAPI application
|
| 61 |
app = FastAPI(
|
| 62 |
title="Lightweight Embeddings API",
|
|
|
|
| 114 |
"""
|
| 115 |
Creates a Gradio Blocks interface showing project info and an embeddings playground.
|
| 116 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
# Available model options for the dropdown
|
| 118 |
model_options = [
|
| 119 |
"multilingual-e5-small",
|
|
|
|
| 124 |
|
| 125 |
with gr.Blocks(title="Lightweight Embeddings", theme="default") as demo:
|
| 126 |
# Project Info
|
| 127 |
+
gr.Markdown(APP_DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
# Split Layout: Playground and cURL Examples
|
| 130 |
with gr.Row():
|