Back to Llama Index

PaLM

docs/examples/llm/palm.ipynb

0.14.211.1 KB
Original Source

<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/palm.ipynb" target="_parent"></a>

PaLM

In this short notebook, we show how to use the PaLM LLM from Google in LlamaIndex: https://ai.google/discover/palm2/.

We use the text-bison-001 model by default.

Setup

If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.

python
%pip install llama-index-llms-palm
python
!pip install llama-index
python
!pip install -q google-generativeai
python
import pprint
import google.generativeai as palm
python
palm_api_key = ""
python
palm.configure(api_key=palm_api_key)

Define Model

python
models = [
    m
    for m in palm.list_models()
    if "generateText" in m.supported_generation_methods
]
model = models[0].name
print(model)

Start using our PaLM LLM abstraction!

python
from llama_index.llms.palm import PaLM

model = PaLM(api_key=palm_api_key)
python
model.complete(prompt)