ollama/examples/langchain-python-rag-websummary/main.py

13 lines
397 B
Python
Raw Normal View History

from langchain_community.llms import Ollama
from langchain_community.document_loaders import WebBaseLoader
2023-08-09 18:49:22 +00:00
from langchain.chains.summarize import load_summarize_chain
loader = WebBaseLoader("https://ollama.com/blog/run-llama2-uncensored-locally")
2023-08-09 18:49:22 +00:00
docs = loader.load()
llm = Ollama(model="llama3")
2023-08-09 18:49:22 +00:00
chain = load_summarize_chain(llm, chain_type="stuff")
result = chain.invoke(docs)
2023-08-09 18:49:22 +00:00
print(result)