lamhieu commited on
Commit
9001620
Β·
1 Parent(s): 073aa83

chore: update something

Browse files
lightweight_embeddings/__init__.py CHANGED
@@ -63,21 +63,17 @@ EMBEDDINGS_API_URL = "http://localhost:7860/v1/embeddings"
63
  APP_DESCRIPTION = f"""
64
  # πŸš€ **Lightweight Embeddings API**
65
 
66
- 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.
67
 
68
- ### ✨ Key Features
69
 
70
- - **Free, Unlimited, and Multilingual**: A fully free API service with no usage limits, capable of processing text in over 100+ languages to support global applications seamlessly.
71
- - **Advanced Embedding and Reranking**: Generate high-quality text and image-text embeddings using state-of-the-art models, alongside robust reranking capabilities for enhanced results.
72
- - **Optimized and Flexible**: Built for speed with lightweight transformer models, efficient backends for rapid inference on low-resource systems, and support for diverse use cases with models.
73
- - **Production-Ready with Ease of Use**: Deploy effortlessly using Docker for a hassle-free setup, and experiment interactively through a **Gradio-powered playground** with comprehensive REST API documentation.
 
74
 
75
- ### πŸ”’ Privacy and Data Transparency
76
-
77
- - **Minimal Data Collection**: This API respects your privacy by design. It does not store or log any input data (text or images) provided by users. Only anonymous usage counts (IDs for statistical purposes) are recorded to monitor and improve the service.
78
- - **Open Source and Transparent**: The API is fully open source, ensuring transparency and allowing users to inspect the code for themselves. This guarantees trust and confidence in how the service handles your data.
79
-
80
- ### πŸ”— Links
81
  - [Documentation]({__metadata__["docs"]}) | [GitHub]({__metadata__["github"]}) | [Playground]({__metadata__["spaces"]})
82
  """
83
 
 
63
  APP_DESCRIPTION = f"""
64
  # πŸš€ **Lightweight Embeddings API**
65
 
66
+ 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.
67
 
68
+ ### ✨ Features & Privacy
69
 
70
+ - **Free & Multilingual**: Unlimited API service supporting 100+ languages with no usage restrictions
71
+ - **Advanced Processing**: High-quality text and image-text embeddings using state-of-the-art models with reranking capabilities
72
+ - **Privacy-First**: No storage of input data (text/images), only anonymous usage statistics for service improvement
73
+ - **Production-Ready**: Docker deployment, interactive Gradio playground, and comprehensive REST API documentation
74
+ - **Open & Efficient**: Fully open-source codebase using lightweight transformer models for rapid inference
75
 
76
+ ### πŸ”— Resources
 
 
 
 
 
77
  - [Documentation]({__metadata__["docs"]}) | [GitHub]({__metadata__["github"]}) | [Playground]({__metadata__["spaces"]})
78
  """
79
 
lightweight_embeddings/router.py CHANGED
@@ -171,8 +171,6 @@ async def create_embeddings(
171
  input_data=request.input, modality=mkind.value
172
  )
173
 
174
- background_tasks.add_task(analytics.access, request.model)
175
-
176
  # 4) Estimate tokens for text only
177
  total_tokens = 0
178
  if mkind == ModelKind.TEXT:
@@ -188,6 +186,10 @@ async def create_embeddings(
188
  },
189
  }
190
 
 
 
 
 
191
  for idx, emb in enumerate(embeddings):
192
  resp["data"].append(
193
  {
@@ -227,7 +229,9 @@ async def rank_candidates(request: RankRequest, background_tasks: BackgroundTask
227
  modality=mkind.value,
228
  )
229
 
230
- background_tasks.add_task(analytics.access, request.model)
 
 
231
 
232
  return results
233
 
 
171
  input_data=request.input, modality=mkind.value
172
  )
173
 
 
 
174
  # 4) Estimate tokens for text only
175
  total_tokens = 0
176
  if mkind == ModelKind.TEXT:
 
186
  },
187
  }
188
 
189
+ background_tasks.add_task(
190
+ analytics.access, request.model, resp["usage"]["total_tokens"]
191
+ )
192
+
193
  for idx, emb in enumerate(embeddings):
194
  resp["data"].append(
195
  {
 
229
  modality=mkind.value,
230
  )
231
 
232
+ background_tasks.add_task(
233
+ analytics.access, request.model, results["usage"]["total_tokens"]
234
+ )
235
 
236
  return results
237