ask-fsdl / ask_fsdl /__init__.py
charlesfrye's picture
rough and ready ask-fsdl backend
407c075
raw
history blame contribute delete
665 Bytes
from dotenv import load_dotenv
load_dotenv()
import os
from . import make_docs
from .chainrunner import *
from .docstore import *
def get_runner(regenerate=False):
from pathlib import Path
filename = Path(FaissDocumentStore.filename).resolve()
if regenerate or not os.path.exists(filename):
texts, metadatas = make_docs.produce_documents()
docsearch = FaissDocumentStore.from_texts(texts, metadatas)
docsearch.to_pickle()
else:
docsearch = FaissDocumentStore.from_pickle()
chain = StuffChain({"model_name": "text-davinci-003", "temperature": 0.0})
query_runner = StuffChainRunner(chain, docsearch)
return query_runner