Skip to content

Instantly share code, notes, and snippets.

@hemanth
Created March 12, 2024 00:24
Show Gist options
  • Save hemanth/7133e70f709e2b0f33f740065221c266 to your computer and use it in GitHub Desktop.
Save hemanth/7133e70f709e2b0f33f740065221c266 to your computer and use it in GitHub Desktop.
Summarize URL with llama_index and ollama
from llama_index.core import VectorStoreIndex, download_loader
from llama_index.llms.ollama import Ollama
from llama_index.embeddings.huggingface import HuggingFaceEmbedding
from llama_index.core import Settings
from llama_index.llms.ollama import Ollama
from IPython.display import display
Settings.llm = Ollama(model="mistral:latest", request_timeout=30.0)
Settings.embed_model = HuggingFaceEmbedding(model_name="BAAI/bge-small-en-v1.5")
SimpleWebPageReader = download_loader("SimpleWebPageReader")
loader = SimpleWebPageReader()
documents = loader.load_data(urls=['https://h3manth.com'])
index = VectorStoreIndex.from_documents(documents)
engine = index.as_query_engine()
response = engine.query("Summarize the website in 5 points")
display((f"{response}"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment