CodeWithSwastik/prsaw

Unexpected?

StarTwi opened this issue · 15 comments

Literally copy pasted the code and tried to run it but got an unexpected error ew
<coroutine object RandomStuff.get_ai_response at 0x01FD3A68> test.py:11: RuntimeWarning: coroutine 'RandomStuff.close' was never awaited rs.close() RuntimeWarning: Enable tracemalloc to get the object allocation traceback sys:1: RuntimeWarning: coroutine 'RandomStuff.get_ai_response' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0188E730>

You have to do:

await rs.close()

Not just rs.close()

bruh read what I said carefully so you understand

Literally copy pasted the code and tried to run it but got an unexpected error ew
<coroutine object RandomStuff.get_ai_response at 0x01FD3A68> test.py:11: RuntimeWarning: coroutine 'RandomStuff.close' was never awaited rs.close() RuntimeWarning: Enable tracemalloc to get the object allocation traceback sys:1: RuntimeWarning: coroutine 'RandomStuff.get_ai_response' was never awaited RuntimeWarning: Enable tracemalloc to get the object allocation traceback Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0188E730>

You're missing an await in some place, specifically somewhere along RandomStuff.get_ai_response(...)

if you actually want it to be blocking instead of async, do not pass async_mode=True to RandomStuff()

@FalseDev Am facing the same issue but removing async_mode=True doesn't helps either. Instead the bot gives this missing API message (even though I have one and used it as #prsaw.RandomStuff().api_key="my-api-key-here"#). Please help!

async_mode is True by default, you'll actually have to set it to False to use it without awaits

RandomStuff(async_mode=False)

async_mode is True by default, you'll actually have to set it to False to use it without awaits

RandomStuff(async_mode=False)

@FalseDev I've set async_mode to False too, still the API missing problem remains. Here's the part of the code:

api_key = "my-api-code"
RandomStuff().api_key=api_key
rs = RandomStuff(async_mode=False)

![See this]
(https://user-images.githubusercontent.com/69592060/114262710-113f3f80-99ff-11eb-867f-e0f386abde04.png)

Note: I'm trying to get "get_ai_response(msg.content)" to work here.

I tested myself and got the following working

Async:

import prsaw
rs = prsaw.RandomStuff(async_mode=True)
reply = await rs.get_ai_response("Hello!")
print(reply)

Sync:

import prsaw
rs = prsaw.RandomStuff()
reply = rs.get_ai_response("Hello!")
print(reply)

Make sure you're not passing in any api_key if you don't have one, the example key shown is obviously invalid

async_mode is True by default, you'll actually have to set it to False to use it without awaits

RandomStuff(async_mode=False)

@FalseDev I've set async_mode to False too, still the API missing problem remains. Here's the part of the code:

api_key = "my-api-code"
RandomStuff().api_key=api_key
rs = RandomStuff(async_mode=False)

![See this]
(https://user-images.githubusercontent.com/69592060/114262710-113f3f80-99ff-11eb-867f-e0f386abde04.png)

Note: I'm trying to get "get_ai_response(msg.content)" to work here.

What you did

api_key = "my-api-code"
RandomStuff().api_key=api_key
rs = RandomStuff(async_mode=False)

What you should have done

api_key = "my-api-code"
rs = RandomStuff(api_key=api_key)

@FalseDev Tried out both of them already, but here are the respective problems:

On using the Async mode, Am getting this weird error: <coroutine object Endpoint.async_call at 0x7f1b9e7b0340> as the bot reply.
On using the Sync mode, Am still getting the missing API key message.

Even just for testing purpose I didn't use my api_key to check if it was working but it still raises error (Note: I do have a valid api_key already but it doesn't makes any change)

async_mode is True by default, you'll actually have to set it to False to use it without awaits

RandomStuff(async_mode=False)

@FalseDev I've set async_mode to False too, still the API missing problem remains. Here's the part of the code:
api_key = "my-api-code"
RandomStuff().api_key=api_key
rs = RandomStuff(async_mode=False)
![See this]
(https://user-images.githubusercontent.com/69592060/114262710-113f3f80-99ff-11eb-867f-e0f386abde04.png)
Note: I'm trying to get "get_ai_response(msg.content)" to work here.

What you did

api_key = "my-api-code"
RandomStuff().api_key=api_key
rs = RandomStuff(async_mode=False)

What you should have done

api_key = "my-api-code"
rs = RandomStuff(api_key=api_key)

Okii so first of all, they both should have done the same thing. But anyways, neither of the way solves the problem. Infact using it as "rs = RandomStuff(api_key=api_key)" raises an error : -

Traceback (most recent call last):
File "main.py", line 19, in
rs = prsaw.RandomStuff(api_key=api_key)
TypeError: init() got an unexpected keyword argument 'api_key'

that's why I used another way to pass it down.

You're on an older version @Aestivial! Update to the latest (v0.3.1) to use the updated random stuff API

You're on an older version @Aestivial! Update to the latest (v0.3.1) to use the updated random stuff API

Oh, I pulled prsaw via pip though, :p lemme see if it's solved after updating. Thanks!

@FalseDev @CodeWithSwastik Thank You so much guys!!! XD Sorry it was just an stupid issue about updates uff ... You all really helped me out so much! Thanks again!

@Aestivial Please close this issue.

@Aestivial Please close this issue.

Oops, sorry I didn't notice your message before (ugh, damn them exams). BTW I can't understand how do I close this issue.