Spaces:
Sleeping
Sleeping
File size: 1,657 Bytes
ece4b12 100fffc 0f115b9 ece4b12 100fffc ece4b12 0f115b9 72ff5b3 ece4b12 aa9a81b ece4b12 d374d8a ece4b12 17c539c ece4b12 3b3a62b ece4b12 3b3a62b ece4b12 100fffc ece4b12 100fffc ece4b12 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import os
from utilities.transcripts import VTTTranscriptLoader, DocumentEmbedder
from utilities.setup import get_files
class EmbeddingService:
def __init__(self, conf):
self.keys = get_files.get_keys()
self.conf = conf
def __enter__(self):
print("Start Embedding Service")
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print("Exiting Embedding Service")
def get_transcripts(self, files):
# Get filepaths and load them in document format
filepaths = [file.name for file in files]
loader = VTTTranscriptLoader(filepaths)
results = loader.load()
return results
def run(self, files):
# gets the files, cleans them, and loads them into pinecone
results = self.get_transcripts(files)
doc_embedder = DocumentEmbedder(
api_keys=self.keys,
files=results,
embedding=self.conf["embeddings"]["embedding"],
index_name=self.conf["embeddings"]["index_name"],
)
# uploads them into pinecone
doc_embedder.embed()
return "complete"
class QAService:
def __init__(self, conf):
self.keys = get_files.get_keys()
self.conf = conf
def __enter__(self):
print("Start QA Service")
return self
def __exit__(self, exc_type, exc_val, exc_tb):
print("Exiting QA Service")
# First embed question
# Next, pass it into pinecone
# Third, retrieve pinecone search
# Structure query
# inference QA model
def run():
return 0 |