File size: 722 Bytes
4df694c | 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 Ollama
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
llm = Ollama(model="llama2-uncensored",
# callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]),
temperature=0.9,
)
from langchain.prompts import PromptTemplate
prompt = PromptTemplate(
input_variables=["topic"],
template="Give me 5 interesting facts about {topic}?",
)
from langchain.chains import LLMChain
chain = LLMChain(llm=llm,
prompt=prompt,
verbose=False)
# Run the chain only specifying the input variable.
print(chain.run("the moon")) |