Spaces:
Running
Running
fahmiaziz98
commited on
Commit
·
f55bc7f
1
Parent(s):
da0b1f1
[FIX Error]: local variable 'texts' referenced before assignment
Browse files
src/api/routers/embedding.py
CHANGED
|
@@ -75,10 +75,12 @@ async def create_embeddings(
|
|
| 75 |
HTTPException: On validation or generation errors
|
| 76 |
"""
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
| 81 |
|
|
|
|
| 82 |
kwargs = extract_embedding_kwargs(request)
|
| 83 |
|
| 84 |
model = manager.get_model(request.model)
|
|
@@ -153,11 +155,12 @@ async def create_sparse_embedding(
|
|
| 153 |
Raises:
|
| 154 |
HTTPException: On validation or generation errors
|
| 155 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
try:
|
| 158 |
-
if isinstance(request.input, str):
|
| 159 |
-
texts = [request.input]
|
| 160 |
-
|
| 161 |
kwargs = extract_embedding_kwargs(request)
|
| 162 |
|
| 163 |
model = manager.get_model(request.model)
|
|
|
|
| 75 |
HTTPException: On validation or generation errors
|
| 76 |
"""
|
| 77 |
|
| 78 |
+
texts = [request.input] if isinstance(request.input, str) else request.input
|
| 79 |
+
|
| 80 |
+
if not texts or not isinstance(texts, list):
|
| 81 |
+
raise ValidationError("Input must be a non-empty list or string.")
|
| 82 |
|
| 83 |
+
try:
|
| 84 |
kwargs = extract_embedding_kwargs(request)
|
| 85 |
|
| 86 |
model = manager.get_model(request.model)
|
|
|
|
| 155 |
Raises:
|
| 156 |
HTTPException: On validation or generation errors
|
| 157 |
"""
|
| 158 |
+
texts = [request.input] if isinstance(request.input, str) else request.input
|
| 159 |
+
|
| 160 |
+
if not texts or not isinstance(texts, list):
|
| 161 |
+
raise ValidationError("Input must be a non-empty list or string.")
|
| 162 |
|
| 163 |
try:
|
|
|
|
|
|
|
|
|
|
| 164 |
kwargs = extract_embedding_kwargs(request)
|
| 165 |
|
| 166 |
model = manager.get_model(request.model)
|