Spaces:
Sleeping
Sleeping
Commit
·
94962e5
1
Parent(s):
415ac2b
Loaded the embedding model via api
Browse files
my_agent/utils/models_loader.py
CHANGED
|
@@ -7,6 +7,7 @@ from dotenv import load_dotenv
|
|
| 7 |
load_dotenv()
|
| 8 |
import os
|
| 9 |
import requests
|
|
|
|
| 10 |
# from langchain_huggingface import HuggingFaceEndpoint
|
| 11 |
os.environ['HUGGINGFACEHUB_ACCESS_TOKEN']=os.getenv('HUGGINGFACEHUB_ACCESS_TOKEN')
|
| 12 |
login(os.environ['HUGGINGFACEHUB_ACCESS_TOKEN'])
|
|
@@ -38,7 +39,8 @@ class HFEmbeddingAPI:
|
|
| 38 |
json={"inputs": texts}
|
| 39 |
)
|
| 40 |
response.raise_for_status()
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
# Instantiate your API-backed "SentenceTransformer"
|
| 44 |
ST = HFEmbeddingAPI(
|
|
|
|
| 7 |
load_dotenv()
|
| 8 |
import os
|
| 9 |
import requests
|
| 10 |
+
import numpy as np
|
| 11 |
# from langchain_huggingface import HuggingFaceEndpoint
|
| 12 |
os.environ['HUGGINGFACEHUB_ACCESS_TOKEN']=os.getenv('HUGGINGFACEHUB_ACCESS_TOKEN')
|
| 13 |
login(os.environ['HUGGINGFACEHUB_ACCESS_TOKEN'])
|
|
|
|
| 39 |
json={"inputs": texts}
|
| 40 |
)
|
| 41 |
response.raise_for_status()
|
| 42 |
+
embeddings=response.json()
|
| 43 |
+
return np.array(embeddings[0]) if len(embeddings) == 1 else np.array(embeddings)
|
| 44 |
|
| 45 |
# Instantiate your API-backed "SentenceTransformer"
|
| 46 |
ST = HFEmbeddingAPI(
|