bhaskartripathi commited on
Commit
a15d048
·
1 Parent(s): d99b030

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -15
app.py CHANGED
@@ -93,21 +93,22 @@ class SemanticSearch:
93
  embeddings.append(emb_batch)
94
  embeddings = np.vstack(embeddings)
95
  return embeddings'''
96
- def get_text_embedding(self, texts):
97
- embeddings = []
98
- if isinstance(self.embedder, openai.Engine):
99
- for text in texts:
100
- response = self.embedder.search(
101
- documents=texts,
102
- query=text,
103
- max_rerank=1
104
- )
105
- embeddings.append(response["data"][0]["score"])
106
- elif isinstance(self.embedder, hub.Module):
107
- embeddings = self.embedder(texts)
108
- else:
109
- raise ValueError("Invalid embedder.")
110
- return np.array(embeddings)
 
111
 
112
 
113
  def load_recommender(path, start_page=1):
 
93
  embeddings.append(emb_batch)
94
  embeddings = np.vstack(embeddings)
95
  return embeddings'''
96
+
97
+ def get_text_embedding(self, texts):
98
+ embeddings = []
99
+ if isinstance(self.embedder, openai.Engine):
100
+ for text in texts:
101
+ response = self.embedder.search(
102
+ documents=texts,
103
+ query=text,
104
+ max_rerank=1
105
+ )
106
+ embeddings.append(response["data"][0]["score"])
107
+ elif isinstance(self.embedder, hub.Module):
108
+ embeddings = self.embedder(texts)
109
+ else:
110
+ raise ValueError("Invalid embedder.")
111
+ return np.array(embeddings)
112
 
113
 
114
  def load_recommender(path, start_page=1):