Authentication error using text2-palm

Dear all,

I’m completely a newbie. I would like to configure to use text2vec-palm (Google PaLM instead of open ai, as given in Weaviate’s example). Refer to my code fragments below, I get error when executing in code fragment 3: batch.add_data_object…

My CoLaboratory notebook complains that google authentication is missing, suggesting to provide oauth token etc.

I’m stuck at this point. Grateful if someone can shown you sample code that uses text2vec-palm.

Thanks a lot!

code segment 1 - client config

import weaviate

auth_config = weaviate.AuthApiKey(api_key=“MY_WEAVIATE_KEY”)

client = weaviate.Client(
url=“https://my_weaviate.weaviate.network”,
auth_client_secret=auth_config,
additional_headers = {

    "X-Palm-Api-Key": "MY_GOOGLE_PROJ_API_KEY"  # Replace with your API key
}

)

code fragment 2 - class def.

class_obj = {
“class”: “Question”,

"moduleConfig": {
    "vectorizeClassName": "true",
    "text2vec-palm":  {"projectId": "MY_GOOGLE_PROJ_ID }, # projectId is required
    "generative-palm": { "projectId": "MY_GOOGLE_PROJ_ID" }  # Ensure the `generative-palm` module is used for generative queries, projectId is required
}

}

client.schema.create_class(class_obj)

code fragment 3 - add objects

import requests
import json
resp = requests.get(‘MY_DATA.json’)
data = json.loads(resp.text) # Load data

client.batch.configure(batch_size=100) # Configure batch
with client.batch as batch: # Initialize a batch process
for i, d in enumerate(data): # Batch import data
print(f"importing question: {i+1}“)
properties = {
“answer”: d[“Answer”],
“question”: d[“Question”],
“category”: d[“Category”],
}
print(f"property: {properties}”)
batch.add_data_object(
data_object=properties,
class_name=“Question”
)

Hi!

Can you share here the exact error message you got?

Unfortunately I was not able to get my hands on a palm API yet…

The following error message shows in CoLab notebook when running the batch.add_data_object line as in code fragement 3 above. Thanks

{‘error’: [{‘message’: ‘update vector: connection to Google PaLM failed with status: 401 error: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.’}]}

I’m getting basically the same issue… anyone know how to resolve this?

details = “explorer: get class: vectorize params: vectorize params: vectorize params: vectorize keywords: remote client vectorize: connection to Google failed with status: 401 error: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

Hi @elynnstl,

That error is coming from you not passing in the API correctly. Since you want to use a multi-modal model, you’ll have to use VertexAI.

If you go to your Google Cloud dashboard, click on the Activate Cloud Shell button (on the upper right). Once the terminal is connected, write gcloud auth print-access-token and it should print out a key. You’ll have to refresh the token every hour and the instructions are here.

If you’re using WCD, you will pass it under the X-Google-Vertex-Api-Key header. If you deployed it yourself, you can also set USE_GOOGLE_AUTH=true and Weaviate will generate the Vertex API key for you.