Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

AttributeError: 'str' object has no attribute 'get' random stuff api python

I am trying to make an AI Chatbot using the Random stuff api and whenever I try to make one, I always get this error (I am using replit.com to host):

Traceback (most recent call last):
  File "main.py", line 5, in <module>
    response = client.get_ai_response("Hi there!")
  File "/home/runner/ChatBot/venv/lib/python3.8/site-packages/randomstuff/client.py", line 254, in get_ai_response
    message=response[0].get('response'),
AttributeError: 'str' object has no attribute 'get'

The code is here:

    import randomstuff

    client = randomstuff.Client(api_key="xxx")

    response = client.get_ai_response("Hi there!")
    print(response.message)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I believe this API has been deprecated:

Hey there, we have deprecated our old version and now we can only be operated through RapidApi. Kindly headover to https://api.pgamerx.com/new for more information

You should switch to the new version since the old one no longer works.

Incidentally, this is also why you get the error, since any call to the old API would return the above string, which obviously doesn’t have a get() function.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading