multi-meeting-QnA / server.py
tykiww's picture
Update server.py
100fffc verified
raw
history blame
1.66 kB
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