Spaces:
Runtime error
Runtime error
File size: 814 Bytes
f19e9c2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from langchain.llms import CTransformers
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
llm = CTransformers(model="TheBloke/Llama-2-7B-Chat-GGML", model_file = 'llama-2-7b-chat.ggmlv3.q2_K.bin', callbacks=[StreamingStdOutCallbackHandler()])
template = """
[INST] <<SYS>>
You are a helpful developed by Mohammed Vasim, respectful and honest assistant. Your answers are always brief.
<</SYS>>
{text}[/INST]
"""
prompt = PromptTemplate(template=template, input_variables=["text"])
# llm_chain = LLMChain(prompt=prompt, llm=llm)
def build_chain(llm=llm, prompt=prompt, template=template):
prompt = PromptTemplate(template=template, input_variables=["text"])
llm_chain = LLMChain(prompt=prompt, llm=llm)
return llm_chain |