multi-meeting-QnA / server.py
tykiww's picture
Update server.py
72ff5b3 verified
raw
history blame
1.56 kB
import os
from utilities.transcripts import VTTTranscriptLoader, DocumentEmbedder
class EmbeddingService:
def __init__(self, conf):
self.keys = self.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_keys(self):
"Get keys required to set up loading"
return {
"pinecone": os.environ["PINECONE_TOKEN"],
"hugginface": os.environ["HUGGINGFACE_TOKEN"],
"openai": "", # leaving this alone for future use.
}
def get_transcripts(self, files):
# Get filepaths and load them in document format
filepaths = [file.name for file in files]
loader = VTTTranscriptLoader(file_path)
results = loader.load()
return results
def run(self, files):
# gets the files, cleans them, and loads them into pinecone
results = 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 results
class QAService:
def __init__(self, conf):
self.keys = get_keys()
self.conf = conf
def run():
return 0