Spaces:
Sleeping
Sleeping
File size: 743 Bytes
1cb46fc 10330bc 99a3f34 5b3feea 10330bc 5b3feea 10330bc 5b3feea 1cb46fc 5b3feea 10330bc |
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 |
from langchain.chains.qa_with_sources.retrieval import RetrievalQAWithSourcesChain
from langchain.chat_models import ChatOpenAI
import logging
import os
from langchain.chains import ConversationalRetrievalChain
from src.config import Config
def load_model():
model = ChatOpenAI(model_name=Config.model_name,
temperature=Config.temperature,
streaming=Config.streaming)
return model
def load_chain(docsearch):
model = load_model()
chain = ConversationalRetrievalChain.from_llm(load_model,
chain_type=Config.chain_type,
retriever=docsearch.as_retriever(),
memory=Config.memory,
return_source_documents=True,
)
return chain
|