Spaces:
Running
Running
jonathanjordan21
commited on
Update apis/chat_api.py
Browse files- apis/chat_api.py +7 -2
apis/chat_api.py
CHANGED
@@ -337,6 +337,11 @@ class ChatAPIApp:
|
|
337 |
|
338 |
|
339 |
class EmbeddingRequest(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
340 |
model: str
|
341 |
prompt: str
|
342 |
options: Optional[dict] = None
|
@@ -345,7 +350,7 @@ class ChatAPIApp:
|
|
345 |
try:
|
346 |
model = request.model
|
347 |
model_kwargs = request.options
|
348 |
-
embeddings = self.embeddings[model].encode(request.
|
349 |
return {
|
350 |
"object":"list",
|
351 |
"data":[
|
@@ -357,7 +362,7 @@ class ChatAPIApp:
|
|
357 |
except ValueError as e:
|
358 |
raise HTTPException(status_code=400, detail=str(e))
|
359 |
|
360 |
-
def get_embeddings_ollama(self, request:
|
361 |
try:
|
362 |
model = request.model
|
363 |
model_kwargs = request.options
|
|
|
337 |
|
338 |
|
339 |
class EmbeddingRequest(BaseModel):
|
340 |
+
model: str
|
341 |
+
input: str
|
342 |
+
options: Optional[dict] = None
|
343 |
+
|
344 |
+
class OllamaEmbeddingRequest(BaseModel):
|
345 |
model: str
|
346 |
prompt: str
|
347 |
options: Optional[dict] = None
|
|
|
350 |
try:
|
351 |
model = request.model
|
352 |
model_kwargs = request.options
|
353 |
+
embeddings = self.embeddings[model].encode(request.input, convert_to_tensor=True)#, **model_kwargs)
|
354 |
return {
|
355 |
"object":"list",
|
356 |
"data":[
|
|
|
362 |
except ValueError as e:
|
363 |
raise HTTPException(status_code=400, detail=str(e))
|
364 |
|
365 |
+
def get_embeddings_ollama(self, request: OllamaEmbeddingRequest, api_key: str = Depends(extract_api_key)):
|
366 |
try:
|
367 |
model = request.model
|
368 |
model_kwargs = request.options
|