import time import gradio as gr from langchain.llms import GPT4All from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler from langchain.prompts import PromptTemplate from langchain.chains import LLMChain from gpt4all import GPT4All from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler # Callbacks support token-wise streaming model = GPT4All("orca-mini-3b.ggmlv3.q4_0.bin") template = """Question: {question} Answer: Let's think step by step.""" prompt = PromptTemplate(template=template, input_variables=["question"]) prompt_template = """ ### System: Answer the question based on the input below. If the question cannot be answered using the information provided answer with "I don't know". Ever answer in spanish. ### Input: %s ### User: Question: %s ### Response: Respuesta:""" def FinderDb(query,dbs,filtred=False): Sal = dbs.similarity_search_with_score(query,9) page_content=[] d=[] if filtred: lim=1.5 else: lim=9000000 for output in Sal: if output[1]