jonathanjordan21 commited on
Commit
1ff3bbb
1 Parent(s): 1d3dcfd

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +26 -1
apis/chat_api.py CHANGED
@@ -3,6 +3,7 @@ import markdown2
3
  import os
4
  import sys
5
  import uvicorn
 
6
 
7
  from pathlib import Path
8
  from typing import Union, Optional
@@ -28,6 +29,29 @@ from networks.openai_streamer import OpenaiStreamer
28
  from sentence_transformers import SentenceTransformer
29
  import tiktoken
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  class ChatAPIApp:
32
  def __init__(self):
33
  self.app = FastAPI(
@@ -39,7 +63,8 @@ class ChatAPIApp:
39
  self.setup_routes()
40
  self.embeddings = {
41
  "mxbai-embed-large":SentenceTransformer("mixedbread-ai/mxbai-embed-large-v1"),
42
- "nomic-embed-text": SentenceTransformer("nomic-ai/nomic-embed-text-v1.5", trust_remote_code=True)
 
43
  }
44
 
45
  def get_available_models(self):
 
3
  import os
4
  import sys
5
  import uvicorn
6
+ import requests
7
 
8
  from pathlib import Path
9
  from typing import Union, Optional
 
29
  from sentence_transformers import SentenceTransformer
30
  import tiktoken
31
 
32
+ # class EmbeddingsAPIInference:
33
+ # def __init__(self, model_name):
34
+ # self.model_name=model_name
35
+ # def encode(self, x, headers=None, api_key=None):
36
+ # if api_key:
37
+ # if headers:
38
+ # headers.update({"Authorization": f"Bearer {api_key}"})
39
+ # else:
40
+ # headers = {"Authorization": f"Bearer {api_key}"}
41
+
42
+ # API_URL = "https://api-inference.huggingface.co/models/"+self.model_name
43
+
44
+ # payload = {
45
+ # "inputs": {
46
+ # "source_sentence": "That is a happy person",
47
+ # "sentences": ["That is a happy dog", "That is a very happy person", "Today is a sunny day"],
48
+ # }
49
+ # }
50
+
51
+ # requests.post(API_URL, headers=headers, json=payload).json()
52
+
53
+
54
+
55
  class ChatAPIApp:
56
  def __init__(self):
57
  self.app = FastAPI(
 
63
  self.setup_routes()
64
  self.embeddings = {
65
  "mxbai-embed-large":SentenceTransformer("mixedbread-ai/mxbai-embed-large-v1"),
66
+ "nomic-embed-text": SentenceTransformer("nomic-ai/nomic-embed-text-v1.5", trust_remote_code=True),
67
+ "multilingual-e5-large-instruct":SentenceTransformer("intfloat/multilingual-e5-large-instruct"),
68
  }
69
 
70
  def get_available_models(self):