multi-meeting-QnA / server.py
tykiww's picture
Update server.py
843aa84 verified
raw
history blame
1.37 kB
import os
from utilities.transcripts import VTTTranscriptLoader, DocumentEmbedder
class EmbeddingService:
def __init__(self, conf):
self.keys = self.get_keys()
self.conf = conf
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 0
class QAService:
def __init__(self, conf):
self.keys = get_keys()
self.conf = conf
def run():
return 0