Nipun1212 / Claude_api

Claude_api is a Python package that provides a convenient way to interact with Claude 2 from Anthropic.
https://pypi.org/project/claude2/1.0.1/
MIT License
113 stars 6 forks source link

Would it be possible to add proxy support? #4

Closed Dima-369 closed 1 year ago

Dima-369 commented 1 year ago

That way, I could access this outside the 'supported' countries.

Nipun1212 commented 1 year ago

Hi Dima, I currently access it from Singapore which isn’t in the list of supported countries, and it works well. You only need to register once with the VPN of the registered country, after that you can access it from anywhere. Is there any issue you’re facing?

Dima-369 commented 1 year ago

Is there any issue you’re facing?

Yeah, I get this. I added print(lines) to def get_answer(self,prompt): to see the error. No idea how to work around this though.

Found old conversations, using the most recent one
['{"error": {"type": "permission_error", "message": "We are unable to serve your request"}}']
Dima-369 commented 1 year ago

I get the same error when using claude.create_new_conversation() before.

Nipun1212 commented 1 year ago

okay, let me look into this! can you let me know which country you are accessing the api from? and when did the issue first happen?

Dima-369 commented 1 year ago

can you let me know which country you are accessing the api from?

Germany.

and when did the issue first happen?

I think I always had issues using this package, I just wanted finally note it down ;)

Nipun1212 commented 1 year ago

and are you sure you're copying the whole session key cookie from the browser, because this error sometimes comes because of that. I jut tried accessing the api, and it worked for me, I am also accessing it from a non supported country

Dima-369 commented 1 year ago

I am using this code. Is this incorrect? I inserted ... in a few places, but did not touch the cookie keys like sessionKey=.

from claude import Claude

cookie = "intercom-device-id-lupk8zyo=...d1835ed5; __cf_bm=Vp4Tq1sik_Q_YAQ...Ms8k-1695200839-0-AVkRmai4aCd5PD/04v4u6C6g+Y3p...T1ByeuV+26YJUgMmJ/CNrZp4g+2vII9HPavmFCa5nc=; cf_clearance=8qSqujGm...PAswE-1695200841-0-1-754722c6.8446846a.22467d26-0.2.1695200841; sessionKey=sk-ant-sid01-y5...kDUmXTabK3rcg8ZCNoHD_lgcvqjP60E...AAA; intercom-session-lupk8zyo=b1M3NU...zZ2RlWm1BNElieWtTU3VDWmgrMzhkQzV3cGFZNjVRYW...RS3EwaWt4SnM5Zz09--35b234ffa70fa7a2c24...86"
claude = Claude(cookie)
claude.create_new_conversation()

prompt = "php strip string"
response = claude.get_answer(prompt)
print(response)
Nipun1212 commented 1 year ago

this is what I did and it is running, checked once again

from claude import Claude
cookie = "sessionKey=sk-...;"
claude = Claude(cookie)
prompt = "Hello, Claude!"
response=claude.get_answer(prompt)
print(response)

try using just the session key maybe, also make sure you have the latest version of the package installed

Dima-369 commented 1 year ago

try using just the session key maybe, also make sure you have the latest version of the package installed

I have the latest version. Just using the session key throws the exact same error. Guess, I'm out of luck since you can't reproduce it. Let's just close this issue then?

Nipun1212 commented 1 year ago

are you able to use it online, like from the official claude website?

Dima-369 commented 1 year ago

Yes, I access it via the Opera VPN.

CleanShot 2023-09-20 at 14 15 42

Nipun1212 commented 1 year ago

I can try adding some more headers to see if it can be fixed, because usually permission denied is because of a wrong cookie or authentication, as if it was a location issue I would be facing it too. Will let you know if I find anything.

Dima-369 commented 1 year ago

It's quite weird. So claude.create_new_conversation() works to create new conversations but getting an answer doesn't work.

discordby commented 1 year ago

curl_cffi.requests.errors.RequestsError: Failed to perform, ErrCode: 77, Reason: 'error setting certificate verify locations: CAfile: \Python\Python310\lib\site-packages\curl_cffi\cacert.pem CApath: none'

Nipun1212 commented 1 year ago

Claude just added support for many countries, so can check if its working not for you or not?

Dima-369 commented 1 year ago

Claude just added support for many countries, so can check if its working not for you or not?

Hey, cool, that you mention it! I just tested my exact same code above and it works flawlessly in Germany without a VPN now.

Thanks :)

Nipun1212 commented 1 year ago

okay perfect I'll close this issue then