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

Does the API work at the moment? #3

Closed TomTlok closed 1 year ago

TomTlok commented 1 year ago

I get the error: {JSONDecodeError}JSONDecodeError('Expecting value: line 1 column 1 (char 0)')

The blue area (in the attached file below) is my copied cookie and i get the error by using Claude(cookie). Claude2

Nipun1212 commented 1 year ago

hi, the api seems to be working fine, issue might be with the cookie you copied, if you're having troubles, I would suggest copying only the session key cookies as that is the only thing that is needed, it is of the form: "sessionKey=sk-ant-sid01-3Q8F4.....pAAA;" and paste this in the cookies section, otherwise can just send me a snippet of your code.

TomTlok commented 1 year ago

Hi, thank you for the fast reply and help. I paste the cookie in as you said, but then I got this error: {JSONDecodeError}JSONDecodeError('Expecting value: line 1 column 1 (char 0)'). If I set the cookie to the value without sessionkey=, I get and 403 error. I know that my cookie ist working, because I used in in a javascript Claude2 API. Here is a Snippet of my code:

from claude import Claude

cookie = 'sk-ant-sid01-8aznL0R_...QMsOIwBV_Q-YaigVQAA;'

def response_from_claude2(prompt): claude = Claude(cookie)

try:
    response = claude.get_answer(prompt)
    print(response)

except Exception as e:
    print(f"Fehler beim Abrufen der Antwort von Claude2: {e}")

Thank you for your time. :)

gamedevjoey commented 1 year ago

hey im having the same issue is there a known problem?

Nipun1212 commented 1 year ago

hi, what exactly is your error, can you send a screenshot? I'll look into it

yongzhi-weee commented 1 year ago
from claude import Claude

cookie = 'sessionKey=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;'

claude = Claude(cookie)

prompt = "Hello, Claude!"
response = claude.get_answer(prompt)
print(response)

image

image

Nipun1212 commented 1 year ago
image

hi, I tried your code with your session id and I was able to log in, but it seems like there's some error in getting the answers from the claude ai model, which I will look into now and try to fix.

Please give me some time to fix that. In the meanwhile, you can check your python version, maybe that is causing the error, please let me know if the issue persists

Nipun1212 commented 1 year ago

I think it's a region issue, can you guys try a vpn. I found it worked for people with similar issues

image
yongzhi-weee commented 1 year ago

I really appreciate your help,i will try vpn

jkfran commented 1 year ago

I am also having the same issue (I am in the UK but the web version works here)

Nipun1212 commented 1 year ago

Hi so sorry. I was travelling so was unable to check the messages. I have figured out the fix , I'll be upgrading the package soon. You can upgrade the version and it should work fine. Just give me like a day to sort it out. Thanks a lot for your patience.

jumasheff commented 1 year ago

@Nipun1212 looking forward to installing a new version of the package!

Nipun1212 commented 1 year ago

hi, I would just like to inform everyone that the package has been upgraded and now works. I have tested it thoroughly. Just run this line in your terminal pip install --upgrade claude2 and check the version, it should be 1.1.5 Please let me know if you guys face any more issues.