docs/examples/llama_hub/llama_pack_ollama.ipynb
!wget "https://www.dropbox.com/s/f6bmb19xdg0xedm/paul_graham_essay.txt?dl=1" -O paul_graham_essay.txt
from llama_index.core import SimpleDirectoryReader
# load in some sample data
reader = SimpleDirectoryReader(input_files=["paul_graham_essay.txt"])
documents = reader.load_data()
Make sure you run ollama run llama2 in a terminal.
# !ollama run llama2
We use download_llama_pack to download the pack class, and then we initialize it with documents.
Every pack will have different initialization parameters. You can find more about the initialization parameters for each pack through its README (also on LlamaHub).
NOTE: You must also specify an output directory. In this case the pack is downloaded to voyage_pack. This allows you to customize and make changes to the file, and import it later!
from llama_index.core.llama_pack import download_llama_pack
# download and install dependencies
OllamaQueryEnginePack = download_llama_pack(
"OllamaQueryEnginePack", "./ollama_pack"
)
# You can use any llama-hub loader to get documents!
ollama_pack = OllamaQueryEnginePack(model="llama2", documents=documents)
response = ollama_pack.run("What did the author do growing up?")
print(str(response))