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)
>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.