#hello

1 messages · Page 1 of 1 (latest)

olive sparrow
#

Just to clarify, you were able to get auth working and a basic implementation and response? Before we jump into the problem stated above.

crisp summit
#

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🙂

olive sparrow
#

I don't have any videos and I just use the guides, examples, and docs.

Let's go back to basics.

  1. Assuming you have auth working, make sure that you have authenticated. As the auth does expire.
  2. 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.

crisp summit
#

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

olive sparrow
#

so your env and/or auth is not setup correctly

crisp summit
#

yup
i will look into it

#

thanks and sorry again

olive sparrow
#

What's the error message? And you are running the above code as is?

crisp summit
#
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*

olive sparrow
#

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).```
crisp summit
#

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

olive sparrow
#

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
crisp summit
#

1.)running locally on my computer
2.)probably not(how do i do that?)
3.)running from VSCode itself

olive sparrow
#

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.

crisp summit
#

ill be offline for some time now
its 2am here
try and get some sleep probably😅

olive sparrow
#

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

crisp summit
#

im just making the obvious changes from colab to vsc and running it

olive sparrow
#

Yeah, sleep is good.

You should break this down in vsc to the very basic when you're back at this.

  1. ensure auth
  2. create a brand new python file just name it anything like test_auth.py
  3. 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])
  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"

crisp summit
#

yup alright
ill do that tomorrow and let you know
thanks!

crisp summit
# olive sparrow Yeah, sleep is good. You should break this down in vsc to the very basic when ...

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)
olive sparrow
#

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.

crisp summit
#

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

olive sparrow
#

Are you using jupyter?

crisp summit
#

aah no no
i just work in a ipynb file in vsc itself

olive sparrow
#

What is different in your file other than the extension?

crisp summit
#

nothing

#

its the same

olive sparrow
#

So if you take the test_auth.py and rename to test_auth.ipynb and run it in VSCode what do you get?

crisp summit
#

its just that the ipynb shows the unauthenticated error and py doesnt
which seems really strange

olive sparrow
#

yeah, file extension shouldn't matter so something else is different in how you are running it

crisp summit
olive sparrow
#

how did you run test_auth.py before? through vsc?

crisp summit
#

yup

#

same venv

olive sparrow
#

So it sounds like vsc is running .py vs .ipynb differently

crisp summit
#

yeah i think so

#

idk man
i feel so confused and lost
im just an intern who has been given the whole project

#

sorry for the vent

olive sparrow
#

So unfortunately I dont use jupyter so not familiar with the details and how it interacts with vsc

crisp summit
#

yup okay
no worries
ill see what i can do

olive sparrow
#

is there a specific reason for using jupyter or ipynb?

crisp summit
#

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

olive sparrow
#

hmm, I don't want to lead you down the wrong path since I've never used jupyter notebooks

crisp summit
#

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

olive sparrow
#

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.

crisp summit
#

Oh okay

#

I'll see what I can do then

#

Thanks for your time

olive sparrow
#

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.

crisp summit