llama-index llms palm integration
Project description
LlamaIndex Llms Integration: Palm
Installation
To install the required packages, run:
%pip install llama-index-llms-palm
!pip install llama-index
!pip install -q google-generativeai
Note: If you're using Colab, the above commands will install the necessary packages. If you see a notice about updating
pip
, you can do so with:pip install --upgrade pip
Setup
Import Libraries and Configure API Key
Import the necessary libraries and configure your PaLM API key:
import pprint
import google.generativeai as palm
palm_api_key = "" # Add your API key here
palm.configure(api_key=palm_api_key)
Define the Model
List and select the available models that support text generation:
models = [
m
for m in palm.list_models()
if "generateText" in m.supported_generation_methods
]
model = models[0].name
print(model)
You should see output similar to:
models/text-bison-001
Using the PaLM LLM Abstraction
Now you can use the PaLM model to generate text. Here’s how to complete a prompt:
from llama_index.llms.palm import PaLM
model = PaLM(api_key=palm_api_key)
# Example prompt
prompt = "Once upon a time in a faraway land, there lived a"
response = model.complete(prompt)
print(response)
LLM Implementation example
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file llama_index_llms_palm-0.3.0.tar.gz
.
File metadata
- Download URL: llama_index_llms_palm-0.3.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd86caae7269f6f40cb2b1006ebfcdf888c274c23b7454f46350c1f41b509ca4 |
|
MD5 | b43a969e7b85d21272855c94dfa8b4b8 |
|
BLAKE2b-256 | 0fb36a21c40ef301b046f8259631026b59f8873a417dabf7745a9f3332b19602 |
File details
Details for the file llama_index_llms_palm-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: llama_index_llms_palm-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.10 Darwin/22.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b5deda76519678c7760c662fbbed7035b93af780b81d5191c22011592c8453 |
|
MD5 | 45e20032d7f00fc878449694cc0c9e1d |
|
BLAKE2b-256 | 23e3e465f4f7f0c51d81e112c5c07ca83938cd9acf24540def433d0559b0c553 |