-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/logo' into deploy/dev
- Loading branch information
Showing
36 changed files
with
131 additions
and
156 deletions.
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
api/core/model_providers/models/embedding/xinference_embedding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 38 additions & 5 deletions
43
api/core/third_party/langchain/embeddings/xinference_embedding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,54 @@ | ||
from typing import List | ||
from typing import List, Optional, Any | ||
|
||
import numpy as np | ||
from langchain.embeddings import XinferenceEmbeddings | ||
from langchain.embeddings.base import Embeddings | ||
from xinference_client.client.restful.restful_client import Client | ||
|
||
|
||
class XinferenceEmbedding(XinferenceEmbeddings): | ||
class XinferenceEmbeddings(Embeddings): | ||
client: Any | ||
server_url: Optional[str] | ||
"""URL of the xinference server""" | ||
model_uid: Optional[str] | ||
"""UID of the launched model""" | ||
|
||
def __init__( | ||
self, server_url: Optional[str] = None, model_uid: Optional[str] = None | ||
): | ||
|
||
super().__init__() | ||
|
||
if server_url is None: | ||
raise ValueError("Please provide server URL") | ||
|
||
if model_uid is None: | ||
raise ValueError("Please provide the model UID") | ||
|
||
self.server_url = server_url | ||
|
||
self.model_uid = model_uid | ||
|
||
self.client = Client(server_url) | ||
|
||
def embed_documents(self, texts: List[str]) -> List[List[float]]: | ||
vectors = super().embed_documents(texts) | ||
model = self.client.get_model(self.model_uid) | ||
|
||
embeddings = [ | ||
model.create_embedding(text)["data"][0]["embedding"] for text in texts | ||
] | ||
vectors = [list(map(float, e)) for e in embeddings] | ||
normalized_vectors = [(vector / np.linalg.norm(vector)).tolist() for vector in vectors] | ||
|
||
return normalized_vectors | ||
|
||
def embed_query(self, text: str) -> List[float]: | ||
vector = super().embed_query(text) | ||
model = self.client.get_model(self.model_uid) | ||
|
||
embedding_res = model.create_embedding(text) | ||
|
||
embedding = embedding_res["data"][0]["embedding"] | ||
|
||
vector = list(map(float, embedding)) | ||
normalized_vector = (vector / np.linalg.norm(vector)).tolist() | ||
|
||
return normalized_vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
web/app/components/header/account-setting/members-page/index.module.css
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
|
||
.emailBackground { | ||
background-color: white !important; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.