Spaces:
Build error
Build error
fix non pickleable object
Browse files
app.py
CHANGED
@@ -113,8 +113,8 @@ class EmbeddingGenerator:
|
|
113 |
|
114 |
|
115 |
class MyEmbeddingFunction(EmbeddingFunction):
|
116 |
-
def __init__(self,
|
117 |
-
self.embedding_generator =
|
118 |
|
119 |
def __call__(self, input: Documents) -> (Embeddings, list):
|
120 |
embeddings_with_metadata = [self.embedding_generator.compute_embeddings(doc.page_content) for doc in input]
|
@@ -122,7 +122,7 @@ class MyEmbeddingFunction(EmbeddingFunction):
|
|
122 |
metadata = [item[1] for item in embeddings_with_metadata]
|
123 |
embeddings_flattened = [emb for sublist in embeddings for emb in sublist]
|
124 |
metadata_flattened = [meta for sublist in metadata for meta in sublist]
|
125 |
-
return embeddings_flattened, metadata_flattened
|
126 |
|
127 |
def load_documents(file_path: str, mode: str = "elements"):
|
128 |
loader = UnstructuredFileLoader(file_path, mode=mode)
|
|
|
113 |
|
114 |
|
115 |
class MyEmbeddingFunction(EmbeddingFunction):
|
116 |
+
def __init__(self, model_name: str, token: str, intention_client):
|
117 |
+
self.embedding_generator = EmbeddingGenerator(model_name, token, intention_client)
|
118 |
|
119 |
def __call__(self, input: Documents) -> (Embeddings, list):
|
120 |
embeddings_with_metadata = [self.embedding_generator.compute_embeddings(doc.page_content) for doc in input]
|
|
|
122 |
metadata = [item[1] for item in embeddings_with_metadata]
|
123 |
embeddings_flattened = [emb for sublist in embeddings for emb in sublist]
|
124 |
metadata_flattened = [meta for sublist in metadata for meta in sublist]
|
125 |
+
return embeddings_flattened, metadata_flattened
|
126 |
|
127 |
def load_documents(file_path: str, mode: str = "elements"):
|
128 |
loader = UnstructuredFileLoader(file_path, mode=mode)
|