Closed jillvillany closed 1 month ago
I figured out it was because I need to use the token parameter instead of API Key but now I am getting the below error:
Also - this article should be updated https://dataplatform.cloud.ibm.com/exchange/public/entry/view/c3dbf23a-9a56-4c4b-8ce5-5707828fc981?context=wx
Found out I needed to use the host URL (was using the full URL for generating a response from the prompt lab) but now I get this error ibm_watsonx_ai.wml_client_error.WMLClientError: Authorization failed with the error message: Authorization header has not been provided.
Ok I finally got the model to init - I had to remove the Bearer
prefix before the bearer token.
@jillvillany Yes, as a token user should pass token instead of passing Bearer prefix. Issue resolved, closing.
When I try to access the model below, I get the following error:
Attempt of authenticating connection to service failed, please validate your credentials. Error: {"errors":[{"code":"authentication_no_token","message":"Failed to authenticate the request due to no Bearer token in the request header","more_info":"https://cloud.ibm.com/apidocs/machine-learning-cp"}],"trace":"4b66d571-784b-4cf1-99b7-b6ebe3b82827","status_code":401}
It says I have no bearer token but I clearly specify it in the code below:
parameters = { GenParams.DECODING_METHOD: DecodingMethods.SAMPLE.value, GenParams.MAX_NEW_TOKENS: 900, GenParams.MIN_NEW_TOKENS: 1, GenParams.TEMPERATURE: 0.5, GenParams.TOP_K: 50, GenParams.TOP_P: 1 }
llama2_70b = WatsonxLLM( model_id="meta-llama/llama-2-70b-chat", url=os.getenv("CP_URL"), instance_id="openshift", version=os.getenv("CP_VERSION"), apikey= f"Bearer {os.getenv('CP_BEARER_TOKEN')}", username=os.getenv("CP_USERNAME"), project_id=os.getenv("PROJECT_ID"), params=parameters )