#hello
1 messages · Page 1 of 1 (latest)
Just to clarify, you were able to get auth working and a basic implementation and response? Before we jump into the problem stated above.
yup
i proceeded with the commands such as
for i, m in zip(range(5), genai.list_tuned_models()):
print(m.name)
which were showing the same unauthenticated error
but commands that you suggested to proceed with, like:
'import google.generativeai as genai
print('Available base models:', [m.name for m in genai.list_models()])
they dont show it
i dont know whats wrong with the code present in google colab
or is it just me
my basic idea was to follow the code in colab that will help me tune a model by simply just taking the help of the code and put it in my vsc
do you have any youtube videos related to this stuff that can help me out
so that i can also stop bothering you🙂
I don't have any videos and I just use the guides, examples, and docs.
Let's go back to basics.
- Assuming you have auth working, make sure that you have authenticated. As the auth does expire.
- If Step 1 is good then run this very basic code
import google.generativeai as genai
print("Available base models:")
for m in genai.list_models():
print(m.name.split("/")[1])
print("My tuned models:")
for m in genai.list_tuned_models():
print(m.name.split("/")[1])```
If that doesn't work then there's some basic things not setup correctly with your env and auth.
I'm assuming you're running python and have the latest libraries/SDKs.
yeah i still do get the error
i made sure i had done everything the right way the way it has been said in the website
i get the output for list of models
but get an error for the tuned models
im sorry
thats my bad
so your env and/or auth is not setup correctly
What's the error message? And you are running the above code as is?
Cell In[15], line 7
5 print(m.name.split("/")[1])
6 print("My tuned models:")
----> 7 for m in genai.list_tuned_models():
8 print(m.name.split("/")[1])
File ~/miniconda3/envs/llm/lib/python3.9/site-packages/google/generativeai/models.py:223, in list_tuned_models(page_size, client, request_options)
220 if client is None:
221 client = get_default_model_client()
--> 223 for model in client.list_tuned_models(
224 page_size=page_size,
225 **request_options,
226 ):
227 model = type(model).to_dict(model)
228 yield model_types.decode_tuned_model(model)
File ~/miniconda3/envs/llm/lib/python3.9/site-packages/google/ai/generativelanguage_v1beta/services/model_service/client.py:1140, in ModelServiceClient.list_tuned_models(self, request, page_size, page_token, retry, timeout, metadata)
1137 self._validate_universe_domain()
1139 # Send the request.
-> 1140 response = rpc(
1141 request,
1142 retry=retry,
1143 timeout=timeout,
...
metadata {
key: "method"
value: "google.ai.generativelanguage.v1beta.ModelService.ListTunedModels"
}
]```
and yeah running the code as is
in my env*
in your venv when you run the following
gcloud auth application-default login --client-id-file=client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning'
- Does it open a browser and have to authenticate and grant access?
- Once browser steps completed, does the terminal output success, path to application_default_credentials.json?
https://accounts.google.com/o/oauth2/...truncated...
Credentials saved to file: [...truncated...application_default_credentials.json]
These credentials will be used by any library that requests Application Default Credentials (ADC).```
yup
does all of that
i also go to the browser and make sure i login to the account using the mail that i have put in the OAuth while authenticating
I forgot to ask, where is your venv, where are you running it, how are you developing?
- on a server or locally on your computer
- does the venv have access to a browser
- are you running from a terminal or VSCode or some other IDE
1.)running locally on my computer
2.)probably not(how do i do that?)
3.)running from VSCode itself
Sorry stepped away for lunch.
Can you provide more of the error message? Looks like you truncated some of the output. Especially the part before metadata { in your error output above.
hmm... can you provide the sample code you are running? it is using the wrong auth key.
401 API keys are not supported by this API
its basically this code
im just making the obvious changes from colab to vsc and running it
Yeah, sleep is good.
You should break this down in vsc to the very basic when you're back at this.
- ensure auth
- create a brand new python file just name it anything like test_auth.py
- only have the following code and nothing else
import google.generativeai as genai
print("Available base models:")
for m in genai.list_models():
print(m.name.split("/")[1])
print("My tuned models:")
for m in genai.list_tuned_models():
print(m.name.split("/")[1])
- we want to see what the error is on running test_auth.py
You seem to have too much going on and we're having a hard time debugging so we just want to make sure we remove any other unnecessary code.
In your latest error output we want to make sure we address this
Unauthenticated: 401 API keys are not supported by this API. Expected OAuth2 access token or other authentication credentials that assert a principal. See https://cloud.google.com/docs/authentication [reason: "CREDENTIALS_MISSING"
yup alright
ill do that tomorrow and let you know
thanks!
hello again,
i tried doing what you asked for
created a totally new .py file
Available base models:
chat-bison-001
text-bison-001
embedding-gecko-001
gemini-1.0-pro
gemini-1.0-pro-001
gemini-1.0-pro-latest
gemini-1.0-pro-vision-latest
gemini-1.5-pro-latest
gemini-pro
gemini-pro-vision
embedding-001
text-embedding-004
aqa
My tuned models:```
this is what i get as my output with no "unauthenticated" error for some reason, which i did not seem to understand why
i also tried running a brand new .ipynb file and ran the same code in a cell which gave me the same error as you had discussed about yesterday(401 API keys)
So, following my instructions and code, it is functioning as expected with no auth errors. That's a good step
That means your auth is setup correctly and when using the python library it's authenticating correctly.
i just had a small doubt if we have to specifically use a.py file
cause i had been working on .ipynb since the start
i feel .ipynb is more convinient when you want to train/tune a model
Are you using jupyter?
aah no no
i just work in a ipynb file in vsc itself
What is different in your file other than the extension?
So if you take the test_auth.py and rename to test_auth.ipynb and run it in VSCode what do you get?
its just that the ipynb shows the unauthenticated error and py doesnt
which seems really strange
yeah, file extension shouldn't matter so something else is different in how you are running it
i get the "uauthenticated- 401 API key" error
how did you run test_auth.py before? through vsc?
So it sounds like vsc is running .py vs .ipynb differently
yeah i think so
i was trying to work in .py and faced this error
idk man
i feel so confused and lost
im just an intern who has been given the whole project
sorry for the vent
So unfortunately I dont use jupyter so not familiar with the details and how it interacts with vsc
yup okay
no worries
ill see what i can do
is there a specific reason for using jupyter or ipynb?
i feel like its the normal thing to do when you are training a model
you just run the cell that you have made for training
and then observe the output there itself
hmm, I don't want to lead you down the wrong path since I've never used jupyter notebooks
Yeah sounds fair
Is there anything that you can help me out here with
I'm ready to work with .py
I'm just want it to work now tbh
Just depends on what path you want to go down and how much time you have. You can go straight python but that's not my place to advise on.
Just out of curiousity from the docs. Do you have this follow code and what happens when you run that section before running the test_auth code?
import os
if 'COLAB_RELEASE_TAG' in os.environ:
from google.colab import userdata
import pathlib
pathlib.Path('client_secret.json').write_text(userdata.get('CLIENT_SECRET'))
# Use `--no-browser` in colab
!gcloud auth application-default login --no-browser --client-id-file client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning'
else:
!gcloud auth application-default login --client-id-file client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning'
Essentially it sounds like you just need to get your notebook to auth and recognize it
Since you're not using colab the first if should fail and go to else.
i do
it just does the same thing as
gcloud auth application-default login --client-id-file=client_secret.json --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/generative-language.tuning'