Spaces:
Runtime error
Runtime error
File size: 1,508 Bytes
f972310 61d1dbd f972310 fc57c23 f972310 3bd7313 195cdd8 3bd7313 f972310 61d1dbd f972310 0caeb72 2b66cad f972310 | 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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
import streamlit as st
from langchain.llms import LlamaCpp
from langchain.embeddings import LlamaCppEmbeddings,OpenAIEmbeddings
from langchain.prompts import PromptTemplate
from langchain.chains import LLMChain
from langchain.document_loaders import TextLoader
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Chroma
from datetime import datetime
from langchain.chains import LLMChain, RetrievalQA
from langchain.vectorstores import Chroma, FAISS
from functions import *
prompt_template = """Use the following pieces of context to answer the question at the end.
You are a helpful,highly skilled AI writer made by greatidea. your purpose is to answer my questions in the most precise way possible. If you don't know the answer, just say that you don't know, don't try to make up an answer.
{context}
Question: {question}
Answer:"""
prompt = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
model='quinto.bin'
llm = LlamaCpp(model_path=model)
embeddings = LlamaCppEmbeddings(model_path=model)
llm_chain = LLMChain(llm=llm, prompt=prompt)
new_db = Chroma(embedding_function=embeddings)
qa = RetrievalQA.from_chain_type(
retriever = new_db.as_retriever(),
llm=llm,
chain_type="stuff",)
#retriever=retriever)
question = st.text_input("Ask me")
start=today()
result = qa({"query": question})
end = today()
st.write(result['result'])
print('question: ',question)
print('inizio: ', start)
print('fine: ', end)
|