Closed gururise closed 1 year ago
Thanks for the report.
Can you provide any more info here? I assume you ran them both from the same machine - can you confirm that? Do you have a proxy configured? (curl is more likely to be using the proxy than Python)
Can you provide the version of the Python package you're using? And the version of Python you're using (looks like 3.10, is that right?) A pip freeze
dump of your virtualenv would help too.
Does this happen 100% of the time, if not, what fraction? Does it work if you change the prompts so they match across REST/Py calls?
And one other thing to try - by default the Python client uses grpc, so can you try using REST in Python? And please report back if there's any difference.
import google.generativeai as palm
palm.configure(api_key=..., transport="rest")
@markmcd I tried the above with transport rest and still getting the error:
On MacOS btw. X11 is installed, Xquartz is installed, python, etc
I found out that disabling ipv6 and only allowing ipv4 resolved this issue.
Happened 100% of the time if ipv6 was enabled. Running from a VPS.
@gururise before you imported did you enter a python env or a virtual env? If not, did you remain in shell when this issue came up?
I found out that disabling ipv6 and only allowing ipv4 resolved this issue.
Happened 100% of the time if ipv6 was enabled. Running from a VPS.
That's interesting - can you provide any more info? e.g. the hosting service you used? the v6 block? do you happen to know if curl was connecting via v6 or v4?
I don't think this is expected - Google infra pretty widely supports ipv6 - but just in case there's an infra bug on our end, it'd be good to squash it. I'm trying to narrow down whether it's in the Python support or more broadly.
If you're concerned about sharing any info, but would be willing to share it directly, my email is the first 2 and last 2 characters of my GH username @google.com. It is also in the Git logs in this repo.
@yarub123
I tried the above with transport rest and still getting the error:
That looks like you're trying to run python code in your shell, and it's running some other program called import
.
@MarkDaoust thanks for following up. Time flies way too damn fast. But yeah, I had to enter the py env first before trying the above import and the api key with "transport." The "transport" code as given above by @markmcd worked. The one with "os.key" in the main readme did not work because I first had to define the variable "os" in order to get it to work. Thank you though.
I heard that they recently removed the region filter. Can you try again?
@markmcd, I have been facing an error which shows:- please can you help me out...
@GuHaRaJ, I think this might be https://github.com/google/generative-ai-python/issues/50, so could you respond over there?
Have you used gcloud
at all? The client library will try to use the application default credentials if they are available (e.g. because you have run gcloud auth application-default login ...
), and will do this automatically and transparently.
I listed a possible solution in https://github.com/google/generative-ai-python/issues/50#issuecomment-1648788032 - try that and let me know (on that issue) how it goes.
@markmcd thanks for helping me out. Basically I am a beginner and could not figure out on how to fix the problem.I found out the title of the issue (later on changed) which was matching with my code error , therefore posted my error here. After referring #50 section discussions , i have tried running it in .venv
mode , and it is working.
Anyways thanks for your concern 🤝...
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!
Using curl in the terminal works just fine.
The above works just fine, however, when I try:
Results in the following error: