Spaces:
Sleeping
Sleeping
jonathanjordan21
commited on
Commit
•
87bcf8e
1
Parent(s):
8f010a7
Update apis/chat_api.py
Browse files- apis/chat_api.py +4 -2
apis/chat_api.py
CHANGED
@@ -26,6 +26,7 @@ from networks.huggingchat_streamer import HuggingchatStreamer
|
|
26 |
from networks.openai_streamer import OpenaiStreamer
|
27 |
|
28 |
from sentence_transformers import SentenceTransformer
|
|
|
29 |
|
30 |
class ChatAPIApp:
|
31 |
def __init__(self):
|
@@ -311,7 +312,7 @@ class ChatAPIApp:
|
|
311 |
|
312 |
class EmbeddingRequest(BaseModel):
|
313 |
model: str
|
314 |
-
input:
|
315 |
options: Optional[dict] = None
|
316 |
|
317 |
class OllamaEmbeddingRequest(BaseModel):
|
@@ -323,7 +324,8 @@ class ChatAPIApp:
|
|
323 |
try:
|
324 |
model = request.model
|
325 |
model_kwargs = request.options
|
326 |
-
|
|
|
327 |
return {
|
328 |
"object":"list",
|
329 |
"data":[
|
|
|
26 |
from networks.openai_streamer import OpenaiStreamer
|
27 |
|
28 |
from sentence_transformers import SentenceTransformer
|
29 |
+
import tiktoken
|
30 |
|
31 |
class ChatAPIApp:
|
32 |
def __init__(self):
|
|
|
312 |
|
313 |
class EmbeddingRequest(BaseModel):
|
314 |
model: str
|
315 |
+
input: list
|
316 |
options: Optional[dict] = None
|
317 |
|
318 |
class OllamaEmbeddingRequest(BaseModel):
|
|
|
324 |
try:
|
325 |
model = request.model
|
326 |
model_kwargs = request.options
|
327 |
+
encoding = tiktoken.get_encoding("cl100k_base")
|
328 |
+
embeddings = self.embeddings[model].encode(encoding.decode(request.input), convert_to_tensor=True)#, **model_kwargs)
|
329 |
return {
|
330 |
"object":"list",
|
331 |
"data":[
|