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
Close
Hashes for llama_index_llms_palm-0.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a963102accf249e3e647b60fdd7d178306fd0fd04ff16deec4dbbe51aa0e3b2f |
|
MD5 | 1be493ff23fce994d237759a0f1c59ac |
|
BLAKE2b-256 | 3249b3d71f366e3a741fd1d73c1d3bed75e47fe1c560815c39cd034df0845d21 |
Close
Hashes for llama_index_llms_palm-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ec74d74647b0a43893f4db78796066c77ac947750175d68a3e33213281e698b |
|
MD5 | aae9931d0479f146860b60766bc32f93 |
|
BLAKE2b-256 | 8a41fbfa6fb1c961ee5aee4e3ef90a4b9a6023a14cf2a101a5cc9c2cfb4d2548 |